Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions campus_python/api/v1/assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def links(self) -> "Assignments.Assignment.Links":
return Assignments.Assignment.Links("links", parent=self)

def delete(self) -> None:
resp = self.client.delete(self.make_path())
resp = self.client.delete(self.make_path(end_slash=True))
resp.raise_for_status()
return None

def get(self) -> campus.model.Assignment:
resp = self.client.get(self.make_path())
resp = self.client.get(self.make_path(end_slash=True))
resp.raise_for_status()
return campus.model.Assignment.from_resource(resp.json())

Expand All @@ -83,7 +83,7 @@ def update(self, **updates) -> None:
"""
if not updates:
raise ValueError("At least one field must be provided for update")
resp = self.client.patch(self.make_path(), json=updates)
resp = self.client.patch(self.make_path(end_slash=True), json=updates)
resp.raise_for_status()
return None

Expand Down
6 changes: 3 additions & 3 deletions campus_python/api/v1/circles.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def members(self) -> "Circles.Circle.CircleMembers":
return Circles.Circle.CircleMembers("members", parent=self)

def delete(self) -> None:
resp = self.client.delete(self.make_path())
resp = self.client.delete(self.make_path(end_slash=True))
resp.raise_for_status()
return None

def get(self) -> campus.model.Circle:
resp = self.client.get(self.make_path())
resp = self.client.get(self.make_path(end_slash=True))
resp.raise_for_status()
return campus.model.Circle.from_resource(resp.json())

Expand All @@ -84,7 +84,7 @@ def update(
payload: dict[str, Any] = {"name": name}
if description is not None:
payload["description"] = description
resp = self.client.patch(self.make_path(), json=payload)
resp = self.client.patch(self.make_path(end_slash=True), json=payload)
resp.raise_for_status()
return None

Expand Down
12 changes: 6 additions & 6 deletions campus_python/api/v1/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def by_assignment(self, assignment_id: str) -> "list[campus.model.Submission]":
Returns:
List of Submission objects
"""
path = f"{self.make_path()}/by-assignment/{assignment_id}"
path = f"{self.make_path()}/by-assignment/{assignment_id}/"
resp = self.client.get(path)
resp.raise_for_status()
return [
Expand All @@ -76,7 +76,7 @@ def by_student(self, student_id: str) -> "list[campus.model.Submission]":
Returns:
List of Submission objects
"""
path = f"{self.make_path()}/by-student/{student_id}"
path = f"{self.make_path()}/by-student/{student_id}/"
resp = self.client.get(path)
resp.raise_for_status()
return [
Expand Down Expand Up @@ -130,13 +130,13 @@ def feedback(self) -> "Submissions.Submission.Feedback":

def delete(self) -> None:
"""Delete this submission."""
resp = self.client.delete(self.make_path())
resp = self.client.delete(self.make_path(end_slash=True))
resp.raise_for_status()
return None

def get(self) -> campus.model.Submission:
"""Get this submission."""
resp = self.client.get(self.make_path())
resp = self.client.get(self.make_path(end_slash=True))
resp.raise_for_status()
return campus.model.Submission.from_resource(resp.json())

Expand Down Expand Up @@ -167,7 +167,7 @@ def update(
if not payload:
raise ValueError("At least one field must be provided for update")

resp = self.client.patch(self.make_path(), json=payload)
resp = self.client.patch(self.make_path(end_slash=True), json=payload)
resp.raise_for_status()
return None

Expand All @@ -186,7 +186,7 @@ def unsubmit(self) -> None:
means "omit the field" there.
"""
resp = self.client.patch(
self.make_path(), json={"submitted_at": None}
self.make_path(end_slash=True), json={"submitted_at": None}
)
resp.raise_for_status()
return None
Expand Down
12 changes: 6 additions & 6 deletions campus_python/auth/v1/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ def __getitem__(self, user_id: str) -> "Credentials.Provider.User":

def get(self, token_id: str) -> campus.model.UserCredentials:
resp = self.client.get(
self.make_path(),
self.make_path(end_slash=True),
query={"token_id": token_id}
)
resp.raise_for_status()
return campus.model.UserCredentials.from_resource(resp.json())

def list(self) -> "list[campus.model.UserCredentials]":
resp = self.client.get(self.make_path())
resp = self.client.get(self.make_path(end_slash=True))
# Raise error if status code is not 2XX or 3XX
resp.raise_for_status()
return [
Expand All @@ -61,7 +61,7 @@ class User(Resource):
def delete(self) -> None:
client_id = env.CLIENT_ID
resp = self.client.delete(
self.make_path(),
self.make_path(end_slash=True),
json={"client_id": client_id}
)
# Raise error if status code is not 2XX or 3XX
Expand All @@ -70,7 +70,7 @@ def delete(self) -> None:
def get(self) -> campus.model.UserCredentials:
client_id = env.CLIENT_ID
resp = self.client.get(
self.make_path(),
self.make_path(end_slash=True),
query={"client_id": client_id}
)
# Raise error if status code is not 2XX or 3XX
Expand All @@ -92,7 +92,7 @@ def new(
The created UserCredentials
"""
resp = self.client.post(
self.make_path(),
self.make_path(end_slash=True),
json={"scopes": scopes, "expires_in": expires_in}
)
# Raise error if status code is not 2XX or 3XX
Expand All @@ -105,6 +105,6 @@ def update(self, token: campus.model.OAuthToken) -> None:
"client_id": client_id,
"token": token.to_resource()
}
resp = self.client.patch(self.make_path(), json=json_data)
resp = self.client.patch(self.make_path(end_slash=True), json=json_data)
# Raise error if status code is not 2XX or 3XX
resp.raise_for_status()
6 changes: 3 additions & 3 deletions campus_python/auth/v1/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def activate(self) -> campus.model.User:
return campus.model.User.from_resource(resp.json())

def delete(self) -> None:
resp = self.client.delete(self.make_path())
resp = self.client.delete(self.make_path(end_slash=True))
resp.raise_for_status()

def get(self) -> campus.model.User:
resp = self.client.get(self.make_path())
resp = self.client.get(self.make_path(end_slash=True))
resp.raise_for_status()
return campus.model.User.from_resource(resp.json())

Expand All @@ -67,6 +67,6 @@ def update(self, *, name: str) -> campus.model.User:
Returns:
The updated User
"""
resp = self.client.patch(self.make_path(), json={"name": name})
resp = self.client.patch(self.make_path(end_slash=True), json={"name": name})
resp.raise_for_status()
return campus.model.User.from_resource(resp.json())
8 changes: 4 additions & 4 deletions campus_python/auth/v1/vaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ class Vault(Resource):
"""A single vault (label) exposing mapping-like access."""

def keys(self) -> "list[str]":
resp = self.client.get(self.make_path())
resp = self.client.get(self.make_path(end_slash=True))
resp.raise_for_status()
body = resp.json()
return body["keys"]

def __delitem__(self, key: str) -> None:
resp = self.client.delete(self.make_path(key))
resp = self.client.delete(self.make_path(key, end_slash=True))
if resp.status_code == 404:
raise KeyError(key)
resp.raise_for_status()
return None

def __getitem__(self, key: str) -> str:
resp = self.client.get(self.make_path(key))
resp = self.client.get(self.make_path(key, end_slash=True))
# translate 404 into KeyError for route compatibility
if resp.status_code == 404:
raise KeyError(key)
Expand All @@ -47,6 +47,6 @@ def __getitem__(self, key: str) -> str:
return body["key"]

def __setitem__(self, key: str, value: Any) -> None:
resp = self.client.post(self.make_path(key), json={"value": value})
resp = self.client.post(self.make_path(key, end_slash=True), json={"value": value})
resp.raise_for_status()
return None
2 changes: 1 addition & 1 deletion tests/unit/test_auth_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_new_posts_scopes_and_expires_in(self):
scopes=["campus.profile"], expires_in=3600
)
self.client.post.assert_called_once_with(
"/auth/v1/credentials/campus/user1",
"/auth/v1/credentials/campus/user1/",
json={"scopes": ["campus.profile"], "expires_in": 3600},
)
self.assertIsInstance(creds, campus.model.UserCredentials)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_oauth_token_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_update_patches_credentials_endpoint(self):
self.auth.credentials["campus"]["user1"].update(self.token)
self.client.patch.assert_called_once()
args, kwargs = self.client.patch.call_args
self.assertEqual(args[0], "/auth/v1/credentials/campus/user1")
self.assertEqual(args[0], "/auth/v1/credentials/campus/user1/")
self.assertEqual(kwargs["json"]["client_id"], "cid123")
self.assertEqual(kwargs["json"]["token"], self.token.to_resource())

Expand Down
Loading