From: Frank Brehm Date: Wed, 8 Feb 2023 14:53:28 +0000 (+0100) Subject: Extending tests X-Git-Tag: 0.3.0~2^2~58 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=046746b95925c5c1a1641816df0986cfb6428edc;p=pixelpark%2Fpuppet-tools.git Extending tests --- diff --git a/test/test_20_base_modinfo.py b/test/test_20_base_modinfo.py index 629b2c1..dd77577 100755 --- a/test/test_20_base_modinfo.py +++ b/test/test_20_base_modinfo.py @@ -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( diff --git a/test/test_22_pfile_modinfo.py b/test/test_22_pfile_modinfo.py index aa68eac..3979f49 100755 --- a/test/test_22_pfile_modinfo.py +++ b/test/test_22_pfile_modinfo.py @@ -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)