예제 #1
0
    def test_multi_errors(self):
        http = Embedly(self.key)

        objs = http.oembed([
            'http://www.youtube.com/this/is/a/bad/url',
            'http://blog.embed.ly/alsd/slsdlf/asdlfj'
        ])
        self.assert_(objs[0].type == 'error', objs[0].dict)
        self.assert_(objs[1].type == 'error', objs[1].dict)

        objs = http.oembed([
            'http://blog.embed.ly/lsbsdlfldsf/asdf/kl',
            'http://twitpic.com/nothing/to/see/here'
        ])
        self.assert_(objs[0].type == 'error', objs[0].dict)
        self.assert_(objs[1].type == 'error', objs[1].dict)

        objs = http.oembed([
            'http://blog.embed.ly/lsbsdlfldsf/asdf/kl',
            'http://yfrog.com/h22eu4j'
        ])
        self.assert_(objs[0].type == 'error', objs[0].dict)
        self.assert_(objs[1].type == 'photo', objs[1].dict)

        objs = http.oembed([
            'http://yfrog.com/h22eu4j',
            'http://www.scribd.com/asdf/asdf/asdfasdf'
        ])
        self.assert_(objs[0].type == 'photo', objs[0].dict)
        self.assert_(objs[1].type == 'error', objs[1].dict)
예제 #2
0
    def test_multi_errors(self):
        http = Embedly(self.key)

        objs = list(
            http.oembed([
                'http://www.embedly.com/this/is/a/bad/url',
                'http://blog.embed.ly/alsd/slsdlf/asdlfj'
            ]))

        self.assertEqual(objs[0]['type'], 'error')
        self.assertEqual(objs[1]['type'], 'error')

        objs = list(
            http.oembed([
                'http://blog.embed.ly/lsbsdlfldsf/asdf/kl',
                'http://twitpic.com/nothing/to/see/here'
            ]))
        self.assertEqual(objs[0]['type'], 'error')
        self.assertEqual(objs[1]['type'], 'error')

        objs = list(
            http.oembed([
                'http://blog.embed.ly/lsbsdlfldsf/asdf/kl',
                'http://yfrog.com/h22eu4j'
            ]))
        self.assertEqual(objs[0]['type'], 'error')
        self.assertEqual(objs[1]['type'], 'photo')

        objs = list(
            http.oembed([
                'http://yfrog.com/h22eu4j',
                'http://www.scribd.com/asdf/asdf/asdfasdf'
            ]))
        self.assertEqual(objs[0]['type'], 'photo')
        self.assertEqual(objs[1]['type'], 'error')
예제 #3
0
    def test_error(self):
        http = Embedly(self.key)

        obj = http.oembed('http://www.embedly.com/this/is/a/bad/url')
        self.assertTrue(obj['error'])
        obj = http.oembed('http://blog.embed.ly/lsbsdlfldsf/asdfkljlas/klajsdlfkasdf')
        self.assertTrue(obj['error'])
        obj = http.oembed('http://twitpic/nothing/to/see/here')
        self.assertTrue(obj['error'])
예제 #4
0
    def test_too_many_urls(self):
        http = Embedly(self.key)

        urls = ['http://embed.ly'] * 21
        try:
            http.oembed(urls)
            self.fail('too many urls, should have thrown an error')
        except Exception as e:
            self.assertTrue(type(e), ValueError)
예제 #5
0
    def test_too_many_urls(self):
        http = Embedly(self.key)

        urls = ['http://embed.ly'] * 21
        try:
            http.oembed(urls)
            self.fail('too many urls, should have thrown an error')
        except Exception as e:
            self.assertTrue(type(e), ValueError)
예제 #6
0
파일: tests.py 프로젝트: a85/doublespeak
 def test_error(self):
     http = Embedly(self.key)
     
     obj = http.oembed('http://www.youtube.com/this/is/a/bad/url')
     self.assert_(obj.error is True, obj.dict)
     obj = http.oembed('http://blog.embed.ly/lsbsdlfldsf/asdfkljlas/klajsdlfkasdf')
     self.assert_(obj.error is True, obj.dict)
     obj = http.oembed('http://twitpic/nothing/to/see/here')
     self.assert_(obj.error is True, obj.dict)
예제 #7
0
    def test_error(self):
        http = Embedly(self.key)

        obj = http.oembed('http://www.embedly.com/this/is/a/bad/url')
        self.assertTrue(obj['error'])
        obj = http.oembed('http://blog.embed.ly/lsbsdlfldsf/asdfkljlas/klajsdlfkasdf')
        self.assertTrue(obj['error'])
        obj = http.oembed('http://twitpic/nothing/to/see/here')
        self.assertTrue(obj['error'])
예제 #8
0
    def test_error(self):
        http = Embedly(self.key)

        obj = http.oembed('http://www.youtube.com/this/is/a/bad/url')
        self.assert_(obj.error is True, obj.dict)
        obj = http.oembed(
            'http://blog.embed.ly/lsbsdlfldsf/asdfkljlas/klajsdlfkasdf')
        self.assert_(obj.error is True, obj.dict)
        obj = http.oembed('http://twitpic/nothing/to/see/here')
        self.assert_(obj.error is True, obj.dict)
예제 #9
0
파일: tests.py 프로젝트: a85/doublespeak
 def test_providers(self):
     http = Embedly(self.key)
     
     objs = http.oembed(['http://www.scribd.com/doc/13994900/Easter',
                         'http://www.scribd.com/doc/28452730/Easter-Cards'])
     self.assert_(objs[0].provider_url == 'http://www.scribd.com/')
     self.assert_(objs[1].provider_url == 'http://www.scribd.com/')
     
     objs = http.oembed(['http://www.youtube.com/watch?v=Zk7dDekYej0',
                         'http://yfrog.com/h22eu4'])
     self.assert_(objs[0].provider_url == 'http://www.youtube.com/')
     self.assert_(objs[1].provider_url == 'http://yfrog.com/')
예제 #10
0
    def test_providers(self):
        http = Embedly(self.key)

        objs = list(http.oembed(['http://www.scribd.com/doc/13994900/Easter',
                                 'http://www.scribd.com/doc/28452730/Easter-Cards']))

        self.assertEqual(objs[0]['provider_url'], 'http://www.scribd.com/')
        self.assertEqual(objs[1]['provider_url'], 'http://www.scribd.com/')

        objs = list(http.oembed(['http://www.youtube.com/watch?v=Zk7dDekYej0',
                                 'http://yfrog.com/h22eu4']))
        self.assertEqual(objs[0]['provider_url'], 'http://www.youtube.com/')
        self.assertEqual(objs[1]['provider_url'], 'http://yfrog.com')
예제 #11
0
파일: tests.py 프로젝트: nabilt/Like-List
    def test_provider(self):
        http = Embedly(self.key)

        obj = http.oembed("http://www.scribd.com/doc/13994900/Easter")
        self.assert_(obj.provider_url == "http://www.scribd.com/")

        obj = http.oembed("http://www.scribd.com/doc/28452730/Easter-Cards")
        self.assert_(obj.provider_url == "http://www.scribd.com/")

        obj = http.oembed("http://www.youtube.com/watch?v=Zk7dDekYej0")
        self.assert_(obj.provider_url == "http://www.youtube.com/")

        obj = http.oembed("http://yfrog.com/h22eu4j")
        self.assert_(obj.provider_url == "http://yfrog.com")
예제 #12
0
    def test_provider(self):
        http = Embedly(self.key)

        obj = http.oembed('http://www.scribd.com/doc/13994900/Easter')
        self.assertTrue(obj.provider_url == 'http://www.scribd.com/')

        obj = http.oembed('http://www.scribd.com/doc/28452730/Easter-Cards')
        self.assertTrue(obj.provider_url == 'http://www.scribd.com/')

        obj = http.oembed('http://www.youtube.com/watch?v=Zk7dDekYej0')
        self.assertTrue(obj.provider_url == 'http://www.youtube.com/')

        obj = http.oembed('http://yfrog.com/h22eu4j')
        self.assertTrue(obj.provider_url == 'http://yfrog.com')
예제 #13
0
    def test_provider(self):
        http = Embedly(self.key)

        obj = http.oembed('http://www.scribd.com/doc/13994900/Easter')
        self.assert_(obj.provider_url == 'http://www.scribd.com/')

        obj = http.oembed('http://www.scribd.com/doc/28452730/Easter-Cards')
        self.assert_(obj.provider_url == 'http://www.scribd.com/')

        obj = http.oembed('http://www.youtube.com/watch?v=Zk7dDekYej0')
        self.assert_(obj.provider_url == 'http://www.youtube.com/')

        obj = http.oembed('http://yfrog.com/h22eu4j')
        self.assert_(obj.provider_url == 'http://yfrog.com')
예제 #14
0
    def test_raw_content_in_request(self):
        client = Embedly(self.key)
        response = client.oembed('http://www.scribd.com/doc/13994900/Easter',
                                 raw=True)

        self.assertEqual(response['raw'], response.data['raw'])

        parsed = json.loads(response['raw'].decode('utf-8'))
        self.assertEqual(response['type'], parsed['type'])
예제 #15
0
파일: tests.py 프로젝트: nabilt/Like-List
    def test_multi_errors(self):
        http = Embedly(self.key)

        objs = http.oembed(["http://www.youtube.com/this/is/a/bad/url", "http://blog.embed.ly/alsd/slsdlf/asdlfj"])
        self.assert_(objs[0].type == "error", objs[0].dict)
        self.assert_(objs[1].type == "error", objs[1].dict)

        objs = http.oembed(["http://blog.embed.ly/lsbsdlfldsf/asdf/kl", "http://twitpic.com/nothing/to/see/here"])
        self.assert_(objs[0].type == "error", objs[0].dict)
        self.assert_(objs[1].type == "error", objs[1].dict)

        objs = http.oembed(["http://blog.embed.ly/lsbsdlfldsf/asdf/kl", "http://yfrog.com/h22eu4j"])
        self.assert_(objs[0].type == "error", objs[0].dict)
        self.assert_(objs[1].type == "photo", objs[1].dict)

        objs = http.oembed(["http://yfrog.com/h22eu4j", "http://www.scribd.com/asdf/asdf/asdfasdf"])
        self.assert_(objs[0].type == "photo", objs[0].dict)
        self.assert_(objs[1].type == "error", objs[1].dict)
예제 #16
0
    def test_raw_content_in_request(self):
        client = Embedly(self.key)
        response = client.oembed(
            'http://www.scribd.com/doc/13994900/Easter',
            raw=True)

        self.assertEqual(response['raw'], response.data['raw'])

        parsed = json.loads(response['raw'].decode('utf-8'))
        self.assertEqual(response['type'], parsed['type'])
예제 #17
0
 def set_embedly_data(self, field_name):
     original_field_value = getattr(self, 'original_{0}'.format(field_name))
     new_field_value = getattr(self, field_name)
     if new_field_value != original_field_value:
         embedly_key = getattr(settings, 'EMBEDLY_KEY')
         if embedly_key:
             client = Embedly(embedly_key)
             data_field_name = '{0}_data'.format(field_name)
             setattr(self, data_field_name, client.oembed(new_field_value)._data)
     setattr(self, 'original_{0}'.format(field_name), new_field_value)
예제 #18
0
 def set_embedly_data(self, field_name):
     original_field_value = getattr(self, 'original_{0}'.format(field_name))
     new_field_value = getattr(self, field_name)
     if new_field_value != original_field_value:
         embedly_key = getattr(settings, 'EMBEDLY_KEY')
         if embedly_key:
             client = Embedly(embedly_key)
             data_field_name = '{0}_data'.format(field_name)
             setattr(self, data_field_name,
                     client.oembed(new_field_value)._data)
     setattr(self, 'original_{0}'.format(field_name), new_field_value)
예제 #19
0
    def test_multi_errors(self):
        http = Embedly(self.key)

        objs = list(http.oembed(['http://www.embedly.com/this/is/a/bad/url',
                                 'http://blog.embed.ly/alsd/slsdlf/asdlfj']))
        self.assertTrue(objs[0].type == 'error', objs[0].dict)
        self.assertTrue(objs[1].type == 'error', objs[1].dict)

        objs = list(http.oembed(['http://blog.embed.ly/lsbsdlfldsf/asdf/kl',
                                 'http://twitpic.com/nothing/to/see/here']))
        self.assertTrue(objs[0].type == 'error',objs[0].dict)
        self.assertTrue(objs[1].type == 'error',objs[1].dict)

        objs = list(http.oembed(['http://blog.embed.ly/lsbsdlfldsf/asdf/kl',
                                 'http://yfrog.com/h22eu4j']))
        self.assertTrue(objs[0].type == 'error',objs[0].dict)
        self.assertTrue(objs[1].type == 'photo',objs[1].dict)

        objs = list(http.oembed(['http://yfrog.com/h22eu4j',
                                 'http://www.scribd.com/asdf/asdf/asdfasdf']))
        self.assertTrue(objs[0].type == 'photo',objs[0].dict)
        self.assertTrue(objs[1].type == 'error',objs[1].dict)
예제 #20
0
    def test_exception_on_too_many_urls(self):
        http = Embedly(self.key)
        urls = ['http://embed.ly'] * 21

        with self.assertRaises(ValueError):
            http.oembed(urls)
예제 #21
0
    def test_exception_on_too_many_urls(self):
        http = Embedly(self.key)
        urls = ['http://embed.ly'] * 21

        with self.assertRaises(ValueError):
            http.oembed(urls)