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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 'app': {'background': {}}, | 610 'app': {'background': {}}, |
610 'name': 'test233' | 611 'name': 'test233' |
611 } | 612 } |
612 caterpillar.edit_code(self.output_path, [], chrome_app_manifest, | 613 caterpillar.edit_code(self.output_path, [], chrome_app_manifest, |
613 {'boilerplate_dir': BOILERPLATE_DIR}) | 614 {'boilerplate_dir': BOILERPLATE_DIR}) |
614 with codecs.open(os.path.join(self.output_path, 'my índex.html'), | 615 with codecs.open(os.path.join(self.output_path, 'my índex.html'), |
615 encoding='utf-8') as js_file: | 616 encoding='utf-8') as js_file: |
616 self.assertIn('<meta content="test233" name="name"', js_file.read()) | 617 self.assertIn('<meta content="test233" name="name"', js_file.read()) |
617 | 618 |
618 | 619 |
620 class TestAddAppInfo(TestCaseWithOutputDir): | |
621 """Tests add_app_info.""" | |
622 | |
623 def test_add_app_info(self): | |
624 """Tests add_app_info writes the correct file.""" | |
625 chrome_app_manifest = { | |
626 'app': {'background': {}}, | |
627 'name': 'tést app', | |
628 } | |
629 config = { | |
630 'id': 'asaasdásdasdasddsadsad', | |
631 } | |
632 | |
633 caterpillar.add_app_info(self.output_path, chrome_app_manifest, config) | |
634 | |
635 with open(os.path.join(self.output_path, 'app.info.js')) as app_info_file: | |
636 app_info_js = app_info_file.read().decode('utf-8') | |
637 | |
638 self.assertEqual(app_info_js, """chrome.caterpillar.manifest = { | |
Matt Giuca
2016/01/28 07:33:22
"""\
Start on the next line.
Matthew Alger
2016/01/28 23:24:45
Done.
| |
639 'app': { | |
640 'background': {} | |
641 }, | |
642 'name': 't\\u00e9st app' | |
643 }; | |
644 chrome.caterpillar.appId = 'asaasdásdasdasddsadsad'; | |
645 """) | |
646 | |
647 | |
619 if __name__ == '__main__': | 648 if __name__ == '__main__': |
620 unittest.main() | 649 unittest.main() |
OLD | NEW |