def test_image_daemon_error_ret(self): imagetickets.uhttp.response = FakeResponse( status=300, data=b'{"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_header_error(fake_connection): fake_response = FakeResponse(status=300) fake_response.headers["content-length"] = "invalid" fake_connection.response = fake_response with pytest.raises(se.ImageDaemonError): imagetickets.remove_ticket("uuid")
def test_image_daemon_error_ret(self): imagetickets.UnixHTTPConnection.response = FakeResponse( status=300, data=b'{"image_daemon_message":"content"}') try: imagetickets.remove_ticket("uuid") except se.ImageDaemonError as e: self.assertTrue(six.text_type("image_daemon_message") in e.value) self.assertTrue(six.text_type("content") in e.value)
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_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_remove_ticket(fake_connection): fake_connection.response = FakeResponse(status=204, reason="No Content") imagetickets.remove_ticket("uuid") expected = [ ("request", ("DELETE", "/tickets/uuid"), { "body": None }), ] assert fake_connection.__calls__ == expected assert fake_connection.closed
def test_remove_ticket_with_content_length(self): # Legacy imageio daemon used to return "Content-Length: 0". This is not # correct according to RFC 7230, but we must support it. imagetickets.uhttp.response = FakeResponse( status=204, reason="No Content") imagetickets.remove_ticket("uuid") expected = [ ("request", ("DELETE", "/tickets/uuid"), {"body": None}), ] self.assertEqual(imagetickets.uhttp.__calls__, expected) self.assertTrue(imagetickets.uhttp.closed)
def test_remove_ticket(self): # New imageio daemon will not return Content-Length header, as # specified in RFC 7230. imagetickets.uhttp.response = FakeResponse( status=204, reason="No Content", headers={}) imagetickets.remove_ticket("uuid") expected = [ ("request", ("DELETE", "/tickets/uuid"), {"body": None}), ] self.assertEqual(imagetickets.uhttp.__calls__, expected) self.assertTrue(imagetickets.uhttp.closed)
def test_remove_ticket(self): # New imageio daemon will not return Content-Length header, as # specified in RFC 7230. imagetickets.UnixHTTPConnection.response = FakeResponse( status=204, reason="No Content", headers={}) imagetickets.remove_ticket("uuid") expected = [ ("request", ("DELETE", "/tickets/uuid"), {"body": None}), ] self.assertEqual(imagetickets.UnixHTTPConnection.__calls__, expected) self.assertTrue(imagetickets.UnixHTTPConnection.closed)
def test_res_read_error(fake_connection): fake_connection.response = FakeResponse(status=300) err_msg = "Environment error message" def read(amt=None): raise EnvironmentError(err_msg) fake_connection.response.read = read with pytest.raises(se.ImageDaemonError) as e: imagetickets.remove_ticket("uuid") assert err_msg in e.value
def test_remove_ticket_with_content_length(self): # Legacy imageio daemon used to return "Content-Length: 0". This is not # correct according to RFC 7230, but we must support it. imagetickets.UnixHTTPConnection.response = FakeResponse( status=204, reason="No Content") imagetickets.remove_ticket("uuid") expected = [ ("request", ("DELETE", "/tickets/uuid"), {"body": None}), ] self.assertEqual(imagetickets.UnixHTTPConnection.__calls__, expected) self.assertTrue(imagetickets.UnixHTTPConnection.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_res_read_error(self): imagetickets.UnixHTTPConnection.response = FakeResponse( status=300, data=b'{"image_daemon_message":"ignored"}') err_msg = "Environment error message" def read(amt=None): raise EnvironmentError(err_msg) imagetickets.UnixHTTPConnection.response.read = read try: imagetickets.remove_ticket("uuid") except se.ImageDaemonError as e: self.assertTrue(err_msg in e.value)
def test_res_read_error(self): imagetickets.uhttp.response = FakeResponse( status=300, data=b'{"image_daemon_message":"ignored"}') 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_remove_ticket_error(fake_connection): fake_connection.response = FakeResponse(status=409, data=b'Conflict') with pytest.raises(se.ImageDaemonError) as e: imagetickets.remove_ticket("uuid") assert "Conflict" in str(e.value)
def test_res_header_error(self): imagetickets.UnixHTTPConnection.response = FakeResponse( status=300, headers={"content-length": "invalid"}) with self.assertRaises(se.ImageDaemonError): imagetickets.remove_ticket("uuid")
def test_res_invalid_json_ret(self): imagetickets.UnixHTTPConnection.response = FakeResponse( status=300, data=b"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_res_invalid_json_ret(self): imagetickets.uhttp.response = FakeResponse( status=300, data=b"not a json string") with self.assertRaises(se.ImageDaemonError): imagetickets.remove_ticket("uuid")