def test_api_key_rejects_deletion_of_nonexistent_key(self):
stderr = StringIO()
user = factory.make_User()
existing_token = get_one(
user.userprofile.get_authorisation_tokens())
token_string = convert_tuple_to_string(
get_creds_tuple(existing_token))
call_command(
'apikey', username=user.username, delete=token_string,
stderr=stderr)
self.assertThat(stderr, IsEmpty)
# Delete it again. Check that there's a sensible rejection.
error_text = assertCommandErrors(
self, 'apikey', username=user.username, delete=token_string)
self.assertIn(
"No matching api key found", error_text)
评论列表
文章目录