]> Frank Brehm's Git Trees - pixelpark/puppet-tools.git/commitdiff
Extending tests
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 8 Feb 2023 14:53:28 +0000 (15:53 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 8 Feb 2023 14:53:28 +0000 (15:53 +0100)
test/test_20_base_modinfo.py
test/test_22_pfile_modinfo.py

index 629b2c105e28da298f3c465b105299eccbd292e1..dd77577d8c133f249f0a024d3959575497ee7d79 100755 (executable)
@@ -53,7 +53,7 @@ class TestBaseModinfo(DpxPuppetToolsTestcase):
         from dpx_puppettools.errors import ModuleInitError
 
         module = 'pixelpark-infra'
-        bad_module = 'uhu'
+        bad_module = 'Bähm!'
 
         modinfo = BaseModuleInfo(
             appname=self.appname, verbose=self.verbose, full_name=module)
@@ -66,6 +66,16 @@ class TestBaseModinfo(DpxPuppetToolsTestcase):
         self.assertEqual(modinfo.name, 'infra')
         self.assertEqual(modinfo.vendor, 'pixelpark')
 
+        modinfo = BaseModuleInfo(
+            appname=self.appname, verbose=self.verbose, full_name='hieradata')
+        LOG.debug("BaseModuleInfo %%r: {!r}".format(modinfo))
+        if self.verbose > 2:
+            LOG.debug("BaseModuleInfo %%s:\n{}".format(modinfo))
+        self.assertEqual(modinfo.full_name, 'hieradata')
+        self.assertEqual(modinfo.full_name_orig, 'hieradata')
+        self.assertEqual(modinfo.name, 'hieradata')
+        self.assertIsNone(modinfo.vendor)
+
         LOG.debug(
             "Testing init of a BaseModuleInfo object with a bad module name {!r}.".format(
             bad_module))
@@ -83,7 +93,8 @@ class TestBaseModinfo(DpxPuppetToolsTestcase):
         from dpx_puppettools.base_moduleinfo import BaseModuleInfo
         from dpx_puppettools import pp
 
-        mods = ('puppetlabs-apache', 'puppet-uhu', 'pixelpark-infra', 'Pixelpark-Infra')
+        mods = ('puppetlabs-apache', 'puppet-uhu', 'pixelpark-infra',
+            'Pixelpark-Infra', 'hieradata')
         modinfos = []
         for mod in mods:
             modinfo = BaseModuleInfo(
index aa68eac5963992c5dd7b7ad04577e9dc84edde28..3979f49f23f1e80fa2f86c28e9b5d5eed60fb2ff 100755 (executable)
@@ -76,6 +76,40 @@ class TestPuppetfileModinfo(DpxPuppetToolsTestcase):
         e = cm.exception
         LOG.debug("{cls} raised: {e}".format(cls=e.__class__.__name__, e=e))
 
+    # -------------------------------------------------------------------------
+    def test_parsing(self):
+
+        LOG.info("Test parsing of Puppetfile module entries ...")
+
+        from dpx_puppettools.pfile_moduleinfo import PuppetfileModuleInfo
+
+        modline = "mod 'abaranov-cobbler',          '0.3.3'"
+        modlines = (
+            "mod 'branan/eight_hundred'",
+            "mod 'abaranov-cobbler',          '0.3.3'",
+            "mod 'puppetlabs/apache', :latest",
+            "mod 'puppetlabs/apache', type:    'forge', version: '6.0.0'",
+            "mod 'pixelpark-accounts',               :git => 'git@git.pixelpark.com:puppet/accounts.git',               :tag => '2.6.0'",
+            "mod 'pixelpark-maven',                  :git => 'https://github.com/pixelpark/puppet-maven',               :commit => '2ae93f8'",
+            "mod 'puppet-typo3',                     :git => 'https://github.com/pixelpark/puppet-typo3.git',           :tag => '0.5.3'",
+            "mod 'pixelpark-infra',                  :git => \"git@git.pixelpark.com:puppet/infra.git\",                  :branch => 'mongo-test'",
+            """mod 'saz-sudo',
+                :git => 'https://github.com/pixelpark/puppet-sudo.git',
+                :tag => 'v7.0.2.2'""",
+            "mod 'puppetlabs-apache', type: 'git', source: 'https://github.com/puppetlabs/puppetlabs-apache', version: '2098a17'",
+            """mod 'hieradata',
+                :git => 'git@git.example.com:organization/hieradata.git',
+                :branch => :control_branch,
+                :default_branch => 'master',
+                :install_path => 'hiera-data'""",
+        )
+
+        for modline in modlines:
+            LOG.debug("Test parsing of: {!r}".format(modline))
+            modinfo = PuppetfileModuleInfo.init_from_puppetfile_line(
+                modline, appname=self.appname, verbose=self.verbose)
+            LOG.debug("PuppetfileModuleInfo %%r: {!r}".format(modinfo))
+
 
 # =============================================================================
 if __name__ == '__main__':
@@ -91,7 +125,7 @@ if __name__ == '__main__':
 
     suite.addTest(TestPuppetfileModinfo('test_import', verbose))
     suite.addTest(TestPuppetfileModinfo('test_init', verbose))
-    # suite.addTest(TestBaseModinfo('test_compare', verbose))
+    suite.addTest(TestPuppetfileModinfo('test_parsing', verbose))
 
     runner = unittest.TextTestRunner(verbosity=verbose)