| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import io | 6 import io |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| 11 sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), | 11 sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| 12 "..", "..", "..", "public", "tools", | 12 "..", "..", "..", "public", "tools", |
| 13 "mojom_fetcher")) | 13 "mojom_fetcher")) |
| 14 sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), | 14 sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| 15 "..", "..", "..", "public", "tools", | 15 "..", "..", "..", "public", "tools", |
| 16 "mojom_fetcher", "pylib")) | 16 "mojom_fetcher", "pylib")) |
| 17 sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), | 17 sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| 18 "..", "..", "..", "public", "tools", | 18 "..", "..", "..", "public", "tools", |
| 19 "bindings", "pylib")) | 19 "bindings", "pylib")) |
| 20 | 20 |
| 21 from mojom_fetcher import UrlRewriter, UrlRewriterException, MojomFetcher | 21 from mojom_fetcher import UrlRewriter, UrlRewriterException, MojomFetcher |
| 22 | 22 |
| 23 # Fake repository for testing | 23 # Fake repository for testing |
| 24 from fake_repository import FakeRepository | 24 from fakes import FakeRepository |
| 25 | 25 |
| 26 class TestUrlRewriter(unittest.TestCase): | 26 class TestUrlRewriter(unittest.TestCase): |
| 27 def test_no_transitive(self): | 27 def test_no_transitive(self): |
| 28 rules = {"foo.com": "bar.com/foo", "bar.com": "baz.com"} | 28 rules = {"foo.com": "bar.com/foo", "bar.com": "baz.com"} |
| 29 try: | 29 try: |
| 30 UrlRewriter(rules) | 30 UrlRewriter(rules) |
| 31 self.fail() | 31 self.fail() |
| 32 except UrlRewriterException: | 32 except UrlRewriterException: |
| 33 # This is expected | 33 # This is expected |
| 34 pass | 34 pass |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 "https://services.fiz.org/foo/bar.mojom"], | 99 "https://services.fiz.org/foo/bar.mojom"], |
| 100 self.fetcher.downloaded_urls) | 100 self.fetcher.downloaded_urls) |
| 101 | 101 |
| 102 if __name__ == '__main__': | 102 if __name__ == '__main__': |
| 103 loader = unittest.defaultTestLoader | 103 loader = unittest.defaultTestLoader |
| 104 runner = unittest.TextTestRunner() | 104 runner = unittest.TextTestRunner() |
| 105 directory = os.path.dirname(os.path.abspath(__file__)) | 105 directory = os.path.dirname(os.path.abspath(__file__)) |
| 106 suite = loader.discover(directory, '*_tests.py') | 106 suite = loader.discover(directory, '*_tests.py') |
| 107 runner.run(suite) | 107 runner.run(suite) |
| 108 | 108 |
| OLD | NEW |