def test_invalid_instance_id(self, mock_get_image, mock_get_instance):
"""Mock the instance to not exist so there is nothing to enroll."""
mock_get_image.return_value = FakeImageService()
mock_get_instance.return_value = None
body = {"metadata": {"ipa_enroll": "True"},
"instance-id": "invalid",
"project-id": fake.PROJECT_ID,
"image-id": fake.IMAGE_ID,
"hostname": "test"}
req = fakes.HTTPRequest.blank('/v1')
req.method = 'POST'
req.content_type = "application/json"
req.body = jsonutils.dump_as_bytes(body)
# Not using assertRaises because the exception is wrapped as
# a Fault
try:
self.join_controller.create(req, body)
except Fault as fault:
assert fault.status_int == 400
else:
assert(False)
评论列表
文章目录