File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ def get_api_endpoint(username: str, flavor: str) -> str:
2020 "PYTHONANYWHERE_SITE" ,
2121 "www." + os .environ .get ("PYTHONANYWHERE_DOMAIN" , "pythonanywhere.com" ),
2222 )
23+ if flavor == "websites" :
24+ return f"https://{ hostname } /api/v1/user/{ username } /{ flavor } /"
2325 return f"https://{ hostname } /api/v0/user/{ username } /{ flavor } /"
2426
2527
Original file line number Diff line number Diff line change @@ -41,6 +41,22 @@ def test_get_api_endpoint_gets_domain_from_pythonanywhere_domain_and_adds_on_www
4141 assert result == "https://www.foo.com/api/v0/user/bill/webapp/"
4242
4343
44+ @pytest .mark .parametrize (
45+ "flavor,expected_version" ,
46+ [
47+ ("files" , "v0" ),
48+ ("schedule" , "v0" ),
49+ ("students" , "v0" ),
50+ ("webapps" , "v0" ),
51+ ("websites" , "v1" ),
52+ ]
53+ )
54+ def test_get_api_endpoint_returns_url_with_correct_api_version (flavor , expected_version ):
55+ result = get_api_endpoint (username = "bill" , flavor = flavor )
56+
57+ assert result == f"https://www.pythonanywhere.com/api/{ expected_version } /user/bill/{ flavor } /"
58+
59+
4460def test_raises_on_401 (api_token , api_responses ):
4561 url = "https://foo.com/"
4662 api_responses .add (responses .POST , url , status = 401 , body = "nope" )
You can’t perform that action at this time.
0 commit comments