How to use the responses.DELETE function in responses

To help you get started, we’ve selected a few responses 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 tsifrer / python-twitch-client / tests / api / test_collections.py View on Github external
def test_delete_item():
    collection_id = 'abcd'
    collection_item_id = '1234'
    responses.add(responses.DELETE,
                  '{}collections/{}/items/{}'.format(BASE_URL, collection_id, collection_item_id),
                  status=204,
                  content_type='application/json')

    client = TwitchClient('client id', 'oauth client')

    client.collections.delete_item(collection_id, collection_item_id)

    assert len(responses.calls) == 1
github pythonanywhere / helper_scripts / tests / test_api_schedule.py View on Github external
def test_deletes_task(self, api_token, api_responses, task_base_url):
        url = task_base_url + "42/"
        api_responses.add(responses.DELETE, url=url, status=204)

        result = Schedule().delete(42)

        post = api_responses.calls[0]
        assert post.request.url == url
        assert post.request.body is None
        assert result is True
github SAPConversationalAI / SDK-python / tests / recastai / apis / request / models / test_conversation.py View on Github external
def test_bad_request(self):
    body = json.dumps({'results': None, 'message': 'Request is invalid'})
    responses.add(responses.PUT, 'https://api.recast.ai/v2/converse', body=body, status=400)
    responses.add(responses.DELETE, 'https://api.recast.ai/v2/converse', body=body, status=400)

    with pytest.raises(RecastError):
      Conversation.set_memory('testtoken', 'testconversationtoken', {'location': {'raw': 'Paris'}})

    with pytest.raises(RecastError):
      Conversation.reset_memory('testtoken', 'testconversationtoken', 'location')

    with pytest.raises(RecastError):
      Conversation.reset_memory('testtoken', 'testconversationtoken')

    with pytest.raises(RecastError):
      Conversation.reset_conversation('testtoken', 'testconversationtoken')
github Datatamer / tamr-client / tests / unit / test_attribute_configuration_collection.py View on Github external
def test_delete_by_resource_id(self):
        attr_config_url = self._base + "projects/1/attributeConfigurations/20"

        responses.add(responses.GET, self.mastering_project, json=self.project_json)
        responses.add(responses.DELETE, attr_config_url, status=204)

        attr_config_collection = self.tamr.projects.by_resource_id(
            "1"
        ).attribute_configurations()
        response = attr_config_collection.delete_by_resource_id("20")
        self.assertEqual(response.status_code, 204)
github wuxi-nextcode / nextcode-python-sdk / tests / test_keycloak.py View on Github external
with responses.RequestsMock() as rsps:
            rsps.add(
                responses.GET,
                f"https://{ROOT_URL}/auth/admin/realms/{DEFAULT_REALM}/users",
                json.dumps(users_response),
            )
            session.get_users()

        with responses.RequestsMock() as rsps:
            rsps.add(
                responses.GET,
                f"https://{ROOT_URL}/auth/admin/realms/{DEFAULT_REALM}/users",
                json.dumps(users_response),
            )
            rsps.add(
                responses.DELETE,
                f"https://{ROOT_URL}/auth/admin/realms/{DEFAULT_REALM}/users/{user_id}",
                json.dumps(users_response),
            )
            session.remove_user(user_name)

        with responses.RequestsMock() as rsps:
            roles_response = {"realmMappings": [{"name": "bla"}]}
            rsps.add(
                responses.GET,
                f"https://{ROOT_URL}/auth/admin/realms/{DEFAULT_REALM}/users?username={user_name}",
                json.dumps(users_response),
            )
            rsps.add(
                responses.GET,
                f"https://{ROOT_URL}/auth/admin/realms/{DEFAULT_REALM}/users/{user_id}/role-mappings",
                json.dumps(roles_response),
github mapbox / mapbox-sdk-py / tests / test_tokens.py View on Github external
def test_delete():
    """Token authorization deletion works"""
    responses.add(
        responses.DELETE,
        'https://api.mapbox.com/tokens/v2/testuser/auth_id?access_token={0}'.format(token),
        match_querystring=True,
        status=204)

    response = Tokens(access_token=token).delete('auth_id')
    assert response.status_code == 204
github pythonanywhere / helper_scripts / tests / test_api_webapp.py View on Github external
def test_raises_if_delete_does_not_20x(self, api_responses, api_token):
        expected_url = (
            get_api_endpoint().format(username=getpass.getuser(), flavor="files")
            + "path/var/log/mydomain.com.access.log/"
        )
        api_responses.add(responses.DELETE, expected_url, status=404, body="nope")

        with pytest.raises(Exception) as e:
            Webapp("mydomain.com").delete_log(log_type="access")

        assert "DELETE log file via API failed" in str(e.value)
        assert "nope" in str(e.value)
github pyapi-gitlab / pyapi-gitlab / gitlab_tests / test_v91 / test_common.py View on Github external
def test_delete(self):
        responses.add(
            responses.DELETE,
            self.gitlab.api_url + '/users/5',
            json=None,
            status=204,
            content_type='application/json')

        self.assertEqual({}, self.gitlab.delete('/users/5'))
        self.assertEqual({}, self.gitlab.delete('/users/5', default_response={}))
github watson-developer-cloud / python-sdk / test / unit / test_conversation_v1.py View on Github external
def test_delete_entity():
    endpoint = '/v1/workspaces/{0}/entities/{1}'.format('boguswid', 'pizza_toppings')
    url = '{0}{1}'.format(base_url, endpoint)
    response = None
    responses.add(
        responses.DELETE,
        url,
        body=json.dumps(response),
        status=204,
        content_type='application/json')
    service = watson_developer_cloud.ConversationV1(
        username='username', password='password', version='2017-04-21')
    entity = service.delete_entity(workspace_id='boguswid', entity='pizza_toppings').get_result()
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(url)
    assert entity is None
github tsifrer / python-twitch-client / tests / api / test_channel_feed.py View on Github external
def test_delete_post_comment():
    channel_id = '1234'
    post_id = example_post['id']
    comment_id = example_comment['id']
    responses.add(
        responses.DELETE,
        '{}feed/{}/posts/{}/comments/{}'.format(BASE_URL, channel_id, post_id, comment_id),
        body=json.dumps(example_comment),
        status=200,
        content_type='application/json'
    )

    client = TwitchClient('client id', 'oauth token')

    comment = client.channel_feed.delete_post_comment(channel_id, post_id, comment_id)

    assert len(responses.calls) == 1
    assert isinstance(comment, Comment)
    assert comment.id == example_comment['id']