From 6f61691980fe11e2eb9c2b56b1acf16a2ceabce3 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Wed, 7 Dec 2016 18:34:58 -0200 Subject: [#801] Mocked event server on resource unit test The resource unit test was breaking because the RootResource initialize calls an event register (and the event queue is not initialized on unit tests). We mocked the registering of events so the unit tests don't try to touch the event queue at all. --- service/test/unit/resources/test_signup_resource.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'service/test/unit/resources') diff --git a/service/test/unit/resources/test_signup_resource.py b/service/test/unit/resources/test_signup_resource.py index 49a7ee41..2f2d2860 100644 --- a/service/test/unit/resources/test_signup_resource.py +++ b/service/test/unit/resources/test_signup_resource.py @@ -20,6 +20,7 @@ from twisted.trial import unittest from twisted.web.resource import getChildForRequest from twisted.web.test.requesthelper import DummyRequest +import leap.common.events from pixelated.application import get_static_folder from pixelated.resources.root_resource import RootResource from pixelated.resources.signup_resource import SignupResource @@ -27,6 +28,12 @@ from pixelated.resources.signup_resource import SignupResource class TestSignupResource(unittest.TestCase): + def setUp(self): + leap.common.events.register = MagicMock + + def tearDown(self): + reload(leap.common.events) + def test_get_resource_for_request(self): public_root_resource = RootResource(mock(), get_static_folder(), public=True) request = DummyRequest(['signup']) -- cgit v1.2.3