Change in vdsm[master]: imagetickets: Add tests.
aaviram at redhat.com
aaviram at redhat.com
Wed Feb 10 10:08:38 UTC 2016
Amit Aviram has uploaded a new change for review.
Change subject: imagetickets: Add tests.
......................................................................
imagetickets: Add tests.
Change-Id: Ia1d414c96c06484365911804e438845dfe17cbb1
Signed-off-by: Amit Aviram <aaviram at redhat.com>
---
M tests/imagetickets_test.py
1 file changed, 45 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/53331/1
diff --git a/tests/imagetickets_test.py b/tests/imagetickets_test.py
index 556ac63..b32d144 100644
--- a/tests/imagetickets_test.py
+++ b/tests/imagetickets_test.py
@@ -62,6 +62,12 @@
self.status = 200
self.reason = "OK"
+ def getheader(*args, **kwargs):
+ return 0
+
+ def read (*args, **kwargs):
+ return "{}"
+
@expandPermutations
class TestImageTickets(VdsmTestCase):
@@ -73,7 +79,7 @@
["remove_ticket", ["uuid"]],
])
def test_not_supported(self, method, args):
- with self.assertRaises(se.ImageDeamonUnsupported):
+ with self.assertRaises(se.ImageDaemonUnsupported):
func = getattr(imagetickets, method)
func(*args)
@@ -91,6 +97,44 @@
@MonkeyPatch(imagetickets, '_have_image_daemon', True)
@MonkeyPatch(imagetickets, 'uhttp', FakeUHTTP())
+ def test_extend_ticket(self):
+ timeout = 300
+ imagetickets.extend_ticket("uuid", timeout)
+ expected = [
+ ("request", ("PATCH", "/tickets/uuid"), {"timeout": timeout}),
+ ]
+
+ self.assertTrue(imagetickets.uhttp.__calls__, expected)
+ self.assertTrue(imagetickets.uhttp.closed)
+
+ @MonkeyPatch(imagetickets, '_have_image_daemon', True)
+ @MonkeyPatch(imagetickets, 'uhttp', FakeUHTTP())
+ def test_remove_ticket(self):
+ imagetickets.remove_ticket("uuid")
+ expected = [
+ ("request", ("PATCH", "/tickets/uuid"), None),
+ ]
+
+ self.assertTrue(imagetickets.uhttp.__calls__, expected)
+ self.assertTrue(imagetickets.uhttp.closed)
+
+
+ @MonkeyPatch(imagetickets, '_have_image_daemon', True)
+ @MonkeyPatch(imagetickets, 'uhttp', FakeUHTTP())
+ @permutations([
+ ["getheader", lambda *args, **kwargs: "string"],
+ ["read", lambda *args, **kwargs: (_ for _ in ()).throw(EnvironmentError)],
+ ["read", lambda *args, **kwargs: "not json"],
+ ])
+ def test_image_daemon_error(self, func_name, fake_impl):
+ imagetickets.uhttp.response.status = 300
+ setattr(imagetickets.uhttp.response, func_name, fake_impl)
+ with self.assertRaises(se.ImageDaemonError):
+ imagetickets.remove_ticket("uuid")
+
+
+ @MonkeyPatch(imagetickets, '_have_image_daemon', True)
+ @MonkeyPatch(imagetickets, 'uhttp', FakeUHTTP())
@permutations([[httplib.HTTPException], [socket.error], [OSError]])
def test_image_tickets_error(self, exc_type):
ticket = create_ticket(uuid="uuid")
--
To view, visit https://gerrit.ovirt.org/53331
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia1d414c96c06484365911804e438845dfe17cbb1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Amit Aviram <aaviram at redhat.com>
More information about the vdsm-patches
mailing list