How to use the httpretty.DELETE 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 rapid7 / lecli / tests / test_userapi.py View on Github external
def test_delete_user(mocked_url, mocked_owner_apikey, mocked_owner_apikey_id,
                     mocked_account_resource_id, capsys):
    mocked_owner_apikey.return_value = misc_ex.TEST_OWNER_APIKEY
    mocked_owner_apikey_id.return_value = misc_ex.TEST_OWNER_APIKEY_ID
    mocked_account_resource_id.return_value = misc_ex.TEST_ACCOUNT_RESOURCE_ID
    mocked_url.return_value = misc_ex.MOCK_USERAPI_URL

    dest_url = misc_ex.MOCK_USERAPI_URL + '/' + str(misc_ex.TEST_USER_KEY)
    httpretty.register_uri(httpretty.DELETE, dest_url, status=204)

    api.delete_user(misc_ex.TEST_USER_KEY)

    out, err = capsys.readouterr()
    assert 'Deleted user' in out
github polyaxon / polyaxon / tests / test_api / test_job.py View on Github external
def test_delete_job(self):
        httpretty.register_uri(
            httpretty.DELETE,
            BaseApiHandler.build_url(
                self.api_config.base_url, "/", "username", "project_name", "jobs", 1
            ),
            content_type="application/json",
            status=204,
        )
        result = self.api_handler.delete_job("username", "project_name", 1)
        assert result.status_code == 204

        # Async
        self.assert_async_call(
            api_handler_call=lambda: self.api_handler.delete_job(
                "username", "project_name", 1, background=True
            ),
            method="delete",
        )
github datacenter / pyaci / tests / core-tests.py View on Github external
def testMoXmlDELETE(self):
        httpretty.register_uri(httpretty.DELETE,
                               'http://localhost/api/mo/uni/tn-test.xml')
        self.tree.polUni().fvTenant('test').DELETE(format='xml')
        (httpretty.last_request().method).should.equal('DELETE')
        (httpretty.last_request().path).should.equal('/api/mo/uni/tn-test.xml')
github openstack / keystonemiddleware / v3 / test_roles.py View on Github external
def test_domain_role_revoke(self):
        user_id = uuid.uuid4().hex
        domain_id = uuid.uuid4().hex
        ref = self.new_ref()

        self.stub_url(httpretty.DELETE,
                      ['domains', domain_id, 'users', user_id,
                       self.collection_key, ref['id']],
                      status=204)

        self.manager.revoke(role=ref['id'], domain=domain_id, user=user_id)
github openstack / keystonemiddleware / v2_0 / test_tokens.py View on Github external
def test_delete(self):
        id_ = uuid.uuid4().hex
        self.stub_url(httpretty.DELETE, ['tokens', id_], status=204)
        self.client.tokens.delete(id_)
github inspirehep / inspire-next / inspire / testsuite / test_workflows.py View on Github external
def test_harvesting_workflow_with_match(self):
        """Test an harvesting workflow when the record already exists."""
        from invenio_base.globals import cfg
        from invenio_workflows.api import start

        # Mock Elasticsearch DELETE hook
        httpretty.register_uri(
            httpretty.DELETE,
            re.compile(".*holdingpen-.*/record/(\d+)"),
            status=404
        )

        httpretty.register_uri(
            httpretty.GET,
            cfg['WORKFLOWS_MATCH_REMOTE_SERVER_URL'],
            body='[1212]',
            status=200
        )

        workflow = start('harvesting_fixture',
                         data=[self.record_oai_arxiv_plots],
                         module_name='unit_tests')
        # XXX(jacquerie): find a better check
        self.assertEqual(workflow.objects, [])
github stormpath / stormpath-sdk-python / tests / httprettys / test_account.py View on Github external
httpretty.register_uri(httpretty.GET,
            self.base_href + "/tenants/current",
            location=self.tenant_href,
            status=302)

        httpretty.register_uri(httpretty.GET,
            self.tenant_href,
            body=json.dumps(self.tenant_body),
            content_type="application/json")

        httpretty.register_uri(httpretty.GET,
            self.dir_href,
            body=json.dumps(self.dir_body),
            content_type="application/json")

        httpretty.register_uri(httpretty.DELETE,
            self.acc_href,
            body='', status=204)

        httpretty.register_uri(httpretty.GET,
            self.acc_href,
            body=json.dumps(self.acc_body),
            content_type="application/json")

        directory = self.client.directories.get(self.dir_href)
        account = directory.accounts.get(self.acc_href)
        account.delete()

        self.assertEqual(HTTPretty.last_request.method, 'DELETE')
        self.assertEqual(HTTPretty.last_request.path, self.acc_path)
github rapid7 / lecli / tests / test_log_api.py View on Github external
def test_delete_log(mocked_url, mocked_rw_apikey, capsys):
    mocked_url.return_value = '', MOCK_API_URL
    mocked_rw_apikey.return_value = ID_WITH_VALID_LENGTH

    httpretty.register_uri(httpretty.DELETE, MOCK_API_URL, status=204)
    log_id = str(uuid.uuid4())
    api.delete_log(log_id)

    out, err = capsys.readouterr()
    assert "Deleted log with id: %s" % log_id in out
github rbw / pysnow / tests / test_resource.py View on Github external
def test_delete_chained(self):
        """:meth:`Response.delete` should return a dictionary containing status"""

        httpretty.register_uri(
            httpretty.GET,
            self.mock_url_builder_base,
            body=get_serialized_result(self.record_response_get_one),
            status=200,
            content_type="application/json",
        )

        httpretty.register_uri(
            httpretty.DELETE,
            self.mock_url_builder_sys_id,
            body=get_serialized_result(self.record_response_delete),
            status=204,
            content_type="application/json",
        )

        result = self.resource.get(query={}).delete()

        self.assertEquals(type(result), dict)
        self.assertEquals(result["status"], "record deleted")
github stormpath / stormpath-sdk-python / tests / httprettys / test_application.py View on Github external
httpretty.register_uri(httpretty.GET,
            self.base_href + "/tenants/current",
            location=self.tenant_href,
            status=302)

        httpretty.register_uri(httpretty.GET,
            self.tenant_href,
            body=json.dumps(self.tenant_body),
            content_type="application/json")

        httpretty.register_uri(httpretty.GET,
            self.app_href,
            body=json.dumps(self.app_body),
            content_type="application/json")

        httpretty.register_uri(httpretty.DELETE,
            self.app_href,
            body='', status=204)

        application = self.client.applications.get(self.app_href)
        application.delete()

        self.assertEqual(HTTPretty.last_request.method, 'DELETE')
        self.assertEqual(HTTPretty.last_request.path, self.app_path)