| OLD | NEW |
| 1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
| 2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
| 3 | 3 |
| 4 # Copyright 2016 Google Inc. All Rights Reserved. | 4 # Copyright 2016 Google Inc. All Rights Reserved. |
| 5 # | 5 # |
| 6 # Licensed under the Apache License, Version 2.0 (the "License"); | 6 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 # you may not use this file except in compliance with the License. | 7 # you may not use this file except in compliance with the License. |
| 8 # You may obtain a copy of the License at | 8 # You may obtain a copy of the License at |
| 9 # | 9 # |
| 10 # http://www.apache.org/licenses/LICENSE-2.0 | 10 # http://www.apache.org/licenses/LICENSE-2.0 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 """Base test case for tests that require an output web app directory.""" | 59 """Base test case for tests that require an output web app directory.""" |
| 60 | 60 |
| 61 def setUp(self): | 61 def setUp(self): |
| 62 """Makes a temporary output directory and stores it in self.output_path. | 62 """Makes a temporary output directory and stores it in self.output_path. |
| 63 """ | 63 """ |
| 64 super(TestCaseWithOutputDir, self).setUp() | 64 super(TestCaseWithOutputDir, self).setUp() |
| 65 self.output_path = os.path.join(self.temp_path, MINIMAL_APP_NAME) | 65 self.output_path = os.path.join(self.temp_path, MINIMAL_APP_NAME) |
| 66 caterpillar.setup_output_dir(MINIMAL_PATH, self.output_path, | 66 caterpillar.setup_output_dir(MINIMAL_PATH, self.output_path, |
| 67 BOILERPLATE_DIR) | 67 BOILERPLATE_DIR) |
| 68 | 68 |
| 69 |
| 69 # Test cases. | 70 # Test cases. |
| 70 | 71 |
| 71 | 72 |
| 72 class TestSetupOutputDir(TestCaseWithTempDir): | 73 class TestSetupOutputDir(TestCaseWithTempDir): |
| 73 """Tests setup_output_dir.""" | 74 """Tests setup_output_dir.""" |
| 74 | 75 |
| 75 def setUp(self): | 76 def setUp(self): |
| 76 """Makes a path to an output web app and stores it in self.output_path.""" | 77 """Makes a path to an output web app and stores it in self.output_path.""" |
| 77 super(TestSetupOutputDir, self).setUp() | 78 super(TestSetupOutputDir, self).setUp() |
| 78 self.output_path = os.path.join(self.temp_path, MINIMAL_APP_NAME) | 79 self.output_path = os.path.join(self.temp_path, MINIMAL_APP_NAME) |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 'app': {'background': {}}, | 611 'app': {'background': {}}, |
| 611 'name': 'test233' | 612 'name': 'test233' |
| 612 } | 613 } |
| 613 caterpillar.edit_code(self.output_path, [], chrome_app_manifest, | 614 caterpillar.edit_code(self.output_path, [], chrome_app_manifest, |
| 614 {'boilerplate_dir': BOILERPLATE_DIR}) | 615 {'boilerplate_dir': BOILERPLATE_DIR}) |
| 615 with codecs.open(os.path.join(self.output_path, 'my índex.html'), | 616 with codecs.open(os.path.join(self.output_path, 'my índex.html'), |
| 616 encoding='utf-8') as js_file: | 617 encoding='utf-8') as js_file: |
| 617 self.assertIn('<meta content="test233" name="name"', js_file.read()) | 618 self.assertIn('<meta content="test233" name="name"', js_file.read()) |
| 618 | 619 |
| 619 | 620 |
| 621 class TestAddAppInfo(TestCaseWithOutputDir): |
| 622 """Tests add_app_info.""" |
| 623 |
| 624 def test_add_app_info(self): |
| 625 """Tests add_app_info writes the correct file.""" |
| 626 chrome_app_manifest = { |
| 627 'app': {'background': {}}, |
| 628 'name': 'tést app', |
| 629 } |
| 630 |
| 631 caterpillar.add_app_info(self.output_path, chrome_app_manifest) |
| 632 |
| 633 with open(os.path.join(self.output_path, 'app.info.js')) as app_info_file: |
| 634 app_info_js = app_info_file.read().decode('utf-8') |
| 635 |
| 636 self.assertEqual(app_info_js, """\ |
| 637 chrome.caterpillar.manifest = { |
| 638 'app': { |
| 639 'background': {} |
| 640 }, |
| 641 'name': 't\\u00e9st app' |
| 642 }; |
| 643 """) |
| 644 |
| 645 |
| 620 if __name__ == '__main__': | 646 if __name__ == '__main__': |
| 621 unittest.main() | 647 unittest.main() |
| OLD | NEW |