Merge lp:~elopio/ubuntu-autopilot-tests/initctl_env_from_toolkit into lp:ubuntu-autopilot-tests/ubuntu-experience-tests

Proposed by Leo Arias
Status: Merged
Merged at revision: 16
Proposed branch: lp:~elopio/ubuntu-autopilot-tests/initctl_env_from_toolkit
Merge into: lp:ubuntu-autopilot-tests/ubuntu-experience-tests
Diff against target: 119 lines (+18/-62)
2 files modified
ubuntu_experience_tests/fixture_setup.py (+8/-31)
ubuntu_experience_tests/tests/test_fixture_setup.py (+10/-31)
To merge this branch: bzr merge lp:~elopio/ubuntu-autopilot-tests/initctl_env_from_toolkit
Reviewer Review Type Date Requested Status
Richard Huddie (community) Approve
Ubuntu Testcase Admins Pending
Review via email: mp+219384@code.launchpad.net

Commit message

Update the environment to use the helpers from the toolkit.

To post a comment you must log in.
17. By Leo Arias

fixed flake8.

18. By Leo Arias

Take into account that the env var might not be set.

19. By Leo Arias

Typo.

Revision history for this message
Richard Huddie (rhuddie) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_experience_tests/fixture_setup.py'
2--- ubuntu_experience_tests/fixture_setup.py 2014-03-10 12:55:24 +0000
3+++ ubuntu_experience_tests/fixture_setup.py 2014-05-13 14:37:56 +0000
4@@ -20,34 +20,11 @@
5 """Set up and clean up fixtures for the Inter-app integration tests."""
6
7
8-import fixtures
9-import subprocess
10-
11-
12-class TestabilityEnvironment(fixtures.Fixture):
13-
14- def setUp(self):
15- super(TestabilityEnvironment, self).setUp()
16- self._set_testability_environment_variable()
17- self.addCleanup(self._reset_environment_variable)
18-
19- def _set_testability_environment_variable(self):
20- """Make sure every app loads the testability driver."""
21- subprocess.call(
22- [
23- '/sbin/initctl',
24- 'set-env',
25- '--global',
26- 'QT_LOAD_TESTABILITY=1'
27- ]
28- )
29-
30- def _reset_environment_variable(self):
31- """Resets the previously added env variable."""
32- subprocess.call(
33- [
34- '/sbin/initctl',
35- 'unset-env',
36- 'QT_LOAD_TESTABILITY'
37- ]
38- )
39+from ubuntuuitoolkit import fixture_setup as toolkit_fixtures
40+
41+
42+class TestabilityEnvironment(toolkit_fixtures.InitctlEnvironmentVariable):
43+ """Setup the testabilty environment."""
44+
45+ def __init__(self):
46+ super(TestabilityEnvironment, self).__init__(QT_LOAD_TESTABILITY=1)
47
48=== modified file 'ubuntu_experience_tests/tests/test_fixture_setup.py'
49--- ubuntu_experience_tests/tests/test_fixture_setup.py 2014-03-10 12:55:24 +0000
50+++ ubuntu_experience_tests/tests/test_fixture_setup.py 2014-05-13 14:37:56 +0000
51@@ -17,53 +17,31 @@
52 # You should have received a copy of the GNU General Public License
53 # along with this program. If not, see <http://www.gnu.org/licenses/>
54
55-import subprocess
56-
57 import testtools
58
59+from ubuntuuitoolkit import environment
60+
61 from ubuntu_experience_tests import fixture_setup
62
63
64 class TestabilityEnvironmentTestCase(testtools.TestCase):
65
66- def setUp(self):
67- super(TestabilityEnvironmentTestCase, self).setUp()
68- old_var = self.get_environment_variable()
69- self.addCleanup(self.set_environment_variable, old_var)
70- self.set_environment_variable('dummy')
71-
72- def get_environment_variable(self):
73+ def get_testability_environment_variable(self):
74 try:
75- return subprocess.check_output(
76- [
77- 'initctl',
78- 'get-env',
79- 'QT_LOAD_TESTABILITY'
80- ]
81- ).strip()
82+ return environment.get_initctl_env_var('QT_LOAD_TESTABILITY')
83 except:
84 return None
85
86- def set_environment_variable(self, value):
87- subprocess.call(
88- [
89- '/sbin/initctl',
90- 'set-env',
91- 'QT_LOAD_TESTABILITY={}'.format(value)
92- ]
93- )
94-
95 def test_fixture_must_setup_testability_environment(self):
96- """Ensures the environment fixture is setting the environment
97- variable."""
98+ """Test the testability environment fixture is setting the variable."""
99 fixture = fixture_setup.TestabilityEnvironment()
100 self.useFixture(fixture)
101
102- self.assertEquals('1', self.get_environment_variable())
103+ self.assertEquals('1', self.get_testability_environment_variable())
104
105 def test_fixture_must_cleanup_testability_environment(self):
106- """Ensures the environment fixture is cleanly removing the previously
107- set environment variable."""
108+ """Test the testability fixture cleans the variable."""
109+ original_value = self.get_testability_environment_variable()
110 fixture = fixture_setup.TestabilityEnvironment()
111
112 def inner_test():
113@@ -74,4 +52,5 @@
114
115 inner_test().run()
116
117- self.assertIsNone(self.get_environment_variable())
118+ self.assertEqual(
119+ original_value, self.get_testability_environment_variable())

Subscribers

People subscribed via source and target branches