[WIP] Link hike to places
This commit is contained in:
14
backend/app/tests/utils/place.py
Normal file
14
backend/app/tests/utils/place.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from sqlmodel import Session
|
||||
|
||||
from app.models.place import Place, PlaceCreate
|
||||
from app.tests.utils.utils import random_lower_string, random_lower_short_string
|
||||
|
||||
|
||||
def create_random_place(db: Session, name: str = None) -> Place:
|
||||
if not name:
|
||||
name = random_lower_string()
|
||||
|
||||
short_name = random_lower_short_string()
|
||||
|
||||
place_in = PlaceCreate(name=name, short_name=short_name)
|
||||
return Place.create(session=db, create_obj=place_in)
|
||||
@@ -6,7 +6,7 @@ from app.tests.utils.utils import random_lower_string
|
||||
from app.tests.utils.hike import create_random_hike
|
||||
|
||||
|
||||
def create_random_route(db: Session, name: str = None, hike: Hike = None) -> Hike:
|
||||
def create_random_route(db: Session, name: str = None, hike: Hike = None) -> Route:
|
||||
if not name:
|
||||
name = random_lower_string()
|
||||
|
||||
|
||||
@@ -6,15 +6,12 @@ from app.models.event import Event
|
||||
from app.models.team import Team, TeamCreate
|
||||
|
||||
from app.tests.utils.event import create_random_event
|
||||
from app.tests.utils.utils import random_lower_string
|
||||
from app.tests.utils.utils import random_lower_string, random_lower_short_string
|
||||
|
||||
|
||||
def random_short_name() -> str:
|
||||
return str(random.Random().randrange(1, 200))
|
||||
|
||||
def create_random_team(db: Session, event: Event | None = None) -> Team:
|
||||
name = random_lower_string()
|
||||
short_name = random_short_name()
|
||||
short_name = random_lower_short_string()
|
||||
|
||||
if not event:
|
||||
event = create_random_event(db)
|
||||
|
||||
@@ -10,6 +10,10 @@ def random_lower_string() -> str:
|
||||
return "".join(random.choices(string.ascii_lowercase, k=32))
|
||||
|
||||
|
||||
def random_lower_short_string() -> str:
|
||||
return str(random.Random().randrange(1, 8))
|
||||
|
||||
|
||||
def random_email() -> str:
|
||||
return f"{random_lower_string()}@{random_lower_string()}.com"
|
||||
|
||||
@@ -24,3 +28,4 @@ def get_superuser_token_headers(client: TestClient) -> dict[str, str]:
|
||||
a_token = tokens["access_token"]
|
||||
headers = {"Authorization": f"Bearer {a_token}"}
|
||||
return headers
|
||||
|
||||
|
||||
Reference in New Issue
Block a user