| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2016 Google Inc. |
| 3 # |
| 4 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 # you may not use this file except in compliance with the License. |
| 6 # You may obtain a copy of the License at |
| 7 # |
| 8 # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 # |
| 10 # Unless required by applicable law or agreed to in writing, software |
| 11 # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 # See the License for the specific language governing permissions and |
| 14 # limitations under the License. |
| 15 |
| 16 """Tests for utils.""" |
| 17 |
| 18 import unittest |
| 19 |
| 20 import setup |
| 21 setup.process_args() |
| 22 |
| 23 from codereview import utils |
| 24 |
| 25 |
| 26 class UtilsTest(unittest.TestCase): |
| 27 def test_parse_cq_status_url_message_v2(self): |
| 28 url = ('https://chromium-cq-status.appspot.com/v2/' |
| 29 'patch-status/codereview.chromium.org/213/1') |
| 30 msg = 'CQ is trying da patch. Follow status at\n' + url |
| 31 self.assertEqual(utils.parse_cq_status_url_message(msg), (url, 213, 1)) |
| 32 msg += '\n' |
| 33 self.assertEqual(utils.parse_cq_status_url_message(msg), (url, 213, 1)) |
| 34 msg = 'Dry run: ' + msg |
| 35 self.assertEqual(utils.parse_cq_status_url_message(msg), (url, 213, 1)) |
| 36 |
| 37 def test_parse_cq_status_url_message_v1(self): |
| 38 url = 'https://chromium-cq-status.appspot.com/patch-status/213/1' |
| 39 msg = 'CQ is trying da patch. Follow status at\n' + url |
| 40 self.assertEqual(utils.parse_cq_status_url_message(msg), (url, 213, 1)) |
| 41 msg += '\n' |
| 42 self.assertEqual(utils.parse_cq_status_url_message(msg), (url, 213, 1)) |
| 43 msg = 'Dry run: ' + msg |
| 44 self.assertEqual(utils.parse_cq_status_url_message(msg), (url, 213, 1)) |
| 45 |
| 46 def test_parse_cq_status_url_message_fail(self): |
| 47 self.assertEqual(utils.parse_cq_status_url_message(''), (None, None, None)) |
| 48 msg = 'Dry run failed because https://weird.url/patch-status/123/4' |
| 49 self.assertEqual(utils.parse_cq_status_url_message(msg), (None, None, None)) |
| 50 |
| 51 |
| 52 if __name__ == '__main__': |
| 53 unittest.main() |
| OLD | NEW |