python: Repomd class support loading repomd.xml during construction (add path param).
authorTomas Mlcoch <tmlcoch@redhat.com>
Tue, 4 Jun 2013 11:53:10 +0000 (13:53 +0200)
committerTomas Mlcoch <tmlcoch@redhat.com>
Tue, 4 Jun 2013 11:53:10 +0000 (13:53 +0200)
src/python/__init__.py
tests/python/tests/test_repomd.py

index df39a35..8208895 100644 (file)
@@ -61,7 +61,11 @@ class Package(_createrepo_c.Package):
 
 # Repomd class
 
-Repomd = _createrepo_c.Repomd
+class Repomd(_createrepo_c.Repomd):
+    def __init__(self, path=None):
+        _createrepo_c.Repomd.__init__(self)
+        if path:
+            xml_parse_repomd(path, self)
 
 # RepomdRecord class
 
@@ -107,7 +111,7 @@ class OtherXmlFile(XmlFile):
     def __init__(self, filename, compressiontype=GZ_COMPRESSION):
         XmlFile.__init__(self, filename, XMLFILE_OTHER, compressiontype)
 
-# Methods
+# Functions
 
 xml_dump_primary    = _createrepo_c.xml_dump_primary
 xml_dump_filelists  = _createrepo_c.xml_dump_filelists
index 24a3960..bceb5a9 100644 (file)
@@ -110,3 +110,13 @@ class TestCaseRepomd(unittest.TestCase):
   </data>
 </repomd>
 """)
+
+    def test_repomd_with_path_in_constructor_repo01(self):
+
+        repomd = cr.Repomd(REPO_01_REPOMD)
+        self.assertEqual(repomd.revision, "1334667230")
+        self.assertEqual(repomd.repo_tags, [])
+        self.assertEqual(repomd.distro_tags, [])
+        self.assertEqual(repomd.content_tags, [])
+        self.assertEqual(len(repomd.records), 3)
+