def test_deleting_a_newly_added_fixture(self): all_fixtures_before_deletion = basic_get_request( endpoints["get_fixtures"]).json() self.assertEqual(len(all_fixtures_before_deletion), 4) basic_delete_request(endpoints["get_fixture_by_id"] + "4") all_fixtures_after_deletion = basic_get_request( endpoints["get_fixtures"]).json() self.assertEqual(len(all_fixtures_after_deletion), 3)
def test_deleting_a_fixture_added_before_a_newly_added_fixture(self): basic_post_request(endpoints["add_fixture"], json_body=self.fixture5) all_fixtures_before_deletion = basic_get_request( endpoints["get_fixtures"]).json() self.assertEqual(len(all_fixtures_before_deletion), 5) basic_delete_request(endpoints["get_fixture_by_id"] + "4") all_fixtures_after_deletion = basic_get_request( endpoints["get_fixtures"]).json() self.assertEqual(len(all_fixtures_after_deletion), 4) basic_delete_request(endpoints["get_fixture_by_id"] + "5")
def test_first_element_of_teams_array_has_HOME_as_teamID_value(self): basic_post_request(endpoints["add_fixture"], json_body=self.fixture5) all_fixtures = basic_get_request(endpoints["get_fixtures"]).json() results = [] for fixtures in all_fixtures: home_team_id = fixtures["footballFullState"]["teams"][0]["teamId"] results.append(home_team_id) self.assertEqual(all(x == "HOME" for x in results), True) self.assertEqual(len(results), 5) basic_delete_request(endpoints["get_fixture_by_id"] + "4") basic_delete_request(endpoints["get_fixture_by_id"] + "5")
def test_attempting_to_delete_a_fixture_that_does_not_exist_returns_an_appropriate_message( self): all_fixtures_before_deletion = basic_get_request( endpoints["get_fixtures"]).json() responses = [ basic_delete_request(endpoints["get_fixture_by_id"] + "10"), basic_delete_request(endpoints["get_fixture_by_id"] + "5"), basic_delete_request(endpoints["get_fixture_by_id"] + "0") ] self.assertEqual(len(all_fixtures_before_deletion), 4) self.assertEqual(all(x.status_code == 404 for x in responses), True) self.assertEqual(all(x.text == "Fixture not found" for x in responses), True) basic_delete_request(endpoints["get_fixture_by_id"] + "4")
def test_an_information_on_newly_added_fixture_can_be_retrieved(self): response_getting_the_new_fixture = basic_get_request( endpoints["get_fixture_by_id"] + "4").json() fixture_id = response_getting_the_new_fixture["fixtureId"] home_team = response_getting_the_new_fixture["footballFullState"][ "homeTeam"] away_team = response_getting_the_new_fixture["footballFullState"][ "awayTeam"] clock_time = response_getting_the_new_fixture["footballFullState"][ "goals"][0]["clockTime"] self.assertEqual(fixture_id, str(4)) self.assertEqual(home_team, "Fixture4 Team") self.assertEqual(away_team, "FC United") self.assertEqual(clock_time, 780) basic_delete_request(endpoints["get_fixture_by_id"] + "4")
def delete_all_fixtures(): all_fixtures_before_deletion = basic_get_request( endpoints["get_fixtures"]).json() for x in range(len(all_fixtures_before_deletion), 0, -1): basic_delete_request(endpoints["get_fixture_by_id"] + str(x))
def test_two_additional_fixtures_are_successfully_added(self): basic_post_request(endpoints["add_fixture"], json_body=self.fixture5) all_fixtures = basic_get_request(endpoints["get_fixtures"]).json() self.assertEqual(len(all_fixtures), 5) basic_delete_request(endpoints["get_fixture_by_id"] + "4") basic_delete_request(endpoints["get_fixture_by_id"] + "5")
def test_an_additional_fixture_is_successfully_added(self): all_fixtures = basic_get_request(endpoints["get_fixtures"]) self.assertEqual(len(all_fixtures.json()), 4) self.assertEqual(self.posting_a_fixture4_response.status_code, 200) basic_delete_request(endpoints["get_fixture_by_id"] + str(len(all_fixtures.json())))