Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py

Issue 302283005: Backported getRecentBuildsets from buildbot 0.8.8 (to use it in RietveldPollerWithCache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/buildbot_8_4p1/buildbot/db/buildsets.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py
diff --git a/third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py b/third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py
index a6d4253cae43572992eac8d73b24cead97f63d9e..d28bcc61a72fd875af51c533b4ae189172225041 100644
--- a/third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py
+++ b/third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py
@@ -441,3 +441,91 @@ class TestBuildsetsConnectorComponent(
d.addCallbacks(cb, eb)
return d
+ def insert_test_getRecentBuildsets_data(self):
+ return self.insertTestData([
+ fakedb.Change(changeid=91, branch='branch_a', repository='repo_a'),
+ fakedb.SourceStamp(id=91, branch='branch_a', repository='repo_a'),
+ fakedb.SourceStampChange(sourcestampid=91, changeid=91),
+
+ fakedb.Buildset(id=91, sourcestampid=91, complete=0,
+ complete_at=298297875, results=-1, submitted_at=266761875,
+ external_idstring='extid', reason='rsn1'),
+ fakedb.Buildset(id=92, sourcestampid=91, complete=1,
+ complete_at=298297876, results=7, submitted_at=266761876,
+ external_idstring='extid', reason='rsn2'),
+
+ # buildset unrelated to the change
+ fakedb.Buildset(id=93, sourcestampid=1, complete=1,
+ complete_at=298297877, results=7, submitted_at=266761877,
+ external_idstring='extid', reason='rsn2'),
+ ])
+
+ def test_getRecentBuildsets_all(self):
+ d = self.insert_test_getRecentBuildsets_data()
+ d.addCallback(lambda _ :
+ self.db.buildsets.getRecentBuildsets(2, branch='branch_a',
+ repository='repo_a'))
+ def check(bsdictlist):
+ self.assertEqual(bsdictlist, [
+ dict(external_idstring='extid', reason='rsn1', sourcestampid=91,
+ submitted_at=datetime.datetime(1978, 6, 15, 12, 31, 15,
+ tzinfo=UTC),
+ complete_at=datetime.datetime(1979, 6, 15, 12, 31, 15,
+ tzinfo=UTC),
+ complete=False, results=-1, bsid=91),
+ dict(external_idstring='extid', reason='rsn2', sourcestampid=91,
+ submitted_at=datetime.datetime(1978, 6, 15, 12, 31, 16,
+ tzinfo=UTC),
+ complete_at=datetime.datetime(1979, 6, 15, 12, 31, 16,
+ tzinfo=UTC),
+ complete=True, results=7, bsid=92),
+ ])
+ d.addCallback(check)
+ return d
+
+ def test_getRecentBuildsets_one(self):
+ d = self.insert_test_getRecentBuildsets_data()
+ d.addCallback(lambda _ :
+ self.db.buildsets.getRecentBuildsets(1, branch='branch_a',
+ repository='repo_a'))
+ def check(bsdictlist):
+ self.assertEqual(bsdictlist, [
+ dict(external_idstring='extid', reason='rsn2', sourcestampid=91,
+ submitted_at=datetime.datetime(1978, 6, 15, 12, 31, 16,
+ tzinfo=UTC),
+ complete_at=datetime.datetime(1979, 6, 15, 12, 31, 16,
+ tzinfo=UTC),
+ complete=True, results=7, bsid=92),
+ ])
+ d.addCallback(check)
+ return d
+
+ def test_getRecentBuildsets_zero(self):
+ d = self.insert_test_getRecentBuildsets_data()
+ d.addCallback(lambda _ :
+ self.db.buildsets.getRecentBuildsets(0, branch='branch_a',
+ repository='repo_a'))
+ def check(bsdictlist):
+ self.assertEqual(bsdictlist, [])
+ d.addCallback(check)
+ return d
+
+ def test_getRecentBuildsets_noBranchMatch(self):
+ d = self.insert_test_getRecentBuildsets_data()
+ d.addCallback(lambda _ :
+ self.db.buildsets.getRecentBuildsets(2, branch='bad_branch',
+ repository='repo_a'))
+ def check(bsdictlist):
+ self.assertEqual(bsdictlist, [])
+ d.addCallback(check)
+ return d
+
+ def test_getRecentBuildsets_noRepoMatch(self):
+ d = self.insert_test_getRecentBuildsets_data()
+ d.addCallback(lambda _ :
+ self.db.buildsets.getRecentBuildsets(2, branch='branch_a',
+ repository='bad_repo'))
+ def check(bsdictlist):
+ self.assertEqual(bsdictlist, [])
+ d.addCallback(check)
+ return d
« no previous file with comments | « third_party/buildbot_8_4p1/buildbot/db/buildsets.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698