def test_oembed_url_xml(self, get): get.return_value = response = mock.Mock() response.ok = True response.text = get_fixture('autodiscover-xml.html') self.assertEqual(self.provider.oembed_url(self.url), 'http://www.youtube.com/oembed?url=http%3A%2F%2F' 'www.youtube.com%2Fwatch%3Fv%3D2nLsvPBqeZ8' '&format=xml')
def test_oembed_url_xml(self, get): get.return_value = response = mock.Mock() response.ok = True response.text = get_fixture('autodiscover-xml.html') self.assertEqual( self.provider.oembed_url(self.url), 'http://www.youtube.com/oembed?url=http%3A%2F%2F' 'www.youtube.com%2Fwatch%3Fv%3D2nLsvPBqeZ8' '&format=xml')
def test_content_parse_with_percent(self): content = get_fixture('sample-video-percent.json') rv = self.parser.content_parse(content) self.assertEqual( rv, { 'provider_url': 'http://www.youtube.com/', 'author_name': 'Showlivre', 'title': u'Vespas Mandarinas em "Antes que ' u'voc\xea conte at\xe9 dez" no Est\xfadio ' u'Showlivre 2013', 'html': u'<iframe width="100%" height="100%" ' u'src="http://www.youtube.com/embed/2nLsvPBqeZ8' u'?feature=oembed" frameborder="0" ' u'allowfullscreen></iframe>', 'thumbnail_width': 480, 'height': '100%', 'width': '100%', 'version': '1.0', 'author_url': 'http://www.youtube.com/user/showlivre', 'provider_name': 'YouTube', 'thumbnail_url': 'http://i1.ytimg.com/vi/' '2nLsvPBqeZ8/hqdefault.jpg', 'type': 'video', 'thumbnail_height': 360 })
def test_content_parse(self): content = get_fixture('sample-video.json') rv = self.parser.content_parse(content) self.assertEqual(rv, {'provider_url': 'http://www.youtube.com/', 'author_name': 'Showlivre', 'title': u'Vespas Mandarinas em "Antes que ' u'voc\xea conte at\xe9 dez" no Est\xfadio ' u'Showlivre 2013', 'html': u'<iframe width="480" height="270" ' u'src="http://www.youtube.com/embed/2nLsvPBqeZ8' u'?feature=oembed" frameborder="0" ' u'allowfullscreen></iframe>', 'thumbnail_width': 480, 'height': 270, 'width': 480, 'version': '1.0', 'author_url': 'http://www.youtube.com/user/showlivre', 'provider_name': 'YouTube', 'thumbnail_url': 'http://i1.ytimg.com/vi/' '2nLsvPBqeZ8/hqdefault.jpg', 'type': 'video', 'thumbnail_height': 360})
def test_parsers_returns_same_stuff(self): xml_parser = XmlParser() json_parser = JsonParser() xml = xml_parser.content_parse(get_fixture('sample-video.xml')) json = json_parser.content_parse(get_fixture('sample-video.json')) self.assertEqual(xml, json)
def test_oembed_url_none(self, get): get.return_value = response = mock.Mock() response.ok = True response.text = get_fixture('autodiscover-none.html') with self.assertRaises(ProviderException): self.provider.oembed_url(self.url)
def test_oembed_url_request_failed(self, get): get.return_value = response = mock.Mock() response.ok = False response.text = get_fixture('autodiscover-both.html') with self.assertRaises(ProviderException): self.provider.oembed_url(self.url)