def test_getLatestRev(self): # First, we need to add a few changes! c1 = Change(who='me!', branch='b1', revision='1', files=[], comments='really important', when=1, revlink='from poller') c2 = Change(who='me!', branch='b2', revision='2', files=[], comments='really important', when=2, revlink='from poller') c3 = Change(who='me!', branch='b1', revision='3', files=[], comments='really important', when=3, revlink='from poller') for c in [c1, c2, c3]: self.dbc.addChangeToDatabase(c) rev = self.dbc.runInteractionNow(lambda t: getLatestRev(self.dbc, t, 'b1', '1', '3')) self.assertEquals(rev, '3') # Revision 2 isn't on branch b1, so revision 1 should be latest rev = self.dbc.runInteractionNow(lambda t: getLatestRev(self.dbc, t, 'b1', '1', '2')) self.assertEquals(rev, '1') # Revision 1 and 1 are the same rev = self.dbc.runInteractionNow(lambda t: getLatestRev(self.dbc, t, 'b1', '1', '1')) self.assertEquals(rev, '1')
def test_getLatestRev(self): # First, we need to add a few changes! c1 = Change(who='me!', branch='b1', revision='1', files=[], comments='really important', when=1, revlink='from poller') c2 = Change(who='me!', branch='b2', revision='2', files=[], comments='really important', when=2, revlink='from poller') c3 = Change(who='me!', branch='b1', revision='3', files=[], comments='really important', when=3, revlink='from poller') for c in [c1, c2, c3]: self.dbc.addChangeToDatabase(c) rev = self.dbc.runInteractionNow( lambda t: getLatestRev(self.dbc, t, 'b1', '1', '3')) self.assertEquals(rev, '3') # Revision 2 isn't on branch b1, so revision 1 should be latest rev = self.dbc.runInteractionNow( lambda t: getLatestRev(self.dbc, t, 'b1', '1', '2')) self.assertEquals(rev, '1') # Revision 1 and 1 are the same rev = self.dbc.runInteractionNow( lambda t: getLatestRev(self.dbc, t, 'b1', '1', '1')) self.assertEquals(rev, '1')
def test_getLatestRev(self): # First, we need to add a few changes! c1 = Change( who="me!", branch="b1", revision="1", files=[], comments="really important", when=1, revlink="from poller" ) c2 = Change( who="me!", branch="b2", revision="2", files=[], comments="really important", when=2, revlink="from poller" ) c3 = Change( who="me!", branch="b1", revision="3", files=[], comments="really important", when=3, revlink="from poller" ) c4 = Change( who="me!", branch="b1", revision="34", files=[], comments="really important", when=1, revlink="from poller" ) for c in [c1, c2, c3, c4]: self.dbc.addChangeToDatabase(c) rev = self.dbc.runInteractionNow(lambda t: getLatestRev(self.dbc, t, "b1", ["1", "3"])) self.assertEquals(rev, "3") # Revision 2 isn't on branch b1, so revision 1 should be latest rev = self.dbc.runInteractionNow(lambda t: getLatestRev(self.dbc, t, "b1", ["1", "2"])) self.assertEquals(rev, "1") # Revision 1 and 1 are the same rev = self.dbc.runInteractionNow(lambda t: getLatestRev(self.dbc, t, "b1", ["1", "1"])) self.assertEquals(rev, "1") # Revision 34 happened before 3 rev = self.dbc.runInteractionNow(lambda t: getLatestRev(self.dbc, t, "b1", ["3", "34"])) self.assertEquals(rev, "3") # Add a new revision beginning with '3' c5 = Change( who="me!", branch="b1", revision="35", files=[], comments="really important", when=4, revlink="from poller" ) self.dbc.addChangeToDatabase(c5) rev = self.dbc.runInteractionNow(lambda t: getLatestRev(self.dbc, t, "b1", ["3", "35"])) self.assertEquals(rev, "35") # revision 35 maches 3%, so it should be latest too even if we don't # ask about it specifically rev = self.dbc.runInteractionNow(lambda t: getLatestRev(self.dbc, t, "b1", ["3", "34"])) self.assertEquals(rev, "35")
def test_getLatestRev(self): # First, we need to add a few changes! c1 = Change(who='me!', branch='b1', revision='1', files=[], comments='really important', when=1, revlink='from poller') c2 = Change(who='me!', branch='b2', revision='2', files=[], comments='really important', when=2, revlink='from poller') c3 = Change(who='me!', branch='b1', revision='3', files=[], comments='really important', when=3, revlink='from poller') c4 = Change(who='me!', branch='b1', revision='34', files=[], comments='really important', when=1, revlink='from poller') for c in [c1, c2, c3, c4]: self.dbc.addChangeToDatabase(c) rev = self.dbc.runInteractionNow( lambda t: getLatestRev(self.dbc, t, 'b1', ['1', '3'])) self.assertEquals(rev, '3') # Revision 2 isn't on branch b1, so revision 1 should be latest rev = self.dbc.runInteractionNow( lambda t: getLatestRev(self.dbc, t, 'b1', ['1', '2'])) self.assertEquals(rev, '1') # Revision 1 and 1 are the same rev = self.dbc.runInteractionNow( lambda t: getLatestRev(self.dbc, t, 'b1', ['1', '1'])) self.assertEquals(rev, '1') # Revision 34 happened before 3 rev = self.dbc.runInteractionNow( lambda t: getLatestRev(self.dbc, t, 'b1', ['3', '34'])) self.assertEquals(rev, '3') # Add a new revision beginning with '3' c5 = Change(who='me!', branch='b1', revision='35', files=[], comments='really important', when=4, revlink='from poller') self.dbc.addChangeToDatabase(c5) rev = self.dbc.runInteractionNow( lambda t: getLatestRev(self.dbc, t, 'b1', ['3', '35'])) self.assertEquals(rev, '35') # revision 35 maches 3%, so it should be latest too even if we don't # ask about it specifically rev = self.dbc.runInteractionNow( lambda t: getLatestRev(self.dbc, t, 'b1', ['3', '34'])) self.assertEquals(rev, '35')