示例#1
0
    def test_repeat_and_raise_on_error(self):
        service = OrangelogicSearchProvider(self.provider)

        with HTTMock(auth_ok, search_error):
            with self.assertRaises(HTTPError):
                items = service.find({})

        with HTTMock(auth_error, search_error):
            with self.assertRaises(HTTPError):
                items = service.find({})
示例#2
0
    def test_find(self):
        service = OrangelogicSearchProvider(self.provider)

        with HTTMock(auth_ok, search_ok):
            items = service.find({})

        self.assertEqual(5, len(items))
        self.assertEqual(items.count(), 2021650)

        # test video
        self.assertEqual('video', items[0]['type'])

        self.assertEqual({
            'href': 'https://example.com/video.mp4',
            'width': 1280,
            'height': 720,
            'mimetype': 'video/mp4',
        }, items[0]['renditions']['webHigh'])

        self.assertEqual({
            'href': 'https://example.com/thumb.jpg',
            'width': 341,
            'height': 192,
            'mimetype': 'image/jpeg',
        }, items[0]['renditions']['thumbnail'])

        self.assertEqual({
            'href': 'https://example.com/thumb.jpg',
            'width': 341,
            'height': 192,
            'mimetype': 'image/jpeg',
        }, items[0]['renditions']['viewImage'])
示例#3
0
    def test_find(self):
        service = OrangelogicSearchProvider(self.provider)

        with HTTMock(auth_ok, search_ok):
            items = service.find({})

        self.assertEqual(5, len(items))
        self.assertEqual(items.count(), 2021650)

        # test video
        self.assertEqual("video", items[0]["type"])

        self.assertEqual(
            {
                "href": "https://example.com/video.mp4",
                "width": 1280,
                "height": 720,
                "mimetype": "video/mp4",
            },
            items[0]["renditions"]["webHigh"],
        )

        self.assertEqual(
            {
                "href": "https://example.com/thumb.jpg",
                "width": 341,
                "height": 192,
                "mimetype": "image/jpeg",
            },
            items[0]["renditions"]["thumbnail"],
        )

        self.assertEqual(
            {
                "href": "https://example.com/thumb.jpg",
                "width": 341,
                "height": 192,
                "mimetype": "image/jpeg",
            },
            items[0]["renditions"]["viewImage"],
        )