OLD | NEW |
1 # This file is part of Buildbot. Buildbot is free software: you can | 1 # This file is part of Buildbot. Buildbot is free software: you can |
2 # redistribute it and/or modify it under the terms of the GNU General Public | 2 # redistribute it and/or modify it under the terms of the GNU General Public |
3 # License as published by the Free Software Foundation, version 2. | 3 # License as published by the Free Software Foundation, version 2. |
4 # | 4 # |
5 # This program is distributed in the hope that it will be useful, but WITHOUT | 5 # This program is distributed in the hope that it will be useful, but WITHOUT |
6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
8 # details. | 8 # details. |
9 # | 9 # |
10 # You should have received a copy of the GNU General Public License along with | 10 # You should have received a copy of the GNU General Public License along with |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 self.db.buildsets.completeBuildset(bsid=93, results=6, | 434 self.db.buildsets.completeBuildset(bsid=93, results=6, |
435 _reactor=self.clock)) | 435 _reactor=self.clock)) |
436 def cb(_): | 436 def cb(_): |
437 self.fail("should not succeed") | 437 self.fail("should not succeed") |
438 def eb(f): | 438 def eb(f): |
439 f.trap(KeyError) | 439 f.trap(KeyError) |
440 # pass | 440 # pass |
441 d.addCallbacks(cb, eb) | 441 d.addCallbacks(cb, eb) |
442 return d | 442 return d |
443 | 443 |
| 444 def insert_test_getRecentBuildsets_data(self): |
| 445 return self.insertTestData([ |
| 446 fakedb.Change(changeid=91, branch='branch_a', repository='repo_a'), |
| 447 fakedb.SourceStamp(id=91, branch='branch_a', repository='repo_a'), |
| 448 fakedb.SourceStampChange(sourcestampid=91, changeid=91), |
| 449 |
| 450 fakedb.Buildset(id=91, sourcestampid=91, complete=0, |
| 451 complete_at=298297875, results=-1, submitted_at=266761875, |
| 452 external_idstring='extid', reason='rsn1'), |
| 453 fakedb.Buildset(id=92, sourcestampid=91, complete=1, |
| 454 complete_at=298297876, results=7, submitted_at=266761876, |
| 455 external_idstring='extid', reason='rsn2'), |
| 456 |
| 457 # buildset unrelated to the change |
| 458 fakedb.Buildset(id=93, sourcestampid=1, complete=1, |
| 459 complete_at=298297877, results=7, submitted_at=266761877, |
| 460 external_idstring='extid', reason='rsn2'), |
| 461 ]) |
| 462 |
| 463 def test_getRecentBuildsets_all(self): |
| 464 d = self.insert_test_getRecentBuildsets_data() |
| 465 d.addCallback(lambda _ : |
| 466 self.db.buildsets.getRecentBuildsets(2, branch='branch_a', |
| 467 repository='repo_a')) |
| 468 def check(bsdictlist): |
| 469 self.assertEqual(bsdictlist, [ |
| 470 dict(external_idstring='extid', reason='rsn1', sourcestampid=91, |
| 471 submitted_at=datetime.datetime(1978, 6, 15, 12, 31, 15, |
| 472 tzinfo=UTC), |
| 473 complete_at=datetime.datetime(1979, 6, 15, 12, 31, 15, |
| 474 tzinfo=UTC), |
| 475 complete=False, results=-1, bsid=91), |
| 476 dict(external_idstring='extid', reason='rsn2', sourcestampid=91, |
| 477 submitted_at=datetime.datetime(1978, 6, 15, 12, 31, 16, |
| 478 tzinfo=UTC), |
| 479 complete_at=datetime.datetime(1979, 6, 15, 12, 31, 16, |
| 480 tzinfo=UTC), |
| 481 complete=True, results=7, bsid=92), |
| 482 ]) |
| 483 d.addCallback(check) |
| 484 return d |
| 485 |
| 486 def test_getRecentBuildsets_one(self): |
| 487 d = self.insert_test_getRecentBuildsets_data() |
| 488 d.addCallback(lambda _ : |
| 489 self.db.buildsets.getRecentBuildsets(1, branch='branch_a', |
| 490 repository='repo_a')) |
| 491 def check(bsdictlist): |
| 492 self.assertEqual(bsdictlist, [ |
| 493 dict(external_idstring='extid', reason='rsn2', sourcestampid=91, |
| 494 submitted_at=datetime.datetime(1978, 6, 15, 12, 31, 16, |
| 495 tzinfo=UTC), |
| 496 complete_at=datetime.datetime(1979, 6, 15, 12, 31, 16, |
| 497 tzinfo=UTC), |
| 498 complete=True, results=7, bsid=92), |
| 499 ]) |
| 500 d.addCallback(check) |
| 501 return d |
| 502 |
| 503 def test_getRecentBuildsets_zero(self): |
| 504 d = self.insert_test_getRecentBuildsets_data() |
| 505 d.addCallback(lambda _ : |
| 506 self.db.buildsets.getRecentBuildsets(0, branch='branch_a', |
| 507 repository='repo_a')) |
| 508 def check(bsdictlist): |
| 509 self.assertEqual(bsdictlist, []) |
| 510 d.addCallback(check) |
| 511 return d |
| 512 |
| 513 def test_getRecentBuildsets_noBranchMatch(self): |
| 514 d = self.insert_test_getRecentBuildsets_data() |
| 515 d.addCallback(lambda _ : |
| 516 self.db.buildsets.getRecentBuildsets(2, branch='bad_branch', |
| 517 repository='repo_a')) |
| 518 def check(bsdictlist): |
| 519 self.assertEqual(bsdictlist, []) |
| 520 d.addCallback(check) |
| 521 return d |
| 522 |
| 523 def test_getRecentBuildsets_noRepoMatch(self): |
| 524 d = self.insert_test_getRecentBuildsets_data() |
| 525 d.addCallback(lambda _ : |
| 526 self.db.buildsets.getRecentBuildsets(2, branch='branch_a', |
| 527 repository='bad_repo')) |
| 528 def check(bsdictlist): |
| 529 self.assertEqual(bsdictlist, []) |
| 530 d.addCallback(check) |
| 531 return d |
OLD | NEW |