def test_remove_ticket(self): imagetickets.remove_ticket("uuid") expected = [ ("request", ("DELETE", "/tickets/uuid"), {"body": None}), ] self.assertEqual(imagetickets.uhttp.__calls__, expected) self.assertTrue(imagetickets.uhttp.closed)
def test_res_read_error(self): imagetickets.uhttp.response.status = 300 err_msg = "Environment error message" def read(amt=None): raise EnvironmentError(err_msg) imagetickets.uhttp.response.read = read try: imagetickets.remove_ticket("uuid") except se.ImageDaemonError as e: self.assertTrue(err_msg in e.value)
def test_image_daemon_error_ret(self): imagetickets.uhttp.response = FakeResponse( status=300, data=u'{"image_daemon_message":"content"}') try: imagetickets.remove_ticket("uuid") except se.ImageDaemonError as e: self.assertTrue("image_daemon_message=content" in e.value)
def test_res_invalid_json_ret(self): imagetickets.uhttp.response = FakeResponse( status=300, data=u"not a json string") with self.assertRaises(se.ImageDaemonError): imagetickets.remove_ticket("uuid")
def test_res_header_error(self): imagetickets.uhttp.response = FakeResponse( status=300, headers={"content-length": "invalid"}) with self.assertRaises(se.ImageDaemonError): imagetickets.remove_ticket("uuid")
def test_remove_ticket(self): imagetickets.remove_ticket("uuid") expected = [ ("request", ("DELETE", "/tickets/uuid"), { "body": None }), ] self.assertEqual(imagetickets.uhttp.__calls__, expected) self.assertTrue(imagetickets.uhttp.closed)
def test_res_invalid_json_ret(self): imagetickets.uhttp.response = FakeResponse(status=300, data=u"not a json string") with self.assertRaises(se.ImageDaemonError): imagetickets.remove_ticket("uuid")