def test_locations_rankings_apicall_url(): coc = ClashOfClans(bearer_token="fake_key", endpoint="http://endpoint", api_version="v0") apicall = coc.locations(123).rankings.clans assert 'locations' in apicall.uri_parts assert 123 in apicall.uri_parts assert 'rankings' in apicall.uri_parts assert 'clans' in apicall.uri_parts assert len(apicall.uri_parts) == 4 apicall = coc.locations(123).rankings('clans') assert 'locations' in apicall.uri_parts assert 123 in apicall.uri_parts assert 'rankings' in apicall.uri_parts assert 'clans' in apicall.uri_parts assert len(apicall.uri_parts) == 4 apicall = coc.locations(123).rankings.players assert 'locations' in apicall.uri_parts assert 123 in apicall.uri_parts assert 'rankings' in apicall.uri_parts assert 'players' in apicall.uri_parts assert len(apicall.uri_parts) == 4 apicall = coc.locations(123).rankings('players') assert 'locations' in apicall.uri_parts assert 123 in apicall.uri_parts assert 'rankings' in apicall.uri_parts assert 'players' in apicall.uri_parts assert len(apicall.uri_parts) == 4
def test_build_uri(): coc = ClashOfClans(bearer_token="fake_key", endpoint="http://endpoint", api_version="v0") apicall = coc.locations('123').rankings('players') built_uri = build_uri(coc.endpoint, coc.api_version, apicall.uri_parts) assert built_uri == 'http://endpoint/v0/locations/123/rankings/players' apicall = coc.locations('123').rankings.clans built_uri = build_uri(coc.endpoint, coc.api_version, apicall.uri_parts) assert built_uri == 'http://endpoint/v0/locations/123/rankings/clans'
def test_specific_locations_apicall(api_key): coc = ClashOfClans(bearer_token=api_key) r = coc.locations(32000260).get() assert r.status_code == 200 assert isinstance(r, dict) assert r['countryCode'] == u'ZW' assert r['id'] == 32000260 assert r['isCountry'] == True assert r['name'] == u'Zimbabwe'
def test_location_player_rank_apicall(api_key): coc = ClashOfClans(bearer_token=api_key) r = coc.locations(32000260).rankings.clans.get() assert r.status_code == 200
from coc.api import ClashOfClans from os import environ if __name__ == '__main__': api = ClashOfClans(environ['COC_API_KEY']) print api.locations(32000183).get()
from coc.api import ClashOfClans from os import environ if __name__ == '__main__': api=ClashOfClans(environ['COC_API_KEY']) print api.locations(32000183).get()
def test_location_by_id_apicall_url(): coc = ClashOfClans(bearer_token="fake_key", endpoint="http://endpoint", api_version="v0") apicall = coc.locations(123) assert 'locations' in apicall.uri_parts assert 123 in apicall.uri_parts assert len(apicall.uri_parts) == 2