Skip to content

Commit

Permalink
Pull up setting authorization header to session
Browse files Browse the repository at this point in the history
  • Loading branch information
markhobson committed Oct 26, 2023
1 parent 594c59d commit 5485438
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions tests/e2e/app_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@ class AppClient:

def __init__(self, url: str, api_key: str):
self._url = url
self._api_key = api_key
self._session = requests.Session()
self._session.headers.update({"Authorization": f"API-Key {api_key}"})

def add_user(self, user: UserRepr) -> None:
response = requests.post(
f"{self._url}/users",
headers={"Authorization": f"API-Key {self._api_key}"},
json=[user.__dict__],
timeout=self.DEFAULT_TIMEOUT,
)
response = self._session.post(f"{self._url}/users", json=[user.__dict__], timeout=self.DEFAULT_TIMEOUT)
assert response.status_code == 201

def clear_users(self) -> None:
response = requests.delete(
f"{self._url}/users", headers={"Authorization": f"API-Key {self._api_key}"}, timeout=self.DEFAULT_TIMEOUT
)
response = self._session.delete(f"{self._url}/users", timeout=self.DEFAULT_TIMEOUT)
assert response.status_code == 204


Expand Down

0 comments on commit 5485438

Please sign in to comment.