本文整理汇总了Python中responses.DELETE属性的典型用法代码示例。如果您正苦于以下问题:Python responses.DELETE属性的具体用法?Python responses.DELETE怎么用?Python responses.DELETE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类responses
的用法示例。
在下文中一共展示了responses.DELETE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_policy
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_delete_policy(nomad_setup):
responses.add(
responses.DELETE,
"http://{ip}:{port}/v1/sentinel/policy/my-policy".format(ip=common.IP, port=common.NOMAD_PORT),
status=200,
json={
"Name": "foo",
"Description": "test policy",
"Scope": "submit-job",
"EnforcementLevel": "advisory",
"Policy": "main = rule { true }\n",
"Hash": "CIs8aNX5OfFvo4D7ihWcQSexEJpHp+Za+dHSncVx5+8=",
"CreateIndex": 8,
"ModifyIndex": 8
}
)
nomad_setup.sentinel.delete_policy(id="my-policy")
示例2: test_cli_dataset_delete_dataset
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_cli_dataset_delete_dataset():
id = "cii9dtexw0039uelz7nzk1lq3"
responses.add(
responses.DELETE,
'https://api.mapbox.com/datasets/v1/{0}/{1}?access_token={2}'.format(username, id, access_token),
match_querystring=True,
status=204
)
runner = CliRunner()
result = runner.invoke(
main_group,
['--access-token', access_token,
'datasets',
'delete-dataset', id])
assert result.exit_code == 0
示例3: test_cli_dataset_delete_feature
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_cli_dataset_delete_feature():
dataset = "dataset-2"
id = "abc"
responses.add(
responses.DELETE,
'https://api.mapbox.com/datasets/v1/{0}/{1}/features/{2}?access_token={3}'.format(username, dataset, id, access_token),
match_querystring=True,
status=204
)
runner = CliRunner()
result = runner.invoke(
main_group,
['--access-token', access_token,
'datasets',
'delete-feature', dataset, id])
assert result.exit_code == 0
示例4: test_disable_monitoring_monitors_not_found
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_disable_monitoring_monitors_not_found(self, mock_consul):
"""
Test that the `disable_monitoring` method removes any New Relic
Synthetics monitors for this instance, even if the actual monitors no longer exist.
"""
monitor_ids = [str(uuid4()) for i in range(3)]
instance = OpenEdXInstanceFactory()
for monitor_id in monitor_ids:
instance.new_relic_availability_monitors.create(pk=monitor_id)
responses.add(
responses.DELETE,
'{0}/monitors/{1}'.format(newrelic.SYNTHETICS_API_URL, monitor_id),
status=requests.codes.not_found
)
# Precondition
self.assertEqual(instance.new_relic_availability_monitors.count(), 3)
# Disable monitoring
instance.disable_monitoring()
# Instance should no longer have any monitors associated with it
self.assertEqual(instance.new_relic_availability_monitors.count(), 0)
示例5: test_reset_stream_key
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_reset_stream_key():
channel_id = example_channel["_id"]
responses.add(
responses.DELETE,
"{}channels/{}/stream_key".format(BASE_URL, channel_id),
body=json.dumps(example_channel),
status=200,
content_type="application/json",
)
client = TwitchClient("client id", "oauth token")
channel = client.channels.reset_stream_key(channel_id)
assert len(responses.calls) == 1
assert isinstance(channel, Channel)
assert channel.id == example_channel["_id"]
assert channel.name == example_channel["name"]
示例6: test_delete_post
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_delete_post():
channel_id = "1234"
post_id = example_post["id"]
responses.add(
responses.DELETE,
"{}feed/{}/posts/{}".format(BASE_URL, channel_id, post_id),
body=json.dumps(example_post),
status=200,
content_type="application/json",
)
client = TwitchClient("client id", "oauth token")
post = client.channel_feed.delete_post(channel_id, post_id)
assert len(responses.calls) == 1
assert isinstance(post, Post)
assert post.id == example_post["id"]
示例7: test_delete_reaction_to_post
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_delete_reaction_to_post():
channel_id = "1234"
post_id = example_post["id"]
body = {"deleted": True}
responses.add(
responses.DELETE,
"{}feed/{}/posts/{}/reactions".format(BASE_URL, channel_id, post_id),
body=json.dumps(body),
status=200,
content_type="application/json",
)
client = TwitchClient("client id", "oauth token")
response = client.channel_feed.delete_reaction_to_post(channel_id, post_id, "1234")
assert len(responses.calls) == 1
assert response["deleted"]
示例8: test_delete_post_comment
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
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"]
示例9: test_unblock_user
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_unblock_user():
user_id = 1234
blocked_user_id = 12345
responses.add(
responses.DELETE,
"{}users/{}/blocks/{}".format(BASE_URL, user_id, blocked_user_id),
body=json.dumps(example_block),
status=200,
content_type="application/json",
)
client = TwitchClient("client id", "oauth token")
client.users.unblock_user(user_id, blocked_user_id)
assert len(responses.calls) == 1
示例10: test_oauth_response_missing_keys
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_oauth_response_missing_keys(self):
"""
A ``requests.RequestException`` is raised when the call for an OAuth2 access token returns no data.
"""
responses.add(
responses.POST,
self.oauth_url,
json={},
status=200
)
responses.add(
responses.DELETE,
self.course_url,
json={},
status=200
)
degreed_api_client = DegreedAPIClient(self.enterprise_config)
with pytest.raises(ClientError):
degreed_api_client.delete_content_metadata({})
示例11: test_unlink_rich_menu_from_user
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_unlink_rich_menu_from_user(self):
responses.add(
responses.DELETE,
LineBotApi.DEFAULT_API_ENDPOINT +
'/v2/bot/user/user_id/richmenu',
json={}, status=200
)
self.tested.unlink_rich_menu_from_user('user_id')
request = responses.calls[0].request
self.assertEqual(request.method, 'DELETE')
self.assertEqual(
request.url,
LineBotApi.DEFAULT_API_ENDPOINT + '/v2/bot/user/user_id/richmenu'
)
示例12: test_cancel_default_rich_menu
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_cancel_default_rich_menu(self):
responses.add(
responses.DELETE,
LineBotApi.DEFAULT_API_ENDPOINT +
'/v2/bot/user/all/richmenu',
json={}, status=200
)
self.tested.cancel_default_rich_menu()
request = responses.calls[0].request
self.assertEqual(request.method, 'DELETE')
self.assertEqual(
request.url,
LineBotApi.DEFAULT_API_ENDPOINT + '/v2/bot/user/all/richmenu'
)
示例13: test_delete_namespace
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_delete_namespace(nomad_setup):
responses.add(
responses.DELETE,
"http://{ip}:{port}/v1/namespace/api".format(ip=common.IP, port=common.NOMAD_PORT),
status=200,
)
nomad_setup.namespace.delete_namespace("api")
######### ENTERPRISE TEST ###########
# def test_apply_namespace(nomad_setup):
# namespace_api='{"Name":"api","Description":"api server namespace"}'
# namespace = json.loads(namespace_api)
# nomad_setup.namespace.apply_namespace("api", namespace)
# assert "api" in nomad_setup.namespace
#
# def test_get_namespace(nomad_setup):
# assert "api" in nomad_setup.namespace.get_namespace("api")["Name"]
#
# def test_delete_namespace(nomad_setup):
# nomad_setup.namespace.delete_namespace("api")
# try:
# assert "api" != nomad_setup.namespace.get_namespace("api")["Name"]
# except nomad.api.exceptions.URLNotFoundNomadException:
# pass
示例14: test_delete_synthetics_monitor
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_delete_synthetics_monitor(self):
"""
Check that the delete_synthetics_monitor function deletes the monitor
with the given id.
"""
monitor_id = '3e442fa8-ec6c-4bf7-94ac-a0eccb817587'
responses.add(responses.DELETE,
'{0}/monitors/{1}'.format(newrelic.SYNTHETICS_API_URL,
monitor_id),
status=204)
newrelic.delete_synthetics_monitor(monitor_id)
self.assertEqual(len(responses.calls), 1)
request_headers = responses.calls[0].request.headers
self.assertEqual(request_headers['x-api-key'], 'admin-api-key')
示例15: test_delete_synthetics_monitor_exceptions
# 需要导入模块: import responses [as 别名]
# 或者: from responses import DELETE [as 别名]
def test_delete_synthetics_monitor_exceptions(self):
"""
Check that the delete_synthetics_monitor function behaves correctly if DELETE request unsuccessful.
We expect the function *not* to raise an exception if the monitor to delete
can not be found (i.e., if the DELETE request comes back with a 404).
In all other cases the function should raise an exception.
"""
monitor_id = '2085b3d6-3689-4847-97cc-f7c91d86cd1d'
client_errors = [status_code for status_code in requests.status_codes._codes if 400 <= status_code < 500]
server_errors = [status_code for status_code in requests.status_codes._codes if 500 <= status_code < 600]
for error in client_errors + server_errors:
with responses.RequestsMock() as mock_responses:
mock_responses.add(responses.DELETE,
'{0}/monitors/{1}'.format(newrelic.SYNTHETICS_API_URL,
monitor_id),
status=error)
try:
newrelic.delete_synthetics_monitor(monitor_id)
except requests.exceptions.HTTPError:
if error == requests.codes.not_found:
self.fail('Should not raise an exception for {} response.'.format(error))
else:
if not error == requests.codes.not_found:
self.fail('Should raise an exception for {} response.'.format(error))