comparison test/test_packager.py @ 91:3ed079a7174a

Implement a way to stop a running treepackager.
author Bernhard Herzog <bh@intevation.de>
date Tue, 11 Sep 2007 17:24:56 +0000
parents 3ae54f99db26
children 73c67372c7f7
comparison
equal deleted inserted replaced
90:6ed1c881ee1b 91:3ed079a7174a
128 "testpkg_2-kk1.dsc", 128 "testpkg_2-kk1.dsc",
129 "testpkg_2.orig.tar.gz"]) 129 "testpkg_2.orig.tar.gz"])
130 self.assertEquals(sorted(os.listdir(os.path.join(pkgdir, "binary"))), 130 self.assertEquals(sorted(os.listdir(os.path.join(pkgdir, "binary"))),
131 ["testpkg_2-kk1_all.deb", 131 ["testpkg_2-kk1_all.deb",
132 "testpkg_2-kk1_i386.changes"]) 132 "testpkg_2-kk1_i386.changes"])
133
134 class StoppingPackager(treepkg.packager.RevisionPackager):
135
136 def package(self):
137 pass
138
139 class StoppingTrack(treepkg.packager.PackageTrack):
140
141 def __init__(self, do_package, do_stop, instructions_file, name, trackdir):
142 super(StoppingTrack, self).__init__(name, trackdir, "", "", "",
143 "", "")
144 self.do_package = do_package
145 self.do_stop = do_stop
146 self.instructions_file = instructions_file
147
148 def package_if_updated(self, revision):
149 if self.do_stop:
150 writefile(self.instructions_file, "stop")
151 if self.do_package:
152 return StoppingPackager(self, 1)
153 else:
154 return None
155
156
157 class TestPackageGroupStop(unittest.TestCase, FileTestMixin):
158
159 def setUp(self):
160 self.trackdir = self.create_temp_dir(self.id() + "-track")
161 self.instructions_file = os.path.join(self.trackdir, "instructions")
162
163 def group(self, do_package=True, do_stop=True):
164 return PackagerGroup([StoppingTrack(do_package, do_stop,
165 self.instructions_file,
166 "test", self.trackdir)],
167 1, instructions_file=self.instructions_file)
168
169 def test_stop(self):
170 group = self.group(do_package=True, do_stop=True)
171 self.failUnless(group.check_package_tracks())
172
173 def test_no_stop(self):
174 group = self.group(do_package=True, do_stop=False)
175 self.failIf(group.check_package_tracks())
176
177 def test_instruction_removal(self):
178 # run once with stopping
179 group = self.group(do_package=True, do_stop=True)
180 self.failUnless(group.check_package_tracks())
181
182 # run again without stopping but using the same files. The
183 # instructions file should be removed automatically
184 group = self.group(do_package=True, do_stop=False)
185 self.failIf(group.check_package_tracks())
186
187 def test_stopping_without_packaging(self):
188 group = self.group(do_package=False, do_stop=True)
189 self.failUnless(group.check_package_tracks())
190
191 def test_stopping_between_checks(self):
192 group = self.group(do_package=False, do_stop=False)
193 # run check_package_tracks once
194 self.failIf(group.check_package_tracks())
195
196 # tell treepkg to stop
197 writefile(self.instructions_file, "stop")
198
199 # check again. The check_package_tracks() may remove the
200 # instructions file but it must do so only the first time
201 self.failUnless(group.check_package_tracks())
133 202
134 203
135 class TestPackageTrack(unittest.TestCase, FileTestMixin): 204 class TestPackageTrack(unittest.TestCase, FileTestMixin):
136 205
137 def setUp(self): 206 def setUp(self):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)