bricks@388: # Copyright (C) 2010 by Intevation GmbH bricks@388: # Authors: bricks@388: # Bjoern Ricks bricks@388: # bricks@388: # This program is free software under the GPL (>=v2) bricks@388: # Read the file COPYING coming with the software for details. bricks@388: bricks@388: """Tests for treepkg.status.status""" bricks@388: bricks@388: import unittest bricks@388: import os.path bricks@388: import sys bricks@388: bricks@388: test_dir = os.path.dirname(__file__) bricks@388: sys.path.append(os.path.join(test_dir, os.pardir)) bricks@388: bricks@388: from treepkg.info.status import TreepkgInfo bricks@388: from treepkg.report import get_packager_group bricks@388: from filesupport import FileTestMixin bricks@388: bricks@388: class TreepkgInfoExampleTest(unittest.TestCase, FileTestMixin): bricks@388: config_contents = """\ bricks@388: [DEFAULT] bricks@388: treepkg_dir: /home/builder/mill bricks@388: tracks_dir: %(treepkg_dir)s/tracks bricks@388: root_cmd: sudo bricks@388: pbuilder_dir: %(treepkg_dir)s/pbuilder bricks@388: builderconfig: %(pbuilder_dir)s/pbuilderrc bricks@388: deb_email: treepkg@example.com bricks@388: deb_fullname: TreePKG bricks@388: pkg_revision_template: treepkg%%(pkg_revision)s bricks@388: handle_dependencies: False bricks@388: bricks@388: [treepkg] bricks@388: instructions_file: %(treepkg_dir)s/instructions bricks@388: check_interval: 3600 bricks@388: name: testtreepkginfo bricks@388: bricks@388: [pkg_simple] bricks@388: pkg_basename: simple1 bricks@388: svn_url: svn://example.com/%(name)s/trunk bricks@388: base_dir: %(tracks_dir)s/%(name)s bricks@388: packager_class: treepkginfo_test.%(name)s bricks@388: handle_dependencies: True bricks@388: signing_key_id: abcd1234 bricks@388: changelog_msg_template: Update to feature branch r%%(revision)s bricks@388: version_template: 1.0.svn%%(revision)s bricks@388: bricks@388: """ bricks@388: bricks@388: files = [("treepkg.cfg", config_contents), bricks@388: ("treepkginfo_test", bricks@388: [("__init__.py", ""), bricks@388: ("simple.py", bricks@388: "\n".join(["class SourcePackager:", bricks@388: " pass", bricks@388: ""])), bricks@388: ])] bricks@388: bricks@388: def setUp(self): bricks@388: self.directory = self.create_files("treepkg", self.files) bricks@388: self.old_path = sys.path bricks@388: sys.path = [self.directory] + sys.path bricks@388: bricks@388: def tearDown(self): bricks@388: sys.path = self.old_path bricks@388: bricks@388: def test_createinfo(self): bricks@388: config_file = os.path.join(self.directory, "treepkg.cfg") bricks@388: group = get_packager_group(config_file) bricks@388: tpginfo = TreepkgInfo(group.name) bricks@388: print tpginfo.toxml().toxml() bricks@388: self.assertEquals("testtreepkginfo", tpginfo.name) bricks@388: bricks@388: bricks@388: class TreepkgInfoTest(unittest.TestCase): bricks@388: bricks@388: def test_toxml(self): bricks@388: status = TreepkgInfo("testtreepkg") bricks@388: dom = status.toxml() bricks@388: xml = dom.toxml() bricks@388: self.assertEquals("testtreepkg", xml) bricks@388: bricks@388: if __name__ == '__main__': bricks@388: unittest.main() bricks@388: