How to use sure - 10 common examples

To help you get started, we’ve selected a few sure examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gabrielfalcao / sure / tests / test_old_api.py View on Github external
def test_microsecond_unit():
    "testing microseconds convertion"
    cfrom, cto = sure.UNITS[sure.microsecond]

    assert_equals(cfrom(1), 100000)
    assert_equals(cto(1), 1)

    cfrom, cto = sure.UNITS[sure.microseconds]

    assert_equals(cfrom(1), 100000)
    assert_equals(cto(1), 1)
github atlassistant / pytlas / tests / conversing / test_request.py View on Github external
def test_it_should_be_able_to_translate_text_in_the_interpreter_language(self):
    r = Request(self.agent, None, {
      'a text': 'un texte',
    })

    expect(r._('a text')).to.equal('un texte')
    expect(r._('not found')).to.equal('not found')
github mindflayer / python-mocket / tests / main / test_httpretty.py View on Github external
def test_httpretty_should_allow_multiple_methods_for_the_same_uri():
    """HTTPretty should allow registering multiple methods for the same uri"""

    url = 'http://test.com/test'
    methods = ['GET', 'POST', 'PUT', 'OPTIONS']
    for method in methods:
        HTTPretty.register_uri(
            getattr(HTTPretty, method),
            url,
            method
        )

    for method in methods:
        request_action = getattr(requests, method.lower())
        expect(request_action(url).text).to.equal(method)
github mindflayer / python-mocket / tests / main / test_httpretty.py View on Github external
def test_can_inspect_last_request():
    """HTTPretty.last_request is a mimetools.Message request from last match"""

    HTTPretty.register_uri(HTTPretty.POST, "http://api.github.com/",
                           body='{"repositories": ["HTTPretty", "lettuce"]}')

    response = requests.post(
        'http://api.github.com',
        '{"username": "gabrielfalcao"}',
        headers={
            'content-type': 'text/json',
        },
    )

    expect(HTTPretty.last_request.method).to.equal('POST')
    expect(HTTPretty.last_request.body).to.equal(
        b'{"username": "gabrielfalcao"}',
    )
    expect(HTTPretty.last_request.headers['content-type']).to.equal(
        'text/json',
    )
    expect(response.json()).to.equal({"repositories": ["HTTPretty", "lettuce"]})
github gabrielfalcao / HTTPretty / tests / functional / test_requests.py View on Github external
def test_httpretty_should_mock_headers_requests(now):
    "HTTPretty should mock basic headers with requests"

    HTTPretty.register_uri(HTTPretty.GET, "http://github.com/",
                           body="this is supposed to be the response",
                           status=201)

    response = requests.get('http://github.com')
    expect(response.status_code).to.equal(201)

    expect(dict(response.headers)).to.equal({
        'content-type': 'text/plain; charset=utf-8',
        'connection': 'close',
        'content-length': '35',
        'status': '201',
        'server': 'Python/HTTPretty',
        'date': now.strftime('%a, %d %b %Y %H:%M:%S GMT'),
    })
github gabrielfalcao / HTTPretty / tests / unit / test_httpretty.py View on Github external
def test_uri_info_full_url():
    uri_info = URIInfo(
        username='johhny',
        password='password',
        hostname=b'google.com',
        port=80,
        path=b'/',
        query=b'foo=bar&baz=test',
        fragment='',
        scheme='',
    )

    expect(uri_info.full_url()).to.equal(
        "http://johhny:password@google.com/?baz=test&foo=bar"
    )

    expect(uri_info.full_url(use_querystring=False)).to.equal(
        "http://johhny:password@google.com/"
    )
github atlassistant / pytlas / tests / supporting / test_manager.py View on Github external
def test_it_should_install_dependencies_when_updating(self):
        s = SkillsManager('skills')
        p = os.path.abspath('skills')

        with patch('os.path.isdir', return_value=True):
            with patch('os.path.isfile', return_value=True):
                with patch('builtins.open', mock_open(read_data='')):
                    with patch('subprocess.check_output') as sub_mock:
                        succeeded, failed = s.update('my/skill')

                        expect(succeeded).to.equal(['my/skill'])
                        expect(failed).to.be.empty

                        expect(sub_mock.call_count).to.equal(2)
                        sub_mock.assert_has_calls([
                            call(['git', 'pull'], cwd=os.path.join(
                                p, 'my__skill'), stderr=subprocess.STDOUT),
                            call(['pip', 'install', '-r', 'requirements.txt'],
                                cwd=os.path.join(p, 'my__skill'), stderr=subprocess.STDOUT),
                        ])
github atlassistant / pytlas / tests / conversing / test_agent.py View on Github external
def test_it_should_have_a_unique_id(self):
    agt1 = Agent(self.interpreter)
    agt2 = Agent(self.interpreter)

    expect(agt1.id).to_not.be.none
    expect(agt1.id).to.be.a(str)
    expect(agt2.id).to_not.be.none
    expect(agt2.id).to.be.a(str)

    expect(agt1.id).to_not.equal(agt2.id)
github ncjones / python-guerrillamail / tests.py View on Github external
def test_set_email_address_should_update_email_address(self, **kwargs):
        self.setup_mocks(**kwargs)
        self.mock_client.set_email_address.return_value = {'email_addr': 'test@users.org', 'email_timestamp': 1234}
        assert self.session.email_timestamp == 0
        self.session.set_email_address('newaddr')
        expect(self.session.email_address).to.equal('test@users.org')
github python-social-auth / social-app-django / tests / backends / utils_tests.py View on Github external
def test_load_backends(self):
        loaded_backends = load_backends((
            'social.backends.github.GithubOAuth2',
            'social.backends.facebook.FacebookOAuth2',
            'social.backends.flickr.FlickrOAuth'
        ))
        keys = list(loaded_backends.keys())
        keys.sort()
        expect(keys).to.equal(['facebook', 'flickr', 'github'])

        backends = ()
        loaded_backends = load_backends(backends, force_load=True)
        expect(len(list(loaded_backends.keys()))).to.equal(0)