Mercurial > treepkg
diff test/test_packager.py @ 125:34e08d52956e
Make the import_packager_module function more flexible. The modules may
now also define a RevisionPackager and a BinaryPackager. See the
docstring for details of the new rules. Also add some more tests.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Thu, 22 May 2008 18:12:30 +0000 |
parents | 4bb029560721 |
children | 5155b4f9443d |
line wrap: on
line diff
--- a/test/test_packager.py Thu May 22 12:44:43 2008 +0000 +++ b/test/test_packager.py Thu May 22 18:12:30 2008 +0000 @@ -354,7 +354,15 @@ ("withtrack.py", "\n".join(["class PackageTrack:", " pass", ""])), - ("notrack.py", "\n".join(["class SourcePackager:", + ("srconly.py", "\n".join(["class SourcePackager:", + " pass", + ""])), + ("srcandbin.py", "\n".join(["class SourcePackager:", + " pass", + "class BinaryPackager:", + " pass", + ""])), + ("revonly.py", "\n".join(["class RevisionPackager:", " pass", ""]))])] @@ -367,10 +375,39 @@ def tearDown(self): sys.path = self.old_path + def check_class_modules(self, module, classmodules): + self.assertEquals(classmodules, + [(item[0], + sys.modules[getattr(module, item[0]).__module__]) + for item in classmodules]) + def test_import_with_track(self): module = import_packager_module("treepkg_importtest.withtrack") - self.failUnless(hasattr(module, "PackageTrack")) + self.check_class_modules(module, [("PackageTrack", module)]) - def test_import_without_track(self): - module = import_packager_module("treepkg_importtest.notrack") - self.failUnless(hasattr(module, "PackageTrack")) + def test_import_with_source_packager(self): + module = import_packager_module("treepkg_importtest.srconly") + self.check_class_modules(module, [("PackageTrack", treepkg.packager), + ("SourcePackager", module),]) + + def test_import_with_source_and_binary_packager(self): + module = import_packager_module("treepkg_importtest.srcandbin") + self.check_class_modules(module, [("PackageTrack", treepkg.packager), + ("RevisionPackager", + treepkg.packager), + ("SourcePackager", module), + ("BinaryPackager", module),]) + self.assertEquals(module.PackageTrack.revision_packager_cls, + module.RevisionPackager) + self.assertEquals(module.RevisionPackager.source_packager_cls, + module.SourcePackager) + self.assertEquals(module.RevisionPackager.binary_packager_cls, + module.BinaryPackager) + + def test_import_with_revision_packager(self): + module = import_packager_module("treepkg_importtest.revonly") + self.check_class_modules(module, [("PackageTrack", treepkg.packager), + ("RevisionPackager", module)]) + + self.assertEquals(module.PackageTrack.revision_packager_cls, + module.RevisionPackager)