| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import unittest |
| 6 |
| 7 import infra.services.bugdroid.log_parser as log_parser |
| 8 |
| 9 |
| 10 class BugLineParserTest(unittest.TestCase): |
| 11 def test_matching_bug(self): |
| 12 for bug, bug_line in [ |
| 13 # Keep distinct bug numbers for easy search in case of test failures. |
| 14 (123, 'BUG=123'), |
| 15 (124, 'Bug: 124'), |
| 16 ('chromium:125', 'Bugs: chromium:125'), |
| 17 ]: |
| 18 m = log_parser.BUG_LINE_REGEX.match(bug_line) |
| 19 self.assertIsNotNone(m, '"%s" line must be matched' % bug_line) |
| 20 self.assertEqual(m.groups()[-1], str(bug), |
| 21 '"%s" line matched to %s but %s expected.' % ( |
| 22 bug_line, m.groups()[-1], str(bug))) |
| 23 |
| 24 def test_not_matching_bug(self): |
| 25 for bug_line in [ |
| 26 # Keep distinct bug numbers for easy search in case of test failures. |
| 27 'BUGr=123', |
| 28 'BUGS/124', |
| 29 'someBugs:', |
| 30 ]: |
| 31 m = log_parser.BUG_LINE_REGEX.match(bug_line) |
| 32 self.assertIsNone(m, '"%s" line must not be matched (got %s)' % |
| 33 (bug_line, m.groups()) if m else None) |
| 34 |
| 35 |
| 36 if __name__ == "__main__": |
| 37 unittest.main() |
| OLD | NEW |