def test_extend_ticket(self): timeout = 300 imagetickets.extend_ticket("uuid", timeout) expected = [ ("request", ("PATCH", "/tickets/uuid"), {"body": '{"timeout": ' + str(timeout) + '}'}), ] self.assertEqual(imagetickets.uhttp.__calls__, expected) self.assertTrue(imagetickets.uhttp.closed)
def test_extend_ticket(self): timeout = 300 imagetickets.extend_ticket("uuid", timeout) body = '{"timeout": ' + str(timeout) + '}' expected = [ ("request", ("PATCH", "/tickets/uuid"), {"body": body.encode("utf8")}), ] self.assertEqual(imagetickets.UnixHTTPConnection.__calls__, expected) self.assertTrue(imagetickets.UnixHTTPConnection.closed)
def test_extend_ticket(self): timeout = 300 imagetickets.extend_ticket("uuid", timeout) expected = [ ("request", ("PATCH", "/tickets/uuid"), { "body": '{"timeout": ' + str(timeout) + '}' }), ] self.assertEqual(imagetickets.uhttp.__calls__, expected) self.assertTrue(imagetickets.uhttp.closed)
def test_extend_ticket(fake_connection): timeout = 300 imagetickets.extend_ticket("uuid", timeout) body = '{"timeout": ' + str(timeout) + '}' expected = [ ("request", ("PATCH", "/tickets/uuid"), { "body": body.encode("utf8") }), ] assert fake_connection.__calls__ == expected assert fake_connection.closed
def test_extend_ticket_error(fake_connection): fake_connection.response = FakeResponse(status=404, data=b'Not found') with pytest.raises(se.ImageDaemonError) as e: imagetickets.extend_ticket("uuid", 1) assert "Not found" in str(e.value)