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@392: from treepkg.info.status import * bricks@388: from treepkg.report import get_packager_group bricks@388: from filesupport import FileTestMixin bricks@388: bricks@413: from publishdebianpackages import get_binary_arch bricks@413: bricks@392: class TreepkgInfoTest(unittest.TestCase, FileTestMixin): bricks@388: config_contents = """\ bricks@388: [DEFAULT] bricks@392: #treepkg_dir: /home/builder/mill bricks@392: #tracks_dir: %(treepkg_dir)s/tracks bricks@392: tracks_dir: /home/builder/mill/tracks bricks@388: root_cmd: sudo bricks@392: pbuilder_dir: %(tracks_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@392: instructions_file: %(tracks_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@392: tpkginfo = TreepkgInfo(config_file) bricks@413: tpkgrootinfo = tpkginfo.tpkgroot.info bricks@413: self.assertEquals("testtreepkginfo", tpkgrootinfo.name) bricks@388: bricks@388: bricks@392: class TreepkgRootInfoTest(unittest.TestCase): bricks@388: bricks@388: def test_toxml(self): bricks@392: status = TreepkgRootInfo("testtreepkg") bricks@388: dom = status.toxml() bricks@388: xml = dom.toxml() bricks@413: self.assertEquals("testtreepkg", xml) bricks@413: bricks@413: class TestPublishDebianPackages(unittest.TestCase, FileTestMixin): bricks@413: bricks@413: def test_get_binary_arch(self): bricks@413: source = get_binary_arch("source") bricks@413: self.assertEquals("source", source) bricks@413: binary_armel = get_binary_arch("armel") bricks@413: self.assertEquals("binary-armel", binary_armel) bricks@413: binary_armel = get_binary_arch("binary-armel") bricks@413: self.assertEquals("binary-armel", binary_armel) bricks@413: bricks@388: bricks@388: if __name__ == '__main__': bricks@388: unittest.main() bricks@388: