def test_get_game_weeks_by_ids(self): log.info(f'Downloading game weeks ...') fpl = FPLPandas() game_weeks = fpl.get_game_weeks([1, 2]) log.info(f'Downloaded {game_weeks.shape[0]} game weeks.') self.assertTrue(game_weeks.shape[0] == 2)
def test_get_game_weeks_with_ids(self): test_data = [{ 'id': 1, 'attr1': 'value11', 'attr2': 'value12' }, { 'id': 2, 'attr1': 'value21', 'attr2': 'value22' }] fpl_mock = mock.MagicMock() async def mock_get_game_weeks(game_week_ids, return_json): self.assertEqual(game_week_ids, [1, 2]) self.assertEqual(return_json, True) return test_data fpl_mock.get_gameweeks = mock_get_game_weeks fpl = FPLPandas(fpl=fpl_mock) actual_df = fpl.get_game_weeks([1, 2]) expected_df = pd.DataFrame.from_dict(test_data).set_index('id') self.assertTrue(expected_df.equals(actual_df))