Merge lp:~milo/lava-tool/unittest-fix into lp:~linaro-validation/lava-tool/trunk

Proposed by Milo Casagrande
Status: Merged
Merged at revision: 192
Proposed branch: lp:~milo/lava-tool/unittest-fix
Merge into: lp:~linaro-validation/lava-tool/trunk
Diff against target: 94 lines (+11/-45)
2 files modified
ci-build (+0/-2)
lava/tests/test_config.py (+11/-43)
To merge this branch: bzr merge lp:~milo/lava-tool/unittest-fix
Reviewer Review Type Date Requested Status
Antonio Terceiro Approve
Linaro Validation Team Pending
Review via email: mp+178913@code.launchpad.net

Description of the change

Merge proposal fixes the error found in the CI build job. The fixes are only for the unit tests, there is still one integration tests that is failing, but that fix is done in another merge proposal (lp:~milo/lava-tool/server-rpc-endpoint-fix).

Also, 3 tests have been removed: they were writing in the user home directory. Avoiding that meant to mock all the functionalities under test.

To post a comment you must log in.
Revision history for this message
Antonio Terceiro (terceiro) wrote :

LGTM

 review approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ci-build'
2--- ci-build 2013-06-18 11:48:30 +0000
3+++ ci-build 2013-08-07 09:01:49 +0000
4@@ -33,8 +33,6 @@
5 pip install coverage
6 fi
7
8-export LAVACONFIG=/dev/null
9-
10 if test -z "$DISPLAY"; then
11 # actual CI
12
13
14=== modified file 'lava/tests/test_config.py'
15--- lava/tests/test_config.py 2013-07-31 12:35:26 +0000
16+++ lava/tests/test_config.py 2013-08-07 09:01:49 +0000
17@@ -23,6 +23,7 @@
18 import os
19 import shutil
20 import sys
21+import tempfile
22
23 from StringIO import StringIO
24 from mock import (
25@@ -97,19 +98,22 @@
26
27 def setUp(self):
28 super(ConfigTest, self).setUp()
29- self.patcher = patch("lava.config.DEFAULT_XDG_RESOURCE", "a_temp_dir")
30- self.patcher.start()
31- self.xdg_resource = os.path.join(
32- os.path.expanduser("~"), ".config/a_temp_dir")
33+
34+ self.config_dir = os.path.join(tempfile.gettempdir(), "config")
35+ self.xdg_resource = os.path.join(self.config_dir, "linaro")
36 self.lavatool_resource = os.path.join(self.xdg_resource, "lava-tool")
37+
38+ os.makedirs(self.lavatool_resource)
39+
40 self.config = Config()
41+ self.config._ensure_xdg_dirs = MagicMock(
42+ return_value=self.lavatool_resource)
43 self.config.save = MagicMock()
44
45 def tearDown(self):
46 super(ConfigTest, self).tearDown()
47- self.patcher.stop()
48- if os.path.isdir(self.xdg_resource):
49- shutil.rmtree(self.xdg_resource)
50+ if os.path.isdir(self.config_dir):
51+ shutil.rmtree(self.config_dir)
52
53 def test_ensure_xdg_dirs(self):
54 # Test that xdg can create the correct cache path, we remove it
55@@ -314,39 +318,3 @@
56 obtained = self.config.get(ListParameter("list"))
57 self.assertIsInstance(obtained, list)
58 self.assertEqual(expected, obtained)
59-
60-
61-class TestInteractiveCache(HelperTest):
62-
63- def setUp(self):
64- super(TestInteractiveCache, self).setUp()
65- self.patcher = patch("lava.config.DEFAULT_XDG_RESOURCE", "a_temp_dir")
66- self.patcher.start()
67- self.cache = InteractiveCache()
68- self.cache.save = MagicMock()
69- self.xdg_resource = os.path.join(
70- os.path.expanduser("~"), ".cache/a_temp_dir")
71- self.lavatool_resource = os.path.join(self.xdg_resource, "lava-tool")
72-
73- def tearDown(self):
74- super(TestInteractiveCache, self).tearDown()
75- self.patcher.stop()
76- if os.path.isdir(self.xdg_resource):
77- shutil.rmtree(self.xdg_resource)
78-
79- def test_default_xdg(self):
80- # Dummy test, only to make sure patching the module attribute works.
81- from lava.config import DEFAULT_XDG_RESOURCE
82- self.assertEquals(DEFAULT_XDG_RESOURCE, "a_temp_dir")
83-
84- def test_ensure_xdg_dirs(self):
85- # Test that xdg can create the correct cache path, we remove it
86- # at the end since we patch the default value.
87- obtained = self.cache._ensure_xdg_dirs()
88- self.assertEquals(self.lavatool_resource, obtained)
89-
90- def test_config_file(self):
91- expected = os.path.join(self.lavatool_resource, "parameters.ini")
92- obtained = self.cache.config_file
93- self.assertEquals(expected, obtained)
94-

Subscribers

People subscribed via source and target branches