diff options
author | Erik Johnston <erikj@jki.re> | 2016-12-15 10:01:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-15 10:01:28 +0000 |
commit | 4da3fc0ea070ad54e323c27f22cc67a5965ebd1a (patch) | |
tree | fadb35dae7b6276937c0e88f0415aa3d52fb88f0 /tests/test_preview.py | |
parent | Fixup membership query (diff) | |
parent | Fix crash in url preview when html tag has no text (diff) | |
download | synapse-4da3fc0ea070ad54e323c27f22cc67a5965ebd1a.tar.xz |
Merge pull request #1701 from mbachry/fix-preview-crash
Fix crash in url preview
Diffstat (limited to 'tests/test_preview.py')
-rw-r--r-- | tests/test_preview.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/test_preview.py b/tests/test_preview.py index ffa52e5dd4..5bd36c74aa 100644 --- a/tests/test_preview.py +++ b/tests/test_preview.py @@ -215,3 +215,53 @@ class PreviewUrlTestCase(unittest.TestCase): u"og:title": u"Foo", u"og:description": u"Some text." }) + + def test_missing_title(self): + html = u""" + <html> + <body> + Some text. + </body> + </html> + """ + + og = decode_and_calc_og(html, "http://example.com/test.html") + + self.assertEquals(og, { + u"og:title": None, + u"og:description": u"Some text." + }) + + def test_h1_as_title(self): + html = u""" + <html> + <meta property="og:description" content="Some text."/> + <body> + <h1>Title</h1> + </body> + </html> + """ + + og = decode_and_calc_og(html, "http://example.com/test.html") + + self.assertEquals(og, { + u"og:title": u"Title", + u"og:description": u"Some text." + }) + + def test_missing_title_and_broken_h1(self): + html = u""" + <html> + <body> + <h1><a href="foo"/></h1> + Some text. + </body> + </html> + """ + + og = decode_and_calc_og(html, "http://example.com/test.html") + + self.assertEquals(og, { + u"og:title": None, + u"og:description": u"Some text." + }) |