diff mbox

[Branch,~linaro-validation/lava-tool/trunk] Rev 192: Fixed unit and integration tests.

Message ID 20130807094724.16646.35110.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Milo Casagrande Aug. 7, 2013, 9:47 a.m. UTC
Merge authors:
  Milo Casagrande (milo)
Related merge proposals:
  https://code.launchpad.net/~milo/lava-tool/unittest-fix/+merge/178913
  proposed by: Milo Casagrande (milo)
  review: Approve - Antonio Terceiro (terceiro)
------------------------------------------------------------
revno: 192 [merge]
committer: Milo Casagrande <milo@ubuntu.com>
branch nick: trunk
timestamp: Wed 2013-08-07 11:42:57 +0200
message:
  Fixed unit and integration tests.
modified:
  ci-build
  lava/tests/test_config.py


--
lp:lava-tool
https://code.launchpad.net/~linaro-validation/lava-tool/trunk

You are subscribed to branch lp:lava-tool.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-tool/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'ci-build'
--- ci-build	2013-06-18 11:48:30 +0000
+++ ci-build	2013-08-07 08:54:55 +0000
@@ -33,8 +33,6 @@ 
   pip install coverage
 fi
 
-export LAVACONFIG=/dev/null
-
 if test -z "$DISPLAY"; then
   # actual CI
 

=== modified file 'lava/tests/test_config.py'
--- lava/tests/test_config.py	2013-07-31 12:35:26 +0000
+++ lava/tests/test_config.py	2013-08-07 08:38:50 +0000
@@ -23,6 +23,7 @@ 
 import os
 import shutil
 import sys
+import tempfile
 
 from StringIO import StringIO
 from mock import (
@@ -97,19 +98,22 @@ 
 
     def setUp(self):
         super(ConfigTest, self).setUp()
-        self.patcher = patch("lava.config.DEFAULT_XDG_RESOURCE", "a_temp_dir")
-        self.patcher.start()
-        self.xdg_resource = os.path.join(
-            os.path.expanduser("~"), ".config/a_temp_dir")
+
+        self.config_dir = os.path.join(tempfile.gettempdir(), "config")
+        self.xdg_resource = os.path.join(self.config_dir, "linaro")
         self.lavatool_resource = os.path.join(self.xdg_resource, "lava-tool")
+
+        os.makedirs(self.lavatool_resource)
+
         self.config = Config()
+        self.config._ensure_xdg_dirs = MagicMock(
+            return_value=self.lavatool_resource)
         self.config.save = MagicMock()
 
     def tearDown(self):
         super(ConfigTest, self).tearDown()
-        self.patcher.stop()
-        if os.path.isdir(self.xdg_resource):
-            shutil.rmtree(self.xdg_resource)
+        if os.path.isdir(self.config_dir):
+            shutil.rmtree(self.config_dir)
 
     def test_ensure_xdg_dirs(self):
         # Test that xdg can create the correct cache path, we remove it
@@ -314,39 +318,3 @@ 
         obtained = self.config.get(ListParameter("list"))
         self.assertIsInstance(obtained, list)
         self.assertEqual(expected, obtained)
-
-
-class TestInteractiveCache(HelperTest):
-
-    def setUp(self):
-        super(TestInteractiveCache, self).setUp()
-        self.patcher = patch("lava.config.DEFAULT_XDG_RESOURCE", "a_temp_dir")
-        self.patcher.start()
-        self.cache = InteractiveCache()
-        self.cache.save = MagicMock()
-        self.xdg_resource = os.path.join(
-            os.path.expanduser("~"), ".cache/a_temp_dir")
-        self.lavatool_resource = os.path.join(self.xdg_resource, "lava-tool")
-
-    def tearDown(self):
-        super(TestInteractiveCache, self).tearDown()
-        self.patcher.stop()
-        if os.path.isdir(self.xdg_resource):
-            shutil.rmtree(self.xdg_resource)
-
-    def test_default_xdg(self):
-        # Dummy test, only to make sure patching the module attribute works.
-        from lava.config import DEFAULT_XDG_RESOURCE
-        self.assertEquals(DEFAULT_XDG_RESOURCE, "a_temp_dir")
-
-    def test_ensure_xdg_dirs(self):
-        # Test that xdg can create the correct cache path, we remove it
-        # at the end since we patch the default value.
-        obtained = self.cache._ensure_xdg_dirs()
-        self.assertEquals(self.lavatool_resource, obtained)
-
-    def test_config_file(self):
-        expected = os.path.join(self.lavatool_resource, "parameters.ini")
-        obtained = self.cache.config_file
-        self.assertEquals(expected, obtained)
-