ComponentTestBase: add check_files() method
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 26 Jun 2014 07:01:18 +0000 (10:01 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Mon, 30 Jun 2014 11:14:42 +0000 (14:14 +0300)
Change-Id: If23365cde15c2659aad039f19984a97968cd4545
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
tests/component/__init__.py
tests/component/rpm/test_import_orig_rpm.py

index f029eb2810c01970afc0daac672223fe91980caa..0c7e27f38ccfb9135440815bd8cd6950175d6edd 100644 (file)
@@ -125,6 +125,15 @@ class ComponentTestBase(object):
 
         self._capture_log(False)
 
+    @staticmethod
+    def check_files(reference, filelist):
+        """Compare two file lists"""
+        extra = set(filelist) - set(reference)
+        missing = set(reference) - set(filelist)
+        assert_msg = "Unexpected files: %s, Missing files: %s" % \
+                        (list(extra), list(missing))
+        assert not extra and not missing, assert_msg
+
     @classmethod
     def _check_repo_state(cls, repo, current_branch, branches, files=None):
         """Check that repository is clean and given branches exist"""
@@ -148,10 +157,7 @@ class ComponentTestBase(object):
                 for dirname in dirnames:
                     local.add(os.path.relpath(os.path.join(dirpath, dirname),
                                               repo.path) + '/')
-            extra = local - set(files)
-            ok_(not extra, "Unexpected files in repo: %s" % list(extra))
-            missing = set(files) - local
-            ok_(not missing, "Files missing from repo: %s" % list(missing))
+            cls.check_files(files, local)
 
     def _capture_log(self, capture=True):
         """ Capture log"""
index 465c5fad4ea2c8544f2d4076d0de0b121e3c02f4..935e995fd651eae6dc4e35e317432c64ca0c71f0 100644 (file)
@@ -96,14 +96,6 @@ class ImportOrigTestBase(ComponentTestBase):
         blobs = [obj[3] for obj in objs if obj[1] == 'blob']
         return set(blobs)
 
-    @staticmethod
-    def check_files(reference, filelist):
-        """Compare two file lists"""
-        extra = set(filelist) - set(reference)
-        assert not extra, "Unexpected files: %s" % list(extra)
-        missing = set(reference) - set(filelist)
-        assert not missing, "Missing files: %s" % list(missing)
-
     @classmethod
     def check_tree(cls, repo, treeish, filelist):
         """Check the contents (list of files) in a git treeish"""