Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 from datetime import datetime | |
| 7 from datetime import timedelta | |
| 8 import time | |
| 9 import unittest | |
| 10 | |
| 11 | |
| 12 from test_expectations_history import TestExpectationsHistory | |
| 13 | |
| 14 | |
| 15 class TestTestExpectaionsHistory(unittest.TestCase): | |
|
dennis_jeffrey
2011/08/26 19:01:26
'TestTestExpectaionsHistory' -->
'TestTestExpectat
imasaki1
2011/08/26 22:28:44
Done.
| |
| 16 """Unit tests for the TestExpectationsHistory class.""" | |
| 17 | |
| 18 def AssertTestName(self, result_list, testname): | |
| 19 """Assert test name in the result_list. | |
| 20 | |
| 21 Args: | |
| 22 result_list: a result list of tuples returned by | |
| 23 |GetDiffBetweenTimesOnly1Diff()|. Each tuple consists of | |
| 24 (old_rev, new_rev, author, date, message, lines) where | |
| 25 |lines| are the entries in the test expectation file. | |
| 26 testname: a testname string. | |
| 27 | |
| 28 Returns: | |
| 29 True if the result contains the testname, False otherwise. | |
| 30 """ | |
| 31 for (_, _, _, _, _, lines) in result_list: | |
| 32 if any([testname in line for line in lines]): | |
| 33 return True | |
| 34 return False | |
| 35 | |
| 36 def testGetDiffBetweenTimes(self): | |
| 37 t = (2011, 8, 20, 0, 0, 0, 0, 0, 0) | |
| 38 ctime = time.mktime(t) | |
| 39 t = (2011, 8, 19, 0, 0, 0, 0, 0, 0) | |
| 40 ptime = time.mktime(t) | |
| 41 testname = 'fast/css/getComputedStyle/computed-style-without-renderer.html' | |
| 42 testname_list = [testname] | |
| 43 result_list = TestExpectationsHistory.GetDiffBetweenTimes( | |
| 44 ctime, ptime, testname_list) | |
| 45 self.assertTrue(self.AssertTestName(result_list, testname)) | |
| 46 | |
| 47 def testGetDiffBetweenTimesOnly1Diff(self): | |
| 48 ptime = datetime.strptime('2011-08-19-23', '%Y-%m-%d-%H') | |
| 49 ptime = time.mktime(ptime.timetuple()) | |
| 50 ctime = datetime.strptime('2011-08-20-00', '%Y-%m-%d-%H') | |
| 51 ctime = time.mktime(ctime.timetuple()) | |
| 52 testname = 'fast/css/getComputedStyle/computed-style-without-renderer.html' | |
| 53 testname_list = [testname] | |
| 54 result_list = TestExpectationsHistory.GetDiffBetweenTimes( | |
| 55 ctime, ptime, testname_list) | |
| 56 self.assertTrue(self.AssertTestName(result_list, testname)) | |
| 57 | |
| 58 | |
| 59 if __name__ == '__main__': | |
| 60 unittest.main() | |
| OLD | NEW |