Exemple #1
0
class XmlParserTestCase(unittest.TestCase):

    def setUp(self):
        self.parser = XmlParser()
        self.maxDiff = None

    def test_content_supported(self):
        self.assertTrue(self.parser.content_supported('text/xml'))
        self.assertTrue(self.parser.content_supported('application/xml'))
        self.assertFalse(self.parser.content_supported('application/json'))

    def test_content_parse(self):
        content = get_fixture('sample-video.xml')
        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})
Exemple #2
0
 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)
Exemple #3
0
 def setUp(self):
     self.parser = XmlParser()
     self.maxDiff = None
Exemple #4
0
class XmlParserTestCase(unittest.TestCase):
    def setUp(self):
        self.parser = XmlParser()
        self.maxDiff = None

    def test_content_supported(self):
        self.assertTrue(self.parser.content_supported('text/xml'))
        self.assertTrue(self.parser.content_supported('application/xml'))
        self.assertFalse(self.parser.content_supported('application/json'))

    def test_content_parse(self):
        content = get_fixture('sample-video.xml')
        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_content_parse_with_percent(self):
        content = get_fixture('sample-video-percent.xml')
        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
            })
Exemple #5
0
 def setUp(self):
     self.parser = XmlParser()
     self.maxDiff = None
Exemple #6
0
 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)