def test_video_load(self, foo, bar): with patch('franck.model.video.Video.beautify') as m: v = Video('http://www.jeuxvideo.com/foo') expected = v actual = v.load() m.assert_called_once_with('video_config', 'video_info') self.assertEqual(id(actual), id(expected))
def test_video_no_reload(self): with patch('franck.model.video.Video.beautify') as m: v = Video('http://www.jeuxvideo.com/foo') v.json = 'json was loaded already' expected = v actual = v.load() self.assertEqual(len(m.mock_calls), 0) self.assertEqual(id(actual), id(expected))
def test_beautify(self): v = Video('http://www.jeuxvideo.com/gaming-live/0001/00011717/kingdom-hearts-chain-of-memories-gameboy-advance-gba-sora-00000849.htm') config = get_video_config() info = get_video_info() expected = build_video().json actual = v.beautify(config, info) self.assertEqual(ordered(actual), ordered(expected))
def video(url): logger.debug("[api] video("+ url +")") v = Video(url) v.load() if v.valid(): return v else: return None
def test_get_source_unloaded(self): v = Video('http://www.jeuxvideo.com/foo') expected = None actual = v.get_source() self.assertEqual(actual, expected)
def test_video_valid_loaded_invalid(self): v = Video('http://www.jeuxvideo.com/foo') v.json = {} expected = False actual = v.valid() self.assertEqual(actual, expected)
def test_video_valid_loaded_valid(self): v = Video('http://www.jeuxvideo.com/foo') v.json = 'json was loaded already' expected = True actual = v.valid() self.assertEqual(actual, expected)
def test_video_loaded_load(self): v = Video('http://www.jeuxvideo.com/foo') expected = False actual = v.loaded() self.assertEqual(actual, expected)
def build_video(): with open(os.path.join(os.path.dirname(__file__), 'files', 'video_json.json')) as jsondump: v = Video('http://www.jeuxvideo.com/gaming-live/0001/00011717/kingdom-hearts-chain-of-memories-gameboy-advance-gba-sora-00000849.htm') v.json = json.load(jsondump) return v