Replaced the UserClient class and the get_user_client function with the get_client function in the tests, for simplicity.
This commit is contained in:
@ -24,27 +24,14 @@ import httpx
|
||||
from flask import Flask
|
||||
|
||||
|
||||
class UserClient:
|
||||
"""A user client."""
|
||||
|
||||
def __init__(self, client: httpx.Client, csrf_token: str):
|
||||
"""Constructs a user client.
|
||||
|
||||
:param client: The client.
|
||||
:param csrf_token: The CSRF token.
|
||||
"""
|
||||
self.client: httpx.Client = client
|
||||
self.csrf_token: str = csrf_token
|
||||
|
||||
|
||||
def get_user_client(test_case: TestCase, app: Flask, username: str) \
|
||||
-> UserClient:
|
||||
def get_client(test_case: TestCase, app: Flask, username: str) \
|
||||
-> tuple[httpx.Client, str]:
|
||||
"""Returns a user client.
|
||||
|
||||
:param test_case: The test case.
|
||||
:param app: The Flask application.
|
||||
:param username: The username.
|
||||
:return: The user client.
|
||||
:return: A tuple of the client and the CSRF token.
|
||||
"""
|
||||
client: httpx.Client = httpx.Client(app=app, base_url="https://testserver")
|
||||
client.headers["Referer"] = "https://testserver"
|
||||
@ -54,7 +41,7 @@ def get_user_client(test_case: TestCase, app: Flask, username: str) \
|
||||
"username": username})
|
||||
test_case.assertEqual(response.status_code, 302)
|
||||
test_case.assertEqual(response.headers["Location"], "/")
|
||||
return UserClient(client, csrf_token)
|
||||
return client, csrf_token
|
||||
|
||||
|
||||
def get_csrf_token(test_case: TestCase, client: httpx.Client, uri: str) -> str:
|
||||
|
Reference in New Issue
Block a user