How to use the httpretty.reset 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 influxdata / influxdb-client-python / influxdb2_test / test_WriteApiBatching.py View on Github external
def setUp(self) -> None:
        # https://github.com/gabrielfalcao/HTTPretty/issues/368
        import warnings
        warnings.filterwarnings("ignore", category=ResourceWarning, message="unclosed.*")
        warnings.filterwarnings("ignore", category=PendingDeprecationWarning, message="isAlive*")

        httpretty.enable()
        httpretty.reset()

        conf = influxdb2.configuration.Configuration()
        conf.host = "http://localhost"
        conf.debug = False

        self.influxdb_client = influxdb2.client.InfluxDBClient(url=conf.host, token="my-token")

        # self._api_client = influxdb2.ApiClient(configuration=conf, header_name="Authorization",
        #                                        header_value="Token my-token")

        write_options = WriteOptions(batch_size=2, flush_interval=5_000, retry_interval=3_000)
        self._write_client = WriteApi(influxdb_client=self.influxdb_client, write_options=write_options)
github rosette-api / python / tests / test_rosette_api.py View on Github external
def test_the_similar_terms_endpoint(api, json_response, doc_params):
    """Test the similar terms endpoint"""
    httpretty.enable()
    httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/semantics/similar",
                           body=json_response, status=200, content_type="application/json")

    api.set_option("resultLanguages", ["spa", "jpn", "deu"])
    result = api.similar_terms(doc_params)
    assert result["name"] == "Rosette"
    httpretty.disable()
    httpretty.reset()
github voxpupuli / pypuppetdb / tests / test_baseapi.py View on Github external
def test_with_url_path(self, baseapi):
        httpretty.enable()
        stub_request('http://localhost:8080/puppetdb/pdb/query/v4/nodes')
        baseapi.url_path = '/puppetdb'
        baseapi._query('nodes')
        assert httpretty.last_request().path == '/puppetdb/pdb/query/v4/nodes'
        httpretty.disable()
        httpretty.reset()
github papaeye / pytest-httpretty / pytest_httpretty.py View on Github external
def pytest_runtest_setup(item):
    marker = item.get_marker('httpretty')
    if marker is not None:
        httpretty.reset()
        httpretty.enable()
github rosette-api / python / tests / test_rosette_api.py View on Github external
def test_the_language_endpoint(api, json_response, doc_params):
    """Test language 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/language",
                           body=json_response, status=200, content_type="application/json")

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

    result = api.info()
    assert result["name"] == "Rosette"
    httpretty.disable()
    httpretty.reset()
github gabrielfalcao / HTTPretty / tests / unit / test_main.py View on Github external
def test_has_request():
    ("httpretty.has_request() correctly detects "
     "whether or not a request has been made")
    httpretty.reset()
    httpretty.has_request().should.be.false
    with patch('httpretty.httpretty.last_request', return_value=HTTPrettyRequest('')):
        httpretty.has_request().should.be.true
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 rosette-api / python / tests / test_rosette_api.py View on Github external
def test_the_morphology_lemmas_endpoint(api, json_response, doc_params):
    """Test the morphology lemmas 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/lemmas",
                           body=json_response, status=200, content_type="application/json")

    result = api.morphology(doc_params, 'lemmas')
    assert result["name"] == "Rosette"
    httpretty.disable()
    httpretty.reset()