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
=== modified file 'ubuntu_experience_tests/fixture_setup.py'
--- ubuntu_experience_tests/fixture_setup.py 2014-03-10 12:55:24 +0000
+++ ubuntu_experience_tests/fixture_setup.py 2014-05-13 14:37:56 +0000
@@ -20,34 +20,11 @@
20"""Set up and clean up fixtures for the Inter-app integration tests."""20"""Set up and clean up fixtures for the Inter-app integration tests."""
2121
2222
23import fixtures23from ubuntuuitoolkit import fixture_setup as toolkit_fixtures
24import subprocess24
2525
2626class TestabilityEnvironment(toolkit_fixtures.InitctlEnvironmentVariable):
27class TestabilityEnvironment(fixtures.Fixture):27 """Setup the testabilty environment."""
2828
29 def setUp(self):29 def __init__(self):
30 super(TestabilityEnvironment, self).setUp()30 super(TestabilityEnvironment, self).__init__(QT_LOAD_TESTABILITY=1)
31 self._set_testability_environment_variable()
32 self.addCleanup(self._reset_environment_variable)
33
34 def _set_testability_environment_variable(self):
35 """Make sure every app loads the testability driver."""
36 subprocess.call(
37 [
38 '/sbin/initctl',
39 'set-env',
40 '--global',
41 'QT_LOAD_TESTABILITY=1'
42 ]
43 )
44
45 def _reset_environment_variable(self):
46 """Resets the previously added env variable."""
47 subprocess.call(
48 [
49 '/sbin/initctl',
50 'unset-env',
51 'QT_LOAD_TESTABILITY'
52 ]
53 )
5431
=== modified file 'ubuntu_experience_tests/tests/test_fixture_setup.py'
--- ubuntu_experience_tests/tests/test_fixture_setup.py 2014-03-10 12:55:24 +0000
+++ ubuntu_experience_tests/tests/test_fixture_setup.py 2014-05-13 14:37:56 +0000
@@ -17,53 +17,31 @@
17# You should have received a copy of the GNU General Public License17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>18# along with this program. If not, see <http://www.gnu.org/licenses/>
1919
20import subprocess
21
22import testtools20import testtools
2321
22from ubuntuuitoolkit import environment
23
24from ubuntu_experience_tests import fixture_setup24from ubuntu_experience_tests import fixture_setup
2525
2626
27class TestabilityEnvironmentTestCase(testtools.TestCase):27class TestabilityEnvironmentTestCase(testtools.TestCase):
2828
29 def setUp(self):29 def get_testability_environment_variable(self):
30 super(TestabilityEnvironmentTestCase, self).setUp()
31 old_var = self.get_environment_variable()
32 self.addCleanup(self.set_environment_variable, old_var)
33 self.set_environment_variable('dummy')
34
35 def get_environment_variable(self):
36 try:30 try:
37 return subprocess.check_output(31 return environment.get_initctl_env_var('QT_LOAD_TESTABILITY')
38 [
39 'initctl',
40 'get-env',
41 'QT_LOAD_TESTABILITY'
42 ]
43 ).strip()
44 except:32 except:
45 return None33 return None
4634
47 def set_environment_variable(self, value):
48 subprocess.call(
49 [
50 '/sbin/initctl',
51 'set-env',
52 'QT_LOAD_TESTABILITY={}'.format(value)
53 ]
54 )
55
56 def test_fixture_must_setup_testability_environment(self):35 def test_fixture_must_setup_testability_environment(self):
57 """Ensures the environment fixture is setting the environment36 """Test the testability environment fixture is setting the variable."""
58 variable."""
59 fixture = fixture_setup.TestabilityEnvironment()37 fixture = fixture_setup.TestabilityEnvironment()
60 self.useFixture(fixture)38 self.useFixture(fixture)
6139
62 self.assertEquals('1', self.get_environment_variable())40 self.assertEquals('1', self.get_testability_environment_variable())
6341
64 def test_fixture_must_cleanup_testability_environment(self):42 def test_fixture_must_cleanup_testability_environment(self):
65 """Ensures the environment fixture is cleanly removing the previously43 """Test the testability fixture cleans the variable."""
66 set environment variable."""44 original_value = self.get_testability_environment_variable()
67 fixture = fixture_setup.TestabilityEnvironment()45 fixture = fixture_setup.TestabilityEnvironment()
6846
69 def inner_test():47 def inner_test():
@@ -74,4 +52,5 @@
7452
75 inner_test().run()53 inner_test().run()
7654
77 self.assertIsNone(self.get_environment_variable())55 self.assertEqual(
56 original_value, self.get_testability_environment_variable())

Subscribers

People subscribed via source and target branches