Changeset 51 for mergebot/trunk/utils/test.py
- Timestamp:
- Feb 23, 2010 6:58:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mergebot/trunk/utils/test.py
r47 r51 189 189 190 190 191 class FunctionalSvnTestCaseSetup(FunctionalTwillTestCaseSetup): 192 def get_workdir(self): 193 return os.path.join(self._testenv.dirname, self.__class__.__name__) 194 195 def checkout(self, ticket_id=None): 196 """checkout a working copy of the branch for the given ticket, or trunk if none given""" 197 if ticket_id is None: 198 svnurl = self._testenv.repo_url() + '/stuff/trunk' 199 else: 200 svnurl = self._testenv.repo_url() + '/stuff/branches/ticket-%s' % ticket_id 201 retval = call(['svn', 'checkout', svnurl, self.get_workdir()], 202 stdout=logfile, stderr=logfile) 203 self.assertEqual(retval, 0, "svn checkout failed with error %s" % (retval)) 204 205 def switch(self, ticket_id=None): 206 if ticket_id is None: 207 svnurl = self._testenv.repo_url() + '/stuff/trunk' 208 else: 209 svnurl = self._testenv.repo_url() + '/stuff/branches/ticket-%s' % ticket_id 210 retval = call(['svn', 'switch', svnurl, self.get_workdir()], 211 stdout=logfile, stderr=logfile) 212 self.assertEqual(retval, 0, "svn checkout failed with error %s" % (retval)) 213 214 def add_new_file(self, filename=None): 215 workdir = self.get_workdir() 216 if filename is None: 217 newfile = os.path.join(workdir, self.__class__.__name__) 218 else: 219 newfile = os.path.join(workdir, filename) 220 open(newfile, 'w').write(random_page()) 221 retval = call(['svn', 'add', newfile], 222 cwd=workdir, 223 stdout=logfile, stderr=logfile) 224 self.assertEqual(retval, 0, "svn add failed with error %s" % (retval)) 225 226 def commit(self, message, files=None): 227 if files is None: 228 files = ['.'] 229 retval = call(['svn', 'commit', '-m', message] + list(files), 230 cwd=self.get_workdir(), 231 stdout=logfile, stderr=logfile) 232 self.assertEqual(retval, 0, "svn commit failed with error %s" % (retval)) 233 234 191 235 class MergeBotTestEnabled(FunctionalTwillTestCaseSetup): 192 236 def runTest(self): … … 246 290 247 291 248 class MergeBotTestRebranchWithChange(Functional TwillTestCaseSetup):292 class MergeBotTestRebranchWithChange(FunctionalSvnTestCaseSetup): 249 293 def runTest(self): 250 294 """Verify that the 'rebranch' button works with changes on the branch""" … … 254 298 255 299 # checkout a working copy & make a change 256 svnurl = self._testenv.repo_url() 257 workdir = os.path.join(self._testenv.dirname, self.__class__.__name__) 258 retval = call(['svn', 'checkout', svnurl + '/stuff/branches/ticket-%s' % ticket_id, workdir], 259 stdout=logfile, stderr=logfile) 260 self.assertEqual(retval, 0, "svn checkout failed with error %s" % (retval)) 300 self.checkout(ticket_id) 261 301 # Create & add a new file 262 newfile = os.path.join(workdir, self.__class__.__name__) 263 open(newfile, 'w').write(random_page()) 264 retval = call(['svn', 'add', self.__class__.__name__], 265 cwd=workdir, 266 stdout=logfile, stderr=logfile) 267 self.assertEqual(retval, 0, "svn add failed with error %s" % (retval)) 268 retval = call(['svn', 'commit', '-m', 'Add a new file', self.__class__.__name__], 269 cwd=workdir, 270 stdout=logfile, stderr=logfile) 271 self.assertEqual(retval, 0, "svn commit failed with error %s" % (retval)) 302 self.add_new_file() 303 self.commit('Add a new file') 304 305 self._tester.rebranch(ticket_id, 'stuff') 306 307 308 class MergeBotTestRebranchWithChangeAndTrunkChange(FunctionalSvnTestCaseSetup): 309 def runTest(self): 310 """Verify that the 'rebranch' button works with changes on the branch""" 311 ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, 312 info={'component':'stuff', 'version':'trunk'}) 313 self._tester.branch(ticket_id, 'stuff') 314 315 # checkout a working copy & make a change 316 self.checkout(ticket_id) 317 # Create & add a new file 318 basename = self.__class__.__name__ 319 self.add_new_file(basename + '-ticket') 320 self.commit('Add a new file on ticket') 321 self.switch() 322 self.add_new_file(basename + '-trunk') 323 self.commit('Add a new file on trunk') 272 324 273 325 self._tester.rebranch(ticket_id, 'stuff') … … 313 365 suite.addTest(MergeBotTestMerge()) 314 366 suite.addTest(MergeBotTestRebranchWithChange()) 367 suite.addTest(MergeBotTestRebranchWithChangeAndTrunkChange()) 315 368 suite.addTest(MergeBotTestSingleUseCase()) 316 369 return suite
Note: See TracChangeset
for help on using the changeset viewer.