[csw-devel] SF.net SVN: gar:[14795] csw/mgar/gar/v2/lib/python

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Jun 12 22:38:21 CEST 2011


Revision: 14795
          http://gar.svn.sourceforge.net/gar/?rev=14795&view=rev
Author:   wahwah
Date:     2011-06-12 20:38:20 +0000 (Sun, 12 Jun 2011)

Log Message:
-----------
file-set-checker: Unit tests refactoring

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/file_set_checker.py
    csw/mgar/gar/v2/lib/python/file_set_checker_test.py

Modified: csw/mgar/gar/v2/lib/python/file_set_checker.py
===================================================================
--- csw/mgar/gar/v2/lib/python/file_set_checker.py	2011-06-12 20:37:30 UTC (rev 14794)
+++ csw/mgar/gar/v2/lib/python/file_set_checker.py	2011-06-12 20:38:20 UTC (rev 14795)
@@ -74,8 +74,7 @@
       tags.append(tag.CheckpkgTag(None, error_tag_name, catalogname))
     return tags
 
-  def CheckFiles(self, file_list):
-    """Checks a set of files. Returns error tags."""
+  def _FilesWithMetadata(self, file_list):
     files_with_metadata = []
     for file_path in file_list:
       pkg_path, basename = os.path.split(file_path)
@@ -89,7 +88,11 @@
       for arch in archs:
         for osrel in common_constants.OS_RELS:
           key = arch, osrel
-          # catalognames_by_arch.setdefault(key, set()).add(catalogname)
+    return files_with_metadata
+
+  def CheckFiles(self, file_list):
+    """Checks a set of files. Returns error tags."""
+    files_with_metadata = self._FilesWithMetadata(file_list)
     tags = []
     tags.extend(self._CheckMissingArchs(files_with_metadata))
     tags.extend(self._CheckUncommitted(files_with_metadata))

Modified: csw/mgar/gar/v2/lib/python/file_set_checker_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/file_set_checker_test.py	2011-06-12 20:37:30 UTC (rev 14794)
+++ csw/mgar/gar/v2/lib/python/file_set_checker_test.py	2011-06-12 20:38:20 UTC (rev 14795)
@@ -27,7 +27,8 @@
   def testMissingArchitecture(self):
     fc = file_set_checker.FileSetChecker()
     expected = [tag.CheckpkgTag(None, 'i386-SunOS5.9-missing', 'libnspr4')]
-    self.assertEqual(expected, fc.CheckFiles(SAMPLE_FILES))
+    files_with_metadata = fc._FilesWithMetadata(SAMPLE_FILES)
+    self.assertEqual(expected, fc._CheckMissingArchs(files_with_metadata))
 
   def testMissingArchitectureWithOsrel(self):
     files = [
@@ -39,7 +40,8 @@
     ]
     fc = file_set_checker.FileSetChecker()
     expected = [tag.CheckpkgTag(None, 'sparc-SunOS5.10-missing', 'foo')]
-    self.assertEqual(expected, fc.CheckFiles(files))
+    files_with_metadata = fc._FilesWithMetadata(files)
+    self.assertEqual(expected, fc._CheckMissingArchs(files_with_metadata))
 
   def testUncommitted(self):
     fc = file_set_checker.FileSetChecker()
@@ -55,16 +57,21 @@
              'nspr_devel-4.8.6,REV=2010.10.16-SunOS5.9-sparc-UNCOMMITTED.pkg.gz',
              '/home/experimental/maciej/'
              'nspr_devel-4.8.6,REV=2010.10.16-SunOS5.9-i386-UNCOMMITTED.pkg.gz']
-    self.assertEqual(expected, fc.CheckFiles(files))
+    files_with_metadata = fc._FilesWithMetadata(files)
+    self.assertEqual(expected, fc._CheckUncommitted(files_with_metadata))
 
   def testBadInput(self):
     fc = file_set_checker.FileSetChecker()
     expected = [
+        tag.CheckpkgTag(None, 'bad-vendor-tag', 'filename=csw-upload-pkg expected=CSW actual=UNKN')
+    ]
+    expected_2 = [
         tag.CheckpkgTag(None, 'bad-arch-or-os-release', 'csw-upload-pkg arch=pkg osrel=unspecified'),
-        tag.CheckpkgTag(None, 'bad-vendor-tag', 'filename=csw-upload-pkg expected=CSW actual=UNKN'),
     ]
     files = ['csw-upload-pkg']
-    self.assertEqual(expected, fc.CheckFiles(files))
+    files_with_metadata = fc._FilesWithMetadata(files)
+    self.assertEqual(expected, fc._CheckUncommitted(files_with_metadata))
+    self.assertEqual(expected_2, fc._CheckMissingArchs(files_with_metadata))
 
 
 if __name__ == '__main__':


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list