import pytest import requests from pysportsdb.exceptions import ParameterNotAllowed, PateronOnlyEndpoint @pytest.mark.usefixtures("unpaid_spec") class TestdSpec: def test_default_api_key(self, unpaid_spec): assert unpaid_spec.API_KEY == "2" def test_lookup(self, unpaid_spec): with pytest.raises(PateronOnlyEndpoint): unpaid_spec.get_search_teams_url(t="Arsenal") def test_check_livescore_not_allowed(self, unpaid_spec): with pytest.raises(PateronOnlyEndpoint): unpaid_spec.get_livescore_url(s="Soccer") def test_no_params_allowed(self, unpaid_spec): with pytest.raises(ParameterNotAllowed): unpaid_spec.get_list_all_sports_url(s="") def test_wrong_params_not_allowed(self, unpaid_spec): with pytest.raises(ParameterNotAllowed): unpaid_spec.get_lookup_player_contracts_url(id="234", k="34234") def test_check_good_params(self, unpaid_spec): url = unpaid_spec.get_lookup_player_contracts_url(id="a9234") assert ( url == "https://www.thesportsdb.com/api/v1/json/2/lookupcontracts.php?id=a9234" ) def test_check_not_protected(self, unpaid_spec): url = unpaid_spec.get_list_all_sports_url() assert ( url == "https://www.thesportsdb.com/api/v1/json/2/all_sports.php" ) @pytest.mark.usefixtures("paid_spec") class TestPaidSpec: def test_default_api_key(self, paid_spec): assert paid_spec.API_KEY != "2" def test_lookup_paid_endpoint(self, paid_spec): url = paid_spec.get_search_teams_url(t="Arsenal") assert ( url == "https://www.thesportsdb.com/api/v1/json/NOTNULL/searchteams.php?t=Arsenal" ) def test_check_livescore_allowed(self, paid_spec): url = paid_spec.get_livescore_url(s="Soccer") assert ( url == "https://www.thesportsdb.com/api/v2/json/NOTNULL/livescore.php?s=Soccer" )