Beispiel #1
0
 def testSort(self):
   s = lkgr_lib.SvnWrapper(self.url, None)
   revs = [(4567, 'foo'), (2345, 'bar'), (6789, 'baz')]
   res = s.sort(revs, keyfunc=lambda x: x[0])
   self.assertEquals(res, [(2345, 'bar'), (4567, 'foo'), (6789, 'baz')])
Beispiel #2
0
class FindLKGRCandidateTest(unittest.TestCase):
  status_stub = StatusGeneratorStub()
  good = lkgr_lib.STATUS.SUCCESS
  fail = lkgr_lib.STATUS.FAILURE
  keyfunc = lkgr_lib.SvnWrapper(None, None).keyfunc

  def testSimpleSucceeds(self):
    build_history = {'m1': {'b1': [(1, self.good, 1)]}}
    revisions = [1]
    candidate = lkgr_lib.FindLKGRCandidate(
        build_history, revisions, self.keyfunc, self.status_stub)
    self.assertEquals(candidate, 1)

  def testSimpleFails(self):
    build_history = {'m1': {'b1': [(1, self.fail, 1)]}}
    revisions = [1]
    candidate = lkgr_lib.FindLKGRCandidate(
        build_history, revisions, self.keyfunc, self.status_stub)
    self.assertEquals(candidate, None)

  def testModerateSuccess(self):
    build_history = {
        'm1': {'b1': [(1, self.good, 1)]},
        'm2': {'b2': [(1, self.good, 1)]}}
    revisions = [1]
    candidate = lkgr_lib.FindLKGRCandidate(
        build_history, revisions, self.keyfunc, self.status_stub)
    self.assertEquals(candidate, 1)

  def testModerateFailsOne(self):
    build_history = {
        'm1': {'b1': [(1, self.good, 1)]},
        'm2': {'b2': [(1, self.fail, 1)]}}
    revisions = [1]
    candidate = lkgr_lib.FindLKGRCandidate(
        build_history, revisions, self.keyfunc, self.status_stub)
    self.assertEquals(candidate, None)

  def testModerateFailsTwo(self):
    build_history = {
        'm1': {'b1': [(1, self.fail, 1)]},
        'm2': {'b2': [(1, self.good, 1)]}}
    revisions = [1]
    candidate = lkgr_lib.FindLKGRCandidate(
        build_history, revisions, self.keyfunc, self.status_stub)
    self.assertEquals(candidate, None)

  def testMultipleRevHistory(self):
    build_history = {
        'm1': {'b1': [(1, self.fail, 1), (2, self.good, 2),
                      (3, self.fail, 3), (4, self.good, 4)]},
        'm2': {'b2': [(1, self.fail, 1), (2, self.fail, 2),
                      (3, self.good, 3), (4, self.good, 4)]}}
    revisions = [1, 2, 3, 4]
    candidate = lkgr_lib.FindLKGRCandidate(
        build_history, revisions, self.keyfunc, self.status_stub)
    self.assertEquals(candidate, 4)

  def testMultipleSuccess(self):
    build_history = {
        'm1': {'b1': [(1, self.fail, 1), (2, self.good, 2),
                      (3, self.fail, 3), (4, self.good, 4), (5, self.good, 5)]},
        'm2': {'b2': [(1, self.fail, 1), (2, self.fail, 2),
                      (3, self.good, 3), (4, self.good, 4), (5, self.good, 5)]}}
    revisions = [1, 2, 3, 4, 5]
    candidate = lkgr_lib.FindLKGRCandidate(
        build_history, revisions, self.keyfunc, self.status_stub)
    self.assertEquals(candidate, 5)

  def testMissingFails(self):
    build_history = {
        'm1': {'b1': [(1, self.fail, 1), (2, self.good, 2),
                      (3, self.fail, 3), (5, self.good, 5)]},
        'm2': {'b2': [(1, self.fail, 1), (2, self.fail, 2),
                      (3, self.good, 3), (4, self.good, 4)]}}
    revisions = [1, 2, 3, 4, 5]
    candidate = lkgr_lib.FindLKGRCandidate(
        build_history, revisions, self.keyfunc, self.status_stub)
    self.assertEquals(candidate, None)

  def testMissingSuccess(self):
    build_history = {
        'm1': {'b1': [(1, self.fail, 1), (2, self.good, 2),
                      (3, self.fail, 3), (5, self.good, 5)]},
        'm2': {'b2': [(1, self.fail, 1), (2, self.fail, 2),
                      (3, self.good, 3), (4, self.good, 4), (6, self.good, 6)]}}
    revisions = [1, 2, 3, 4, 5, 6]
    candidate = lkgr_lib.FindLKGRCandidate(
        build_history, revisions, self.keyfunc, self.status_stub)
    self.assertEquals(candidate, 5)
Beispiel #3
0
 def testKeyfuncFails(self):
   s = lkgr_lib.SvnWrapper(self.url, None)
   res = s.keyfunc('deadbeef')
   self.assertEquals(res, None)
Beispiel #4
0
 def testKeyfuncSucceeds(self):
   s = lkgr_lib.SvnWrapper(self.url, None)
   res = s.keyfunc(12345)
   self.assertEquals(res, 12345)
Beispiel #5
0
 def testCheckRevNOREVFails(self):
   s = lkgr_lib.SvnWrapper(self.url, None)
   res = s.check_rev(lkgr_lib.NOREV)
   self.assertFalse(res)
Beispiel #6
0
 def testCheckRevFails(self):
   s = lkgr_lib.SvnWrapper(self.url, None)
   res = s.check_rev('deadbeef')
   self.assertFalse(res)
Beispiel #7
0
 def testCheckRevStringSucceeds(self):
   s = lkgr_lib.SvnWrapper(self.url, None)
   res = s.check_rev('12345')
   self.assertTrue(res)