Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Unified Diff: src/caterpillar_test.py

Issue 1644543005: inject_misc_tags no longer fails if document has no head. Resolves #16. (Closed) Base URL: git@github.com:chromium/caterpillar.git@master
Patch Set: Response to CR + tests Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/caterpillar.py ('K') | « src/caterpillar.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/caterpillar_test.py
diff --git a/src/caterpillar_test.py b/src/caterpillar_test.py
index 7ae50ff8e5beea0534d317deabb129782c30abbd..ff68bc3debf8f51f0ed282fd2ede4f1f97682a7f 100755
--- a/src/caterpillar_test.py
+++ b/src/caterpillar_test.py
@@ -447,6 +447,46 @@ class TestInjectMiscTags(unittest.TestCase):
self.assertIsNotNone(meta)
self.assertEqual(meta['content'], chrome_app_manifest['name'])
+ def test_no_head(self):
+ """Tests that the manifest link tag is added even with no head."""
+ chrome_app_manifest = {}
+ root_path = 'path'
+ html = """
Matt Giuca 2016/01/29 02:19:26 """\
Matthew Alger 2016/01/29 02:41:51 Done.
+<!DOCTYPE html>
+<html>
+ <body>
+ <h1>
+ Héllo, World! ÚÑÍ¢ÓÐÉ
+ </h1>
+ </body>
+</html>"""
+ soup = bs4.BeautifulSoup(html, 'html.parser')
+ caterpillar.inject_misc_tags(soup, chrome_app_manifest, root_path, '')
+ 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.
+ self.assertIsNotNone(link)
+ self.assertEqual(link['href'],
+ os.path.join(root_path, 'manifest.webmanifest'))
+ self.assertIsNotNone(soup.find('head'))
+
+ def test_no_head_or_html(self):
+ """Tests that the manifest link tag is added with no head or html tags."""
+ chrome_app_manifest = {}
+ root_path = 'path'
+ html = """
+<!DOCTYPE html>
+<body>
+<h1>
+ Héllo, World! ÚÑÍ¢ÓÐÉ
+</h1>
+</body>"""
+ soup = bs4.BeautifulSoup(html, 'html.parser')
+ caterpillar.inject_misc_tags(soup, chrome_app_manifest, root_path, '')
+ link = soup.find('link', rel='manifest')
+ self.assertIsNotNone(link)
+ self.assertEqual(link['href'],
+ os.path.join(root_path, 'manifest.webmanifest'))
+ self.assertIsNotNone(soup.find('head'))
+
class TestInsertTodosIntoFile(TestCaseWithTempDir):
"""Tests insert_todos_into_file."""
« src/caterpillar.py ('K') | « src/caterpillar.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698