annotate test/test_packager.py @ 274:2676abfc0e1d

Refactoring: Implement do_package in treepkg.packager.SourcePackager. The actual implementation in the derived classes is almost identical in all cases so it's better to have as much of the implementation in the base class. The update_version_numbers method is not called directly by the base class code so is removed from the base class. OTOH, prepare_sources_for_tarball has been added as a more general variant of update_version_numbers that is actually called by the default implementation of do_package.
author Bernhard Herzog <bh@intevation.de>
date Thu, 07 May 2009 15:19:15 +0000
parents e3cda08d2619
children faeeac2c4c71
rev   line source
222
01c043f13f13 Remove the unused PackageTrack.last_packaged_revision method and
Bernhard Herzog <bh@intevation.de>
parents: 190
diff changeset
1 # Copyright (C) 2007, 2008, 2009 by Intevation GmbH
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
2 # Authors:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
3 # Bernhard Herzog <bh@intevation.de>
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
4 #
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
5 # This program is free software under the GPL (>=v2)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
6 # Read the file COPYING coming with the software for details.
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
7
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
8 """Tests for treepkg.packager"""
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
9
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
10 import sys
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
11 import os
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
12 import unittest
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
13
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
14 from treepkg.run import call
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
15 from treepkg.cmdexpand import cmdexpand
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
16 from treepkg.util import writefile
128
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
17 from treepkg.packager import PackagerGroup, import_packager_module, \
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
18 CyclicDependencyError
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
19 import treepkg.subversion as subversion
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
20 import treepkg
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
21
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
22 from filesupport import FileTestMixin
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
23
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
24
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
25 def create_svn_repository(directory):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
26 baseurl = "file://" + directory
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
27 call(cmdexpand("svnadmin create --fs-type fsfs $directory",
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
28 **locals()))
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
29 call(cmdexpand("svn mkdir -q -m 'create directory structure'"
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
30 " $baseurl/trunk",
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
31 **locals()))
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
32 return baseurl
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
33
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
34 def add_svn_files(workingcopy, filedesc, commitmsg):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
35 for name, contents in filedesc:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
36 writefile(os.path.join(workingcopy, name), contents)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
37 call(cmdexpand("svn add -q $name", **locals()),
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
38 cwd=workingcopy)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
39 call(cmdexpand("svn commit -q -m $commitmsg", **locals()),
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
40 cwd=workingcopy)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
41
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
42
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
43 class SourcePackager(treepkg.packager.SourcePackager):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
44
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
45 pkg_basename = "testpkg"
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
46
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
47 def do_package(self):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
48 pkgbaseversion, pkgbasedir = self.export_sources()
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
49
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
50 pkgbasename = self.pkg_basename + "_" + pkgbaseversion
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
51 origtargz = os.path.join(self.work_dir,
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
52 pkgbasename + ".orig.tar.gz")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
53 self.create_tarball(origtargz, self.work_dir,
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
54 os.path.basename(pkgbasedir))
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
55
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
56 changemsg = ("Update to SVN rev. %d" % (self.revision,))
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
57 self.copy_debian_directory(pkgbasedir, pkgbaseversion,
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
58 changemsg)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
59
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
60 self.create_source_package(pkgbasedir, origtargz)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
61 self.move_source_package(pkgbasename)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
62
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
63
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
64 class RevisionPackager(treepkg.packager.RevisionPackager):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
65
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
66 source_packager_cls = SourcePackager
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
67
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
68
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
69 class PackageTrack(treepkg.packager.PackageTrack):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
70
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
71 revision_packager_cls = RevisionPackager
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
72
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
73
94
0c13a84a67dd refactor the packager test cases to prepare for more tests
Bernhard Herzog <bh@intevation.de>
parents: 93
diff changeset
74 class PackagerTest(unittest.TestCase, FileTestMixin):
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
75
94
0c13a84a67dd refactor the packager test cases to prepare for more tests
Bernhard Herzog <bh@intevation.de>
parents: 93
diff changeset
76 revisions = []
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
77
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
78 debian_files = [
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
79 ("debian",
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
80 [("control", """\
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
81 Source: testpkg
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
82 Priority: optional
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
83 Maintainer: TreePKG <treepkg@example.com>
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
84 Standards-Version: 3.7.2
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
85
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
86 Package: testpkg
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
87 Architecture: all
116
093514306186 Cosemetic fix in test data
Bernhard Herzog <bh@intevation.de>
parents: 113
diff changeset
88 Description: Test package for treepkg tests
093514306186 Cosemetic fix in test data
Bernhard Herzog <bh@intevation.de>
parents: 113
diff changeset
89 German (de) internationalized (i18n) files for KDE
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
90 This package contains the German internationalized (i18n) files for
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
91 all KDE core applications.
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
92 """),
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
93 ("changelog", """\
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
94 testpkg (0-0) unstable; urgency=low
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
95
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
96 * Initial version
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
97
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
98 -- TreePKG <treepkg@example.com> Thu, 8 Mar 2007 18:34:39 +0100
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
99 """),
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
100 ("rules", "binary: echo binary")])]
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
101
94
0c13a84a67dd refactor the packager test cases to prepare for more tests
Bernhard Herzog <bh@intevation.de>
parents: 93
diff changeset
102
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
103 def setUp(self):
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
104 self.svndir = self.create_temp_dir("svn")
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
105 self.svnworkdir = self.create_temp_dir("svnwork")
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
106 self.trackdir = self.create_files("track", self.debian_files)
94
0c13a84a67dd refactor the packager test cases to prepare for more tests
Bernhard Herzog <bh@intevation.de>
parents: 93
diff changeset
107 self.svn_url = create_svn_repository(self.svndir) + "/trunk"
0c13a84a67dd refactor the packager test cases to prepare for more tests
Bernhard Herzog <bh@intevation.de>
parents: 93
diff changeset
108 subversion.checkout(self.svn_url, self.svnworkdir)
95
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
109 for message, files in self.revisions:
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
110 add_svn_files(self.svnworkdir, files, message)
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
111
98
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
112 def runtest(self, debrevision, group_args=None, **extra_track_args):
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
113 rootcmd = os.path.join(os.path.dirname(__file__), os.pardir, "test",
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
114 "mocksudopbuilder.py")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
115 track = PackageTrack(name="testpkg", base_dir=self.trackdir,
94
0c13a84a67dd refactor the packager test cases to prepare for more tests
Bernhard Herzog <bh@intevation.de>
parents: 93
diff changeset
116 svn_url=self.svn_url, pbuilderrc="",
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
117 root_cmd=[sys.executable, rootcmd],
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
118 deb_email="treepkg@example.com",
93
73c67372c7f7 Make the prefix used in the debian revision number configurable.
Bernhard Herzog <bh@intevation.de>
parents: 91
diff changeset
119 deb_fullname="treepkg tester",
73c67372c7f7 Make the prefix used in the debian revision number configurable.
Bernhard Herzog <bh@intevation.de>
parents: 91
diff changeset
120 **extra_track_args)
98
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
121
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
122 if group_args is None:
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
123 group_args = {}
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
124 group = PackagerGroup([track], 1, **group_args)
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
125 group.check_package_tracks()
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
126
95
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
127 # determine version that has been packaged. This assumes that
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
128 # check_package_tracks will leave the checkout in the revision
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
129 # that was actually packaged.
98
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
130 version = track.last_changed_revision()
95
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
131
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
132 # Now check the source and binary package files
232
e3cda08d2619 When checking whether to build a new revision, also update the rules
Bernhard Herzog <bh@intevation.de>
parents: 229
diff changeset
133 pkgdir = os.path.join(self.trackdir, "pkg", "%d-0" % version)
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
134 self.assertEquals(sorted(os.listdir(os.path.join(pkgdir, "src"))),
95
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
135 [name % locals() for name in
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
136 ["testpkg_%(version)d-%(debrevision)s.diff.gz",
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
137 "testpkg_%(version)d-%(debrevision)s.dsc",
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
138 "testpkg_%(version)d.orig.tar.gz"]])
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
139 self.assertEquals(sorted(os.listdir(os.path.join(pkgdir, "binary"))),
95
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
140 [name % locals() for name in
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
141 ["testpkg_%(version)d-%(debrevision)s_all.deb",
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
142 "testpkg_%(version)d-%(debrevision)s_i386.changes"]])
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
143
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
144
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
145 class TestPackager(PackagerTest):
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
146
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
147 revisions = [
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
148 ("Initial Revision",
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
149 [("README", "and miles to go before I sleep")]),
8f1c72135ea6 Make PackagerTest more flexible to make it easier to add tests
Bernhard Herzog <bh@intevation.de>
parents: 94
diff changeset
150 ]
93
73c67372c7f7 Make the prefix used in the debian revision number configurable.
Bernhard Herzog <bh@intevation.de>
parents: 91
diff changeset
151
73c67372c7f7 Make the prefix used in the debian revision number configurable.
Bernhard Herzog <bh@intevation.de>
parents: 91
diff changeset
152 def test_default_debrevision_prefix(self):
73c67372c7f7 Make the prefix used in the debian revision number configurable.
Bernhard Herzog <bh@intevation.de>
parents: 91
diff changeset
153 self.runtest("treepkg1")
73c67372c7f7 Make the prefix used in the debian revision number configurable.
Bernhard Herzog <bh@intevation.de>
parents: 91
diff changeset
154
73c67372c7f7 Make the prefix used in the debian revision number configurable.
Bernhard Herzog <bh@intevation.de>
parents: 91
diff changeset
155 def test_custom_debrevision_prefix(self):
73c67372c7f7 Make the prefix used in the debian revision number configurable.
Bernhard Herzog <bh@intevation.de>
parents: 91
diff changeset
156 self.runtest("kk1", debrevision_prefix="kk")
85
31b0567df051 Make PackageTrack.get_revision_numbers return the revisions as a sorted
Bernhard Herzog <bh@intevation.de>
parents: 84
diff changeset
157
98
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
158
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
159 class TestPackagerWithMultipleRevisions(PackagerTest):
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
160
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
161 revisions = [
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
162 ("Initial Revision",
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
163 [("README", "and miles to go before I sleep")]),
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
164 ("Add some code",
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
165 [("program.c", "int main(void) { return 0; }")]),
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
166 ("Add some more code",
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
167 [("another.c", "int main(void) { return 1; }")]),
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
168 ]
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
169
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
170 def test_packaging_specific_revision(self):
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
171 # Package the newest revision and then package an older one.
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
172 self.runtest("treepkg1")
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
173 self.runtest("treepkg1", group_args=dict(revision=3))
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
174
f7b9c7113c46 Make packaging a specific revision work even if newer revisions have already
Bernhard Herzog <bh@intevation.de>
parents: 97
diff changeset
175
91
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
176 class StoppingPackager(treepkg.packager.RevisionPackager):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
177
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
178 def package(self):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
179 pass
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
180
223
230582ed7329 some cosmetic changes:
Bernhard Herzog <bh@intevation.de>
parents: 222
diff changeset
181
91
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
182 class StoppingTrack(treepkg.packager.PackageTrack):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
183
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
184 def __init__(self, do_package, do_stop, instructions_file, name, trackdir):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
185 super(StoppingTrack, self).__init__(name, trackdir, "", "", "",
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
186 "", "")
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
187 self.do_package = do_package
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
188 self.do_stop = do_stop
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
189 self.instructions_file = instructions_file
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
190
190
e83db4482aab Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
191 def package_if_updated(self, revision, do_svn_update=True):
91
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
192 if self.do_stop:
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
193 writefile(self.instructions_file, "stop")
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
194 if self.do_package:
229
653a45adda50 Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents: 223
diff changeset
195 return StoppingPackager(self, 1, 0)
91
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
196 else:
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
197 return None
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
198
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
199
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
200 class TestPackageGroupStop(unittest.TestCase, FileTestMixin):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
201
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
202 def setUp(self):
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
203 self.trackdir = self.create_temp_dir("track")
91
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
204 self.instructions_file = os.path.join(self.trackdir, "instructions")
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
205
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
206 def group(self, do_package=True, do_stop=True):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
207 return PackagerGroup([StoppingTrack(do_package, do_stop,
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
208 self.instructions_file,
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
209 "test", self.trackdir)],
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
210 1, instructions_file=self.instructions_file)
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
211
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
212 def test_stop(self):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
213 group = self.group(do_package=True, do_stop=True)
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
214 self.failUnless(group.check_package_tracks())
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
215
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
216 def test_no_stop(self):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
217 group = self.group(do_package=True, do_stop=False)
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
218 self.failIf(group.check_package_tracks())
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
219
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
220 def test_instruction_removal(self):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
221 # run once with stopping
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
222 group = self.group(do_package=True, do_stop=True)
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
223 self.failUnless(group.check_package_tracks())
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
224
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
225 # run again without stopping but using the same files. The
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
226 # instructions file should be removed automatically
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
227 group = self.group(do_package=True, do_stop=False)
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
228 self.failIf(group.check_package_tracks())
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
229
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
230 def test_stopping_without_packaging(self):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
231 group = self.group(do_package=False, do_stop=True)
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
232 self.failUnless(group.check_package_tracks())
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
233
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
234 def test_stopping_between_checks(self):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
235 group = self.group(do_package=False, do_stop=False)
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
236 # run check_package_tracks once
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
237 self.failIf(group.check_package_tracks())
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
238
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
239 # tell treepkg to stop
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
240 writefile(self.instructions_file, "stop")
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
241
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
242 # check again. The check_package_tracks() may remove the
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
243 # instructions file but it must do so only the first time
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
244 self.failUnless(group.check_package_tracks())
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 88
diff changeset
245
85
31b0567df051 Make PackageTrack.get_revision_numbers return the revisions as a sorted
Bernhard Herzog <bh@intevation.de>
parents: 84
diff changeset
246
31b0567df051 Make PackageTrack.get_revision_numbers return the revisions as a sorted
Bernhard Herzog <bh@intevation.de>
parents: 84
diff changeset
247 class TestPackageTrack(unittest.TestCase, FileTestMixin):
31b0567df051 Make PackageTrack.get_revision_numbers return the revisions as a sorted
Bernhard Herzog <bh@intevation.de>
parents: 84
diff changeset
248
31b0567df051 Make PackageTrack.get_revision_numbers return the revisions as a sorted
Bernhard Herzog <bh@intevation.de>
parents: 84
diff changeset
249 def test_get_revision_numbers(self):
86
9bd92a3290e0 In TestPackageTrack, create the test files in the test_-methods so that
Bernhard Herzog <bh@intevation.de>
parents: 85
diff changeset
250 # Note: The revisions in the pkg dir are not ordered so that we
9bd92a3290e0 In TestPackageTrack, create the test files in the test_-methods so that
Bernhard Herzog <bh@intevation.de>
parents: 85
diff changeset
251 # can check whether get_revision_numbers returns a sorted list
9bd92a3290e0 In TestPackageTrack, create the test files in the test_-methods so that
Bernhard Herzog <bh@intevation.de>
parents: 85
diff changeset
252 # of revisions
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
253 trackdir = self.create_files("track",
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
254 [("pkg",
229
653a45adda50 Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents: 223
diff changeset
255 [("704195-0",
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
256 [("status", ""),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
257 ("src", []),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
258 ("binary", [])]),
229
653a45adda50 Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents: 223
diff changeset
259 ("702432-2",
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
260 [("status", ""),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
261 ("src", []),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
262 ("binary", [])])])])
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
263 track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
229
653a45adda50 Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents: 223
diff changeset
264 self.assertEquals(track.get_revision_numbers(),
653a45adda50 Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents: 223
diff changeset
265 [(702432, 2), (704195, 0)])
87
08d8ffd40f27 add some tests for the PackageTrack.last_packaged_revision() method
Bernhard Herzog <bh@intevation.de>
parents: 86
diff changeset
266
88
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
267
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
268 class TestRevisionPackager(unittest.TestCase, FileTestMixin):
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
269
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
270 def test_list_source_files(self):
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
271 trackdir = self.create_files("track",
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
272 [("pkg",
229
653a45adda50 Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents: 223
diff changeset
273 [("704195-31",
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
274 [("status",
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
275 ("TreePackagerStatus 0.0\n"
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
276 "status: binary_package_created\n"
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
277 "start: 2007-09-10 17:16:48\n"
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
278 "stop: 2007-09-11 00:07:36\n")),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
279 ("src", [("test_1.0.orig.tar.gz", ""),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
280 ("test_1.0-1.diff.gz", ""),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
281 ("test_1.0-1.dsc", "")]),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
282 ("binary", [])]),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
283 ("702432-1",
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
284 [("status", ""),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
285 ("src", []),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
286 ("binary", [])])])])
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
287 track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
229
653a45adda50 Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents: 223
diff changeset
288 revpkg = RevisionPackager(track, 704195, 31)
653a45adda50 Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents: 223
diff changeset
289 srcdir = os.path.join(trackdir, "pkg", "704195-31", "src")
88
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
290 self.assertEquals(revpkg.list_source_files(),
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
291 [os.path.join(srcdir, filename)
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
292 for filename in ["test_1.0-1.diff.gz",
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
293 "test_1.0-1.dsc",
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
294 "test_1.0.orig.tar.gz"]])
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
295
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
296 def test_list_binary_files(self):
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
297 trackdir = self.create_files("track",
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
298 [("pkg",
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
299 [("704195-1",
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
300 [("status",
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
301 ("TreePackagerStatus 0.0\n"
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
302 "status: binary_package_created\n"
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
303 "start: 2007-09-10 17:16:48\n"
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
304 "stop: 2007-09-11 00:07:36\n")),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
305 ("src", []),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
306 ("binary",
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
307 [("test_1.0-1_i386.deb", ""),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
308 ("test_1.0-1_i386.changes", "")])]),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
309 ("702432-1",
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
310 [("status", ""),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
311 ("src", []),
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
312 ("binary", [])])])])
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
313 track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
229
653a45adda50 Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents: 223
diff changeset
314 revpkg = RevisionPackager(track, 704195, 1)
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
315 bindir = os.path.join(trackdir, "pkg", "704195-1", "binary")
88
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
316 self.assertEquals(revpkg.list_binary_files(),
117
4bb029560721 Fix variable name in testcase
Bernhard Herzog <bh@intevation.de>
parents: 116
diff changeset
317 [os.path.join(bindir, filename)
88
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
318 for filename in ["test_1.0-1_i386.changes",
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 87
diff changeset
319 "test_1.0-1_i386.deb"]])
113
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
320
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
321
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
322 class TestImportPackagerModule(unittest.TestCase, FileTestMixin):
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
323
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
324 files = [("treepkg_importtest",
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
325 [("__init__.py", ""),
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
326 ("withtrack.py", "\n".join(["class PackageTrack:",
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
327 " pass",
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
328 ""])),
125
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
329 ("srconly.py", "\n".join(["class SourcePackager:",
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
330 " pass",
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
331 ""])),
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
332 ("srcandbin.py", "\n".join(["class SourcePackager:",
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
333 " pass",
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
334 "class BinaryPackager:",
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
335 " pass",
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
336 ""])),
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
337 ("revonly.py", "\n".join(["class RevisionPackager:",
113
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
338 " pass",
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
339 ""]))])]
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
340
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
341 def setUp(self):
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
342 self.directory = self.create_files("a_module", self.files)
113
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
343 self.old_path = sys.path
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
344 sys.path = [self.directory] + sys.path
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
345
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
346 def tearDown(self):
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
347 sys.path = self.old_path
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
348
125
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
349 def check_class_modules(self, module, classmodules):
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
350 self.assertEquals(classmodules,
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
351 [(item[0],
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
352 sys.modules[getattr(module, item[0]).__module__])
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
353 for item in classmodules])
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
354
113
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
355 def test_import_with_track(self):
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
356 module = import_packager_module("treepkg_importtest.withtrack")
125
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
357 self.check_class_modules(module, [("PackageTrack", module)])
113
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
358
125
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
359 def test_import_with_source_packager(self):
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
360 module = import_packager_module("treepkg_importtest.srconly")
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
361 self.check_class_modules(module, [("PackageTrack", treepkg.packager),
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
362 ("SourcePackager", module),])
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
363
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
364 def test_import_with_source_and_binary_packager(self):
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
365 module = import_packager_module("treepkg_importtest.srcandbin")
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
366 self.check_class_modules(module, [("PackageTrack", treepkg.packager),
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
367 ("RevisionPackager",
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
368 treepkg.packager),
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
369 ("SourcePackager", module),
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
370 ("BinaryPackager", module),])
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
371 self.assertEquals(module.PackageTrack.revision_packager_cls,
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
372 module.RevisionPackager)
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
373 self.assertEquals(module.RevisionPackager.source_packager_cls,
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
374 module.SourcePackager)
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
375 self.assertEquals(module.RevisionPackager.binary_packager_cls,
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
376 module.BinaryPackager)
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
377
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
378 def test_import_with_revision_packager(self):
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
379 module = import_packager_module("treepkg_importtest.revonly")
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
380 self.check_class_modules(module, [("PackageTrack", treepkg.packager),
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
381 ("RevisionPackager", module)])
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
382
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
383 self.assertEquals(module.PackageTrack.revision_packager_cls,
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 117
diff changeset
384 module.RevisionPackager)
128
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
385
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
386
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
387 class PackageTrackWithDependencies(treepkg.packager.PackageTrack):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
388
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
389 def __init__(self, name, handle_dependencies, requires, provides):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
390 defaults = dict(base_dir="/home/builder/tracks/" + name,
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
391 svn_url="svn://example.com",
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
392 root_cmd=["false"],
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
393 pbuilderrc="/home/builder/pbuilderrc",
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
394 deb_email="treepkg@example.com", deb_fullname="treepkg",
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
395 handle_dependencies=handle_dependencies)
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
396 super(PackageTrackWithDependencies,
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
397 self).__init__(name, **defaults)
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
398 self.dependencies = (set(requires.split()), set(provides.split()))
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
399
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
400 def determine_dependencies(self):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
401 pass
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
402
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
403
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
404 class TestPackageDependencies(unittest.TestCase):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
405
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
406 def test_track_order(self):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
407 P = PackageTrackWithDependencies
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
408 tracks = [P("library", True, "base-dev", "library library-dev"),
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
409 P("other", False, "cdbs base-dev", "other"),
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
410 P("base", True, "", "base base-dev"),
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
411 P("program", True, "library-dev libc", "program program-doc"),
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
412 ]
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
413 group = PackagerGroup(tracks, 3600)
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
414 sorted_tracks = group.get_package_tracks()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
415 track_indices = dict([(track.name, index) for index, track in
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
416 enumerate(sorted_tracks)])
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
417 def check_order(track1, track2):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
418 self.failUnless(track_indices[track1] < track_indices[track2])
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
419
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
420 check_order("base", "library")
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
421 check_order("library", "program")
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
422 check_order("base", "program")
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
423
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
424 # sanity check whether other is still there. It doesn't matter
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
425 # where
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
426 self.failUnless("other" in track_indices)
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
427
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
428 def test_track_order_cycle(self):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
429 P = PackageTrackWithDependencies
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
430 tracks = [P("library", True, "base-dev", "library library-dev"),
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
431 P("cycle", True, "program", "cycle"),
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
432 P("other", False, "cdbs base-dev", "other"),
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
433 P("base", True, "cycle", "base base-dev"),
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
434 P("program", True, "library-dev libc", "program program-doc"),
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
435 ]
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
436 try:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
437 group = PackagerGroup(tracks, 3600)
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
438 sorted_tracks = group.get_package_tracks()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
439 except CyclicDependencyError, exc:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
440 pass
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
441 else:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
442 self.fail("PackagerGroup did not detect cyclic dependencies")
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)