def test_get_teams(self): log.info(f'Downloading teams ...') fpl = FPLPandas() teams = fpl.get_teams() log.info(f'Downloaded {teams.shape[0]} teams.') self.assertTrue(teams.shape[0] > 0)
def test_get_teams_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_team(team_ids, return_json): self.assertEqual(team_ids, [1, 2]) self.assertEqual(return_json, True) return test_data fpl_mock.get_teams = mock_get_team fpl = FPLPandas(fpl=fpl_mock) actual_df = fpl.get_teams([1, 2]) expected_df = pd.DataFrame.from_dict(test_data).set_index('id') self.assertTrue(expected_df.equals(actual_df))