Chromium Code Reviews| 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 | 440 |
| 441 def test_meta_name(self): | 441 def test_meta_name(self): |
| 442 """Tests that the meta name tag is added and correct.""" | 442 """Tests that the meta name tag is added and correct.""" |
| 443 chrome_app_manifest = {'name': 'a náme'} | 443 chrome_app_manifest = {'name': 'a náme'} |
| 444 root_path = 'path' | 444 root_path = 'path' |
| 445 caterpillar.inject_misc_tags(self.soup, chrome_app_manifest, root_path, '') | 445 caterpillar.inject_misc_tags(self.soup, chrome_app_manifest, root_path, '') |
| 446 meta = self.soup.find('meta', {'name': 'name'}) | 446 meta = self.soup.find('meta', {'name': 'name'}) |
| 447 self.assertIsNotNone(meta) | 447 self.assertIsNotNone(meta) |
| 448 self.assertEqual(meta['content'], chrome_app_manifest['name']) | 448 self.assertEqual(meta['content'], chrome_app_manifest['name']) |
| 449 | 449 |
| 450 def test_no_head(self): | |
| 451 """Tests that the manifest link tag is added even with no head.""" | |
| 452 chrome_app_manifest = {} | |
| 453 root_path = 'path' | |
| 454 html = """ | |
|
Matt Giuca
2016/01/29 02:19:26
"""\
Matthew Alger
2016/01/29 02:41:51
Done.
| |
| 455 <!DOCTYPE html> | |
| 456 <html> | |
| 457 <body> | |
| 458 <h1> | |
| 459 Héllo, World! ÚÑÍ¢ÓÐÉ | |
| 460 </h1> | |
| 461 </body> | |
| 462 </html>""" | |
| 463 soup = bs4.BeautifulSoup(html, 'html.parser') | |
| 464 caterpillar.inject_misc_tags(soup, chrome_app_manifest, root_path, '') | |
| 465 link = soup.find('link', rel='manifest') | |
|
Matt Giuca
2016/01/29 02:19:26
Again, I think you should match the entire file, n
Matthew Alger
2016/01/29 02:41:51
Done.
| |
| 466 self.assertIsNotNone(link) | |
| 467 self.assertEqual(link['href'], | |
| 468 os.path.join(root_path, 'manifest.webmanifest')) | |
| 469 self.assertIsNotNone(soup.find('head')) | |
| 470 | |
| 471 def test_no_head_or_html(self): | |
| 472 """Tests that the manifest link tag is added with no head or html tags.""" | |
| 473 chrome_app_manifest = {} | |
| 474 root_path = 'path' | |
| 475 html = """ | |
| 476 <!DOCTYPE html> | |
| 477 <body> | |
| 478 <h1> | |
| 479 Héllo, World! ÚÑÍ¢ÓÐÉ | |
| 480 </h1> | |
| 481 </body>""" | |
| 482 soup = bs4.BeautifulSoup(html, 'html.parser') | |
| 483 caterpillar.inject_misc_tags(soup, chrome_app_manifest, root_path, '') | |
| 484 link = soup.find('link', rel='manifest') | |
| 485 self.assertIsNotNone(link) | |
| 486 self.assertEqual(link['href'], | |
| 487 os.path.join(root_path, 'manifest.webmanifest')) | |
| 488 self.assertIsNotNone(soup.find('head')) | |
| 489 | |
| 450 | 490 |
| 451 class TestInsertTodosIntoFile(TestCaseWithTempDir): | 491 class TestInsertTodosIntoFile(TestCaseWithTempDir): |
| 452 """Tests insert_todos_into_file.""" | 492 """Tests insert_todos_into_file.""" |
| 453 | 493 |
| 454 def test_no_todos(self): | 494 def test_no_todos(self): |
| 455 """Tests that if there are no TODOs to add, nothing is changed.""" | 495 """Tests that if there are no TODOs to add, nothing is changed.""" |
| 456 js = """// héllo world | 496 js = """// héllo world |
| 457 unrelated.app.call();""" | 497 unrelated.app.call();""" |
| 458 filename = 'test.js' | 498 filename = 'test.js' |
| 459 filepath = os.path.join(self.temp_path, filename) | 499 filepath = os.path.join(self.temp_path, filename) |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 } | 652 } |
| 613 caterpillar.edit_code(self.output_path, [], chrome_app_manifest, | 653 caterpillar.edit_code(self.output_path, [], chrome_app_manifest, |
| 614 {'boilerplate_dir': BOILERPLATE_DIR}) | 654 {'boilerplate_dir': BOILERPLATE_DIR}) |
| 615 with codecs.open(os.path.join(self.output_path, 'my índex.html'), | 655 with codecs.open(os.path.join(self.output_path, 'my índex.html'), |
| 616 encoding='utf-8') as js_file: | 656 encoding='utf-8') as js_file: |
| 617 self.assertIn('<meta content="test233" name="name"', js_file.read()) | 657 self.assertIn('<meta content="test233" name="name"', js_file.read()) |
| 618 | 658 |
| 619 | 659 |
| 620 if __name__ == '__main__': | 660 if __name__ == '__main__': |
| 621 unittest.main() | 661 unittest.main() |
| OLD | NEW |