How to use the httpretty.enable function in httpretty

To help you get started, we’ve selected a few httpretty 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 rosette-api / python / tests / test_rosette_api.py View on Github external
def test_for_no_content_or_contentUri(api, json_response, doc_params):
    """Test for missing content and contentUri in DocumentParameters"""
    httpretty.enable()
    httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info",
                           body=json_response, status=200, content_type="application/json")
    httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/entities",
                           body=json_response, status=200, content_type="application/json")

    doc_params['content'] = None
    with pytest.raises(RosetteException) as e_rosette:
        api.entities(doc_params)

    assert e_rosette.value.status == 'badArgument'
    assert e_rosette.value.message == 'Must supply one of Content or ContentUri'
    httpretty.disable()
    httpretty.reset()
github voxpupuli / pypuppetdb / tests / test_baseapi.py View on Github external
def test_with_token_authorization(self, token_baseapi):
        httpretty.enable()
        stub_request('https://localhost:8080/pdb/query/v4/nodes')
        token_baseapi._query('nodes')
        assert httpretty.last_request().path == '/pdb/query/v4/nodes'
        assert httpretty.last_request().headers['X-Authentication'] == \
            'tokenstring'
github zenodo / zenodo / zenodo / modules / github / testsuite / test_tasks.py View on Github external
def test_handle_payload(self):
        from zenodo.modules.github.tasks import handle_github_payload
        from invenio.modules.webhooks.models import Event

        httpretty.enable()
        extra_data = self.remote_token.remote_account.extra_data
        assert 'auser/repo-1' in extra_data['repos']
        assert 'auser/repo-2' in extra_data['repos']

        assert len(extra_data['repos']['auser/repo-1']['depositions']) == 0
        assert len(extra_data['repos']['auser/repo-2']['depositions']) == 0

        e = Event(
            user_id=self.user.id,
            payload=fixtures.PAYLOAD('auser', 'repo-1')
        )

        handle_github_payload(e.__getstate__())

        db.session.expire(self.remote_token.remote_account)
        extra_data = self.remote_token.remote_account.extra_data
github gabrielfalcao / HTTPretty / tests / functional / test_bypass.py View on Github external
httpretty.disable()

    fd = urllib2.urlopen('http://localhost:{}/go-for-bubbles/'.format(context.http_port))
    got1 = fd.read()
    fd.close()

    expect(got1).to.equal(
        b'. o O 0 O o . o O 0 O o . o O 0 O o . o O 0 O o . o O 0 O o .')

    fd = urllib2.urlopen('http://localhost:{}/come-again/'.format(context.http_port))
    got2 = fd.read()
    fd.close()

    expect(got2).to.equal(b'<- HELLO WORLD ->')

    httpretty.enable()

    fd = urllib2.urlopen('http://localhost:{}/go-for-bubbles/'.format(context.http_port))
    got3 = fd.read()
    fd.close()

    expect(got3).to.equal(b'glub glub')
    core.POTENTIAL_HTTP_PORTS.remove(context.http_port)
github voxpupuli / pypuppetdb / tests / test_baseapi.py View on Github external
def test_with_count_filter(self, baseapi):
        httpretty.enable()
        stub_request('http://localhost:8080/pdb/query/v4/nodes')
        baseapi._query('nodes', count_filter=1)
        assert httpretty.last_request().querystring == {
            'counts_filter': ['1']}
        httpretty.disable()
        httpretty.reset()
github rosette-api / python / tests / test_rosette_api.py View on Github external
def test_ping(api, json_response):
    """Test ping"""
    httpretty.enable()
    httpretty.register_uri(httpretty.GET, "https://api.rosette.com/rest/v1/ping",
                           body=json_response, status=200, content_type="application/json")

    result = api.ping()
    assert result["name"] == "Rosette"
    httpretty.disable()
    httpretty.reset()
github rosette-api / python / tests / test_rosette_api.py View on Github external
def test_the_morphology_compound_components_endpoint(api, json_response, doc_params):
    """Test the morphology compound-components endpoint"""
    httpretty.enable()
    httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info",
                           body=json_response, status=200, content_type="application/json")
    httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/morphology/compound-components",
                           body=json_response, status=200, content_type="application/json")

    result = api.morphology(doc_params, 'compound-components')
    assert result["name"] == "Rosette"
    httpretty.disable()
    httpretty.reset()
github rosette-api / python / tests / test_rosette_api.py View on Github external
def test_the_relationships_endpoint(api, json_response):
    """Test the relationships endpoint"""
    httpretty.enable()
    httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info",
                           body=json_response, status=200, content_type="application/json")
    httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/relationships",
                           body=json_response, status=200, content_type="application/json")

    params = DocumentParameters()
    params["content"] = "some text data"
    api.set_option('accuracyMode', 'PRECISION')
    result = api.relationships(params)
    assert result["name"] == "Rosette"
    httpretty.disable()
    httpretty.reset()
github toumorokoshi / uranium / tests / test_get_remote_script_full.py View on Github external
def test_get_remote_script(tmpdir):
    httpretty.enable()
    httpretty.register_uri(httpretty.GET, SCRIPT_URL, body=REMOTE_SCRIPT)
    script = get_remote_script(SCRIPT_URL)
    build = Build(tmpdir.strpath)
    script["setup"](build)
    httpretty.disable()
    httpretty.reset()
github frictionlessdata / datapackage-py / tests / test_datapackage.py View on Github external
def test_it_works_with_remote_files(self, datapackage_zip):
        httpretty.enable()

        datapackage_zip.seek(0)
        url = 'http://someplace.com/datapackage.zip'
        httpretty.register_uri(httpretty.GET, url, body=datapackage_zip.read(),
                               content_type='application/zip')

        dp = datapackage.DataPackage(url)
        assert dp.descriptor['name'] == 'proverbs'
        assert len(dp.resources) == 1
        assert dp.resources[0].data == b'foo\n'

        httpretty.disable()