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)
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))
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(
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__':
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)