on xenial help sign in
test adding the with_lightdm_mock wrapper.
8953889Thomi Richards
tests/autopilot/unity8/shell/tests/helpers.py+14−1
@@ -5,13 +5,26 @@
5# under the terms of the GNU General Public License version 3, as published
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
6# by the Free Software Foundation.
7
7
8−from testtools.matchers import Equals, NotEquals
9from autopilot.matchers import Eventually
8from autopilot.matchers import Eventually
9+from testtools.matchers import Equals, NotEquals
10+from functools import wraps
10
11
11import logging
12import logging
12
13
13logger = logging.getLogger(__name__)
14logger = logging.getLogger(__name__)
14
15
16+
17+def with_lightdm_mock(fn, mock_type):
18+ """A simple decorator that sets up the LightDM mock for a single test."""
19+ @wraps(fn)
20+ def wrapper(*args, **kwargs):
21+ logger.info("Setting up LightDM mock type '%s'", mock_type)
22+ return fn(*args, **kwargs)
23+ return wrapper
24+
25+
26+# TODO: Mixing classes like these are ikky. Remove them, and replace with
27+# something better!
15class TestShellHelpers(object):
28class TestShellHelpers(object):
16 """Helpers for testing the Shell"""
29 """Helpers for testing the Shell"""
17
30
tests/autopilot/unity8/shell/tests/test_lock_screen.py+2−1
@@ -26,7 +26,7 @@
26from __future__ import absolute_import
26from __future__ import absolute_import
27
27
28from unity8.shell.tests import Unity8TestCase
28from unity8.shell.tests import Unity8TestCase
29−from unity8.shell.tests.helpers import TestShellHelpers
29+from unity8.shell.tests.helpers import with_lightdm_mock
30
30
31from autopilot.input import Mouse, Touch, Pointer
31from autopilot.input import Mouse, Touch, Pointer
32from testtools.matchers import Equals, NotEquals, GreaterThan, MismatchError
32from testtools.matchers import Equals, NotEquals, GreaterThan, MismatchError
@@ -62,6 +62,7 @@ class TestLockscreen(Unity8TestCase):
62 # dash = self.main_window.get_dash()
62 # dash = self.main_window.get_dash()
63 # self.assertThat(dash.showScopeOnLoaded, Eventually(Equals(""), timeout=30))
63 # self.assertThat(dash.showScopeOnLoaded, Eventually(Equals(""), timeout=30))
64
64
65+ @with_lightdm_mock("single_pin")
65 def test_can_unlock_screen(self):
66 def test_can_unlock_screen(self):
66 """Must be able to unlock the screen."""
67 """Must be able to unlock the screen."""
67 self.lightdm_mock = "single_pin"
68 self.lightdm_mock = "single_pin"