class MockTest(unittest.TestCase): def setUp(self): self.parser = Parser() def test_current_season(self): with HTTMock(current_season_mock): current = self.parser.current_shows self.assertEqual(list(current), ["Test 1", "Test 2", "Test 3", "Test 4"]) def test_shows_list(self): with HTTMock(shows_mock): shows = self.parser.shows self.assertEqual( shows, { 'Test 1': 'test-1', 'Test 2': 'test-2', 'Test 3': 'test-3', 'Test 4': 'test-4' }) def test_get_episodes(self): with HTTMock(api_mock): episodes = self.parser.get_episodes("test", limit=4) self.assertEqual(len(episodes), 4) batch = self.parser.get_batches("test") self.assertEqual(batch[0]["title"].lower(), "one-punch man") def test_show_id(self): with HTTMock(showid_mock): showid = self.parser._get_show_id("doesn't matter") self.assertTrue(showid, 123456789)
def test_get_batches(): parser = Parser() title = "Kateikyoushi Hitman Reborn!" batches = parser.get_batches(title) assert len(batches) == 2 for batch in batches: assert batch["title"] == title has_magnet = [] for resolution in "480", "720", "1080": assert resolution in batch has_magnet.append("Magnet" in batch[resolution]) assert has_magnet == sorted(has_magnet, reverse=True) assert has_magnet[0]