Package moap :: Package test :: Module test_commands_cl
[hide private]
[frames] | no frames]

Source Code for Module moap.test.test_commands_cl

  1  # -*- Mode: Python; test-case-name: moap.test.test_commands_cl -*- 
  2  # vi:si:et:sw=4:sts=4:ts=4 
  3   
  4  import os 
  5  import time 
  6  import StringIO 
  7   
  8  from moap.test import common 
  9   
 10  from moap.util import log 
 11   
 12  from moap.command import cl 
 13   
14 -class TestClMoap1(common.TestCase):
15 - def setUp(self):
16 file = os.path.join(os.path.dirname(__file__), 'ChangeLog', 17 'ChangeLog.moap') 18 self.cl = cl.ChangeLogFile(file) 19 self.cl.parse()
20
21 - def testGetEntry0(self):
22 e = self.cl.getEntry(0) 23 self.assertEquals(e.date, "2006-06-15") 24 self.assertEquals(e.name, "Thomas Vander Stichele") 25 self.assertEquals(e.address, "thomas at apestaart dot org") 26 self.assertEquals(len(e.files), 1) 27 self.assertEquals(e.files, ["moap/vcs/svn.py"]) 28 # we don't want the empty line because text ends in \n 29 lines = e.text.split("\n")[:-1] 30 self.assertEquals(len(lines), 2)
31
32 - def testGetEntry1(self):
33 e = self.cl.getEntry(1) 34 self.assertEquals(e.date, "2006-06-12") 35 self.assertEquals(e.name, "Thomas Vander Stichele") 36 self.assertEquals(e.address, "thomas at apestaart dot org") 37 self.assertEquals(len(e.files), 2) 38 self.assertEquals(e.files, [ 39 "moap/commands/doap.py", 40 "moap/doap/doap.py", 41 ])
42
43 - def testFind(self):
44 searchTerms = ['show'] 45 entries = self.cl.find(searchTerms) 46 self.assertEquals(len(entries), 1) 47 e = entries[0] 48 self.assertEquals(e.date, "2006-06-12") 49 self.assertEquals(e.name, "Thomas Vander Stichele") 50 self.assertEquals(e.address, "thomas at apestaart dot org")
51
52 - def testFindByNameAndDate(self):
53 searchTerms = ['Thomas', '2006', 'show'] 54 entries = self.cl.find(searchTerms) 55 self.assertEquals(len(entries), 1) 56 e = entries[0] 57 self.assertEquals(e.date, "2006-06-12") 58 self.assertEquals(e.name, "Thomas Vander Stichele") 59 self.assertEquals(e.address, "thomas at apestaart dot org")
60
61 - def testFindCaseInsEnSiTiVE(self):
62 searchTerms = ['SHOW'] 63 entries = self.cl.find(searchTerms) 64 self.assertEquals(len(entries), 1) 65 e = entries[0] 66 self.assertEquals(e.date, "2006-06-12") 67 self.assertEquals(e.name, "Thomas Vander Stichele") 68 self.assertEquals(e.address, "thomas at apestaart dot org")
69
70 - def testFindCaseSensitive(self):
71 searchTerms = ['SHOW'] 72 entries = self.cl.find(searchTerms, caseSensitive=True) 73 self.assertEquals(len(entries), 0) 74 searchTerms = ['show'] 75 entries = self.cl.find(searchTerms, caseSensitive=True) 76 self.assertEquals(len(entries), 1) 77 e = entries[0] 78 self.assertEquals(e.date, "2006-06-12") 79 self.assertEquals(e.name, "Thomas Vander Stichele") 80 self.assertEquals(e.address, "thomas at apestaart dot org")
81
82 - def testFindMultiple(self):
83 searchTerms = ['svn.py'] 84 entries = self.cl.find(searchTerms) 85 self.assertEquals(len(entries), 3) 86 e = entries[0] 87 self.assertEquals(e.date, "2006-06-15") 88 self.assertEquals(e.name, "Thomas Vander Stichele") 89 self.assertEquals(e.address, "thomas at apestaart dot org") 90 e = entries[1] 91 self.assertEquals(e.date, "2006-06-11") 92 self.assertEquals(e.name, "Thomas Vander Stichele") 93 self.assertEquals(e.address, "thomas at apestaart dot org") 94 e = entries[2] 95 self.assertEquals(e.date, "2006-06-11") 96 self.assertEquals(e.name, "Thomas Vander Stichele") 97 self.assertEquals(e.address, "thomas at apestaart dot org") 98 99 searchTerms = ['svn.py', '--no-commit'] 100 entries = self.cl.find(searchTerms) 101 self.assertEquals(len(entries), 1) 102 e = entries[0] 103 self.assertEquals(e.date, "2006-06-11") 104 self.assertEquals(e.name, "Thomas Vander Stichele") 105 self.assertEquals(e.address, "thomas at apestaart dot org") 106 107 searchTerms = ['svn.py', 'foobar'] 108 entries = self.cl.find(searchTerms) 109 self.assertEquals(len(entries), 0)
110
111 -class TestClGstPluginsGood(common.TestCase):
112 - def setUp(self):
113 file = os.path.join(os.path.dirname(__file__), 'ChangeLog', 114 'ChangeLog.gst-plugins-good') 115 self.cl = cl.ChangeLogFile(file) 116 self.cl.parse()
117
118 - def testGetEntry0(self):
119 e = self.cl.getEntry(0) 120 self.assertEquals(e.date, "2006-06-29") 121 self.assertEquals(e.name, "Thomas Vander Stichele") 122 self.assertEquals(e.address, "thomas at apestaart dot org") 123 self.assertEquals(len(e.files), 1) 124 self.assertEquals(e.files, ["tests/check/elements/level.c"]) 125 # we don't want the empty line because text ends in \n 126 lines = e.text.split("\n")[:-1] 127 self.assertEquals(len(lines), 2)
128
129 -class TestClGstreamer(common.TestCase):
130 - def setUp(self):
131 file = os.path.join(os.path.dirname(__file__), 'ChangeLog', 132 'ChangeLog.gstreamer') 133 self.cl = cl.ChangeLogFile(file) 134 self.cl.parse()
135
136 - def testGetEntry0(self):
137 e = self.cl.getEntry(0) 138 self.assertEquals(e.date, "2006-07-02") 139 self.assertEquals(e.name, "Thomas Vander Stichele") 140 self.assertEquals(e.address, "thomas at apestaart dot org") 141 self.assertEquals(len(e.files), 1) 142 self.assertEquals(e.files, ["tests/check/gst/gststructure.c"]) 143 # we don't want the empty line because text ends in \n 144 lines = e.text.split("\n")[:-1] 145 self.assertEquals(len(lines), 3)
146
147 -class TestClGstPluginsBase(common.TestCase):
148 - def setUp(self):
149 self.file = os.path.join(os.path.dirname(__file__), 'ChangeLog', 150 'ChangeLog.gst-plugins-base') 151 self.cl = cl.ChangeLogFile(self.file) 152 self.cl.parse()
153
154 - def testGetRelease(self):
155 e = self.cl.getEntry(0) 156 self.assertEquals(e.version, "0.10.10")
157
158 - def testGetContributors(self):
159 e = self.cl.getEntry(1) 160 self.assertEquals(e.contributors, ["Michael Smith", ])
161
162 - def testContributors(self):
163 stdout = StringIO.StringIO() 164 c = cl.ChangeLog(stdout=stdout) 165 ret = c.parse(['-C', self.file, 'contributors']) 166 self.assertEquals(ret, 0) 167 self.assertEquals(stdout.getvalue(), "\n")
168
169 - def testContributorsRelease(self):
170 stdout = StringIO.StringIO() 171 c = cl.ChangeLog(stdout=stdout) 172 ret = c.parse(['-C', self.file, 'contributors', '-r', '0.10.10']) 173 self.assertEquals(ret, 0) 174 self.assertEquals(stdout.getvalue(), """Michael Smith 175 Thomas Vander Stichele 176 Wim Taymans 177 """)
178
179 - def testFind(self):
180 stdout = StringIO.StringIO() 181 c = cl.ChangeLog(stdout=stdout) 182 ret = c.parse(['-C', self.file, 'find', 'gnomevfs', ]) 183 self.assertEquals(ret, 0) 184 self.assertEquals(stdout.getvalue(), 185 """2006-09-07 Thomas Vander Stichele <thomas at apestaart dot org> 186 187 \tpatch by: Wim Taymans <wim at fluendo dot com> 188 189 \t* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnome_vfs_src_start): 190 \tThis patch removes the RANDOM flag that was incorrectly introduced with 191 \trevision 1.91. Fixes #354590 192 """)
193
194 - def testFindMultiple(self):
195 stdout = StringIO.StringIO() 196 c = cl.ChangeLog(stdout=stdout) 197 ret = c.parse(['-C', self.file, 'find', 'gst', ]) 198 self.assertEquals(ret, 0) 199 self.assertEquals(stdout.getvalue(), 200 """2006-09-07 Thomas Vander Stichele <thomas at apestaart dot org> 201 202 \tpatch by: Michael Smith <msmith at fluendo dot com> 203 204 \t* gst/tcp/gstmultifdsink.c: (is_sync_frame), 205 \t(gst_multi_fd_sink_client_queue_buffer), 206 \t(gst_multi_fd_sink_new_client): 207 \t* tests/check/elements/multifdsink.c: (GST_START_TEST), 208 \t(multifdsink_suite): 209 \t Fix implementation of sync-method 'next-keyframe' 210 \t Closes #354594 211 212 2006-09-07 Thomas Vander Stichele <thomas at apestaart dot org> 213 214 \tpatch by: Wim Taymans <wim at fluendo dot com> 215 216 \t* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnome_vfs_src_start): 217 \tThis patch removes the RANDOM flag that was incorrectly introduced with 218 \trevision 1.91. Fixes #354590 219 """) 220 221 stdout = StringIO.StringIO() 222 c = cl.ChangeLog(stdout=stdout) 223 ret = c.parse(['-C', self.file, 'find', 'gst', 'gnomevfs', ]) 224 self.assertEquals(ret, 0) 225 self.assertEquals(stdout.getvalue(), 226 """2006-09-07 Thomas Vander Stichele <thomas at apestaart dot org> 227 228 \tpatch by: Wim Taymans <wim at fluendo dot com> 229 230 \t* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnome_vfs_src_start): 231 \tThis patch removes the RANDOM flag that was incorrectly introduced with 232 \trevision 1.91. Fixes #354590 233 """) 234 235 stdout = StringIO.StringIO() 236 c = cl.ChangeLog(stdout=stdout) 237 ret = c.parse(['-C', self.file, 'find', 'gst', 'jpegdec', ]) 238 self.assertEquals(ret, 0) 239 self.assertEquals(stdout.getvalue(), "")
240
241 -class TestClGstPluginsBase270(common.TestCase):
242 - def setUp(self):
243 self.file = os.path.join(os.path.dirname(__file__), 'ChangeLog', 244 'ChangeLog.gst-plugins-base.270') 245 self.cl = cl.ChangeLogFile(self.file) 246 self.cl.parse()
247
248 - def testGetContributors(self):
249 e = self.cl.getEntry(0) 250 # because it's written Patch by and not Patch by: it fails to find 251 # contributors 252 self.assertEquals(e.contributors, [])
253
254 - def testFind(self):
255 stdout = StringIO.StringIO() 256 c = cl.ChangeLog(stdout=stdout) 257 ret = c.parse(['-C', self.file, 'find', 'ogg', ]) 258 self.assertEquals(ret, 0) 259 self.assertEquals(stdout.getvalue(), "")
260 261 # In ticket #271, the trailing space in the date/name/address line used to 262 # cause misparsing
263 -class TestClGstPluginsBase271(common.TestCase):
264 - def setUp(self):
265 self.file = os.path.join(os.path.dirname(__file__), 'ChangeLog', 266 'ChangeLog.gst-plugins-base.271') 267 self.cl = cl.ChangeLogFile(self.file) 268 self.cl.parse()
269
270 - def testGetContributors(self):
271 e = self.cl.getEntry(0) 272 self.assertEquals(e.date, "2006-09-29") 273 self.assertEquals(e.name, "Philippe Kalaf") 274 self.assertEquals(e.address, "philippe.kalaf@collabora.co.uk")
275
276 -class TestCheckin(common.SVNTestCase):
277 - def setUp(self):
278 common.SVNTestCase.setUp(self) 279 self.repodir = self.createRepository() 280 self.livedir = self.createLive()
281
282 - def tearDown(self):
283 log.debug('unittest', 'removing temp repodir in %s' % self.repodir) 284 os.system('rm -rf %s' % self.repodir) 285 log.debug('unittest', 'removing temp livedir in %s' % self.livedir) 286 os.system('rm -rf %s' % self.livedir) 287 common.SVNTestCase.tearDown(self)
288
289 - def testCheckinNewDirectory(self):
290 # test a moap cl ci when a parent directory has just been added, 291 # and is not listed in the ChangeLog of course 292 os.system('svn co file://%s %s > /dev/null' % ( 293 self.repodir, self.livedir)) 294 self.liveCreateDirectory('src') 295 self.liveWriteFile('src/test', 'some contents') 296 self.liveWriteFile('ChangeLog', '') 297 os.system('svn add %s > /dev/null' % os.path.join( 298 self.livedir, 'ChangeLog')) 299 os.system('svn add %s > /dev/null' % os.path.join(self.livedir, 'src')) 300 self.liveWriteFile('ChangeLog', """2006-08-15 Thomas Vander Stichele <thomas at apestaart dot org> 301 302 \t* src/test: 303 \t some content 304 """) 305 c = cl.ChangeLog() 306 ret = c.parse(['-C', self.livedir, 'checkin']) 307 self.assertEquals(ret, 0)
308
309 - def testPrepareDiff(self):
310 # Override any externally set CHANGE_LOG_NAME and _EMAIL_ADDRESS 311 os.environ['CHANGE_LOG_NAME'] = 'Hugo van der Hardcore' 312 os.environ['CHANGE_LOG_EMAIL_ADDRESS'] ='hugo@ninenin.jas' 313 314 os.system('svn co file://%s %s > /dev/null' % ( 315 self.repodir, self.livedir)) 316 self.liveWriteFile('ChangeLog', '') 317 os.system('svn add %s > /dev/null' % os.path.join(self.livedir, 318 'ChangeLog')) 319 self.liveWriteFile('test', '') 320 os.system('svn add %s > /dev/null' % os.path.join(self.livedir, 321 'test')) 322 os.system('svn commit -m "add" %s' % 323 os.path.join(self.livedir)) 324 325 self.liveWriteFile('test', 'some contents') 326 327 # FIXME: this fails because an empty ChangeLog causes tracebacks 328 # c = cl.Diff() 329 # print c.do([self.livedir, ]) 330 331 log.debug('unittest', 'moap cl prep -c') 332 c = cl.ChangeLog(stdout=common.FakeStdOut()) 333 c.parse(['-C', self.livedir, 'prepare', '-c', ]) 334 # FIXME: the diff command will diff relative paths; 335 # so running just moap cl diff will not actually change to the repo 336 # path and fail to show diffs 337 oldPath = os.getcwd() 338 os.chdir(self.livedir) 339 log.debug('unittest', 'moap cl diff') 340 stdout = StringIO.StringIO() 341 c = cl.ChangeLog(stdout=stdout) 342 c.parse(['-C', self.livedir, 'diff', ]) 343 os.chdir(oldPath) 344 345 firstline = time.strftime('%Y-%m-%d') + ' ' + \ 346 'Hugo van der Hardcore' + ' <' + 'hugo@ninenin.jas' + '>' 347 expected = firstline + """ 348 349 \treviewed by: <delete if not using a buddy> 350 \tpatch by: <delete if not someone else's patch> 351 352 \t* test: 353 354 Index: test 355 =================================================================== 356 --- test\t(revision 1) 357 +++ test\t(working copy) 358 @@ -0,0 +1 @@ 359 +some contents 360 \ No newline at end of file 361 """ 362 # skip the date 363 l = len("2007-07-30") 364 self.assertEquals(stdout.getvalue()[l:], expected[l:])
365
366 - def testPrepareTagged(self):
367 # test an actual patch set commited to moap to see if 368 # we extract tags correctly. 369 os.system('svn co file://%s %s > /dev/null' % ( 370 self.repodir, self.livedir)) 371 372 # copy and add mail.py 373 file = os.path.join(os.path.dirname(__file__), 'prepare', 374 'mail.py') 375 os.system("cp %s %s" % (file, self.livedir)) 376 codePath = os.path.join(self.livedir, 'mail.py') 377 os.system('svn add %s' % codePath) 378 os.system('svn commit -m "add" %s' % self.livedir) 379 380 # patch it 381 patchPath = os.path.join(os.path.dirname(__file__), 'prepare', 382 'mail.patch') 383 os.system('patch %s < %s' % (codePath, patchPath)) 384 385 # prepare entry 386 log.debug('unittest', 'moap cl prep -c') 387 c = cl.ChangeLog(stdout=common.FakeStdOut()) 388 # try the version of prepare that allows you to pass the path 389 c.parse(['prepare', '-c', self.livedir, ]) 390 391 # now check the fresh ChangeLog entry 392 ChangeLog = os.path.join(self.livedir, "ChangeLog") 393 lines = open(ChangeLog, 'r').readlines() 394 # FIXME: Message.send is in here because the diff marks a line 395 # of whitespace before the new Message.mailto method as added; 396 # we should filter this by parsing the diff better and only looking 397 # for affected tags within blocks of non-whitespace, 398 # or better defining (nested) location (ie, including end) for tags 399 self.assertEquals(lines[5], 400 "\t* mail.py " 401 "(Message.__init__, Message.setFromm, Message.send,\n") 402 self.assertEquals(lines[6], 403 "\t Message.mailto):\n")
404 405
406 -class TestClMoap2(common.TestCase):
407 - def setUp(self):
408 file = os.path.join(os.path.dirname(__file__), 'ChangeLog', 409 'ChangeLog.moap.2') 410 self.cl = cl.ChangeLogFile(file) 411 self.cl.parse()
412
413 - def testGetEntry0(self):
414 e = self.cl.getEntry(0) 415 self.assertEquals(e.date, "2007-03-20") 416 self.assertEquals(e.name, "Thomas Vander Stichele") 417 self.assertEquals(e.address, "thomas at apestaart dot org") 418 self.assertEquals(len(e.files), 7) 419 self.assertEquals(e.files[0], "moap/util/Makefile.am") 420 self.assertEquals(e.files[6], "moap/vcs/vcs.py") 421 # we don't want the empty line because text ends in \n 422 lines = e.text.split("\n")[:-1] 423 self.assertEquals(len(lines), 13)
424
425 - def testFindByVersion(self):
426 searchTerms = ['0.2.1'] 427 entries = self.cl.find(searchTerms) 428 self.assertEquals(len(entries), 2) 429 430 e = entries[0] 431 self.assertEquals(e.version, "0.2.1") 432 433 e = entries[1] 434 self.assertEquals(e.name, "Thomas Vander Stichele") 435 self.assertEquals(e.address, "thomas at apestaart dot org")
436
437 -class TestClNotEdited(common.TestCase):
438 - def setUp(self):
439 file = os.path.join(os.path.dirname(__file__), 'ChangeLog', 440 'ChangeLog.notedited') 441 self.cl = cl.ChangeLogFile(file) 442 self.cl.parse()
443
444 - def testGetBadEntry(self):
445 entry = self.cl.getEntry(0) 446 self.failUnless(isinstance(entry, cl.ChangeEntry)) 447 self.failUnless("mail" in entry.notEdited) 448 self.failUnless("name" in entry.notEdited) 449 self.failUnless("patched by" in entry.notEdited) 450 self.failUnless("reviewer" in entry.notEdited)
451