e = cm.exception
LOG.debug("{cls} raised: {e}".format(cls=e.__class__.__name__, e=e))
+ # -------------------------------------------------------------------------
+ def test_compare(self):
+
+ LOG.info("Test comparing of BaseModuleInfo objects ...")
+ from dpx_puppettools.base_moduleinfo import BaseModuleInfo
+ from dpx_puppettools import pp
+
+ mods = ('puppetlabs-apache', 'puppet-uhu', 'pixelpark-infra', 'Pixelpark-Infra')
+ modinfos = []
+ for mod in mods:
+ modinfo = BaseModuleInfo(
+ appname=self.appname, verbose=self.verbose, full_name=mod)
+ modinfos.append(modinfo)
+
+ LOG.debug("Comparing modules {m1!r} and {m2!r} ...".format(
+ m1=mods[2], m2=mods[3]))
+ self.assertEqual(modinfos[2], modinfos[3])
+ self.assertGreaterEqual(modinfos[2], modinfos[3])
+ self.assertLessEqual(modinfos[2], modinfos[3])
+
+ LOG.debug("Comparing modules {m1!r} and {m2!r} ...".format(
+ m1=mods[1], m2=mods[2]))
+ self.assertNotEqual(modinfos[1], modinfos[2])
+ self.assertGreater(modinfos[1], modinfos[2])
+ self.assertGreaterEqual(modinfos[1], modinfos[2])
+ self.assertLess(modinfos[2], modinfos[1])
+ self.assertLessEqual(modinfos[2], modinfos[1])
+
+ LOG.debug("Sorting modules ...")
+ sorted_modinfos = sorted(modinfos)
+ if self.verbose > 2:
+ LOG.debug("Sorted modinfos:\n{}".format(pp(sorted_modinfos)))
# =============================================================================
if __name__ == '__main__':
suite.addTest(TestBaseModinfo('test_import', verbose))
suite.addTest(TestBaseModinfo('test_init', verbose))
+ suite.addTest(TestBaseModinfo('test_compare', verbose))
runner = unittest.TextTestRunner(verbosity=verbose)