- Added TypeScript build info for frontend. - Created Vite configuration for React application. - Implemented pre-commit hook to run checks before commits. - Set up PostgreSQL Dockerfile with PostGIS support and initialization scripts. - Added database creation script for PostgreSQL with necessary extensions. - Established Python project configuration with dependencies and development tools. - Developed pre-commit script to enforce code quality checks for backend and frontend. - Created PowerShell script to set up Git hooks path.
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
from datetime import datetime, timezone
|
|
|
|
from backend.app.models import StationModel, TrackModel, TrainModel
|
|
|
|
|
|
def _now() -> datetime:
|
|
return datetime.now(timezone.utc)
|
|
|
|
|
|
def test_station_model_round_trip() -> None:
|
|
timestamp = _now()
|
|
station = StationModel(
|
|
id="station-1",
|
|
name="Central",
|
|
latitude=52.52,
|
|
longitude=13.405,
|
|
created_at=timestamp,
|
|
updated_at=timestamp,
|
|
)
|
|
assert station.name == "Central"
|
|
assert station.model_dump()["id"] == "station-1"
|
|
|
|
|
|
def test_track_model_properties() -> None:
|
|
timestamp = _now()
|
|
track = TrackModel(
|
|
id="track-1",
|
|
start_station_id="station-1",
|
|
end_station_id="station-2",
|
|
length_meters=1500.0,
|
|
max_speed_kph=120.0,
|
|
created_at=timestamp,
|
|
updated_at=timestamp,
|
|
)
|
|
assert track.length_meters > 0
|
|
assert track.start_station_id != track.end_station_id
|
|
|
|
|
|
def test_train_model_operating_tracks() -> None:
|
|
timestamp = _now()
|
|
train = TrainModel(
|
|
id="train-1",
|
|
designation="Express",
|
|
capacity=350,
|
|
max_speed_kph=200.0,
|
|
operating_track_ids=["track-1", "track-2"],
|
|
created_at=timestamp,
|
|
updated_at=timestamp,
|
|
)
|
|
assert train.capacity >= 0
|
|
assert len(train.operating_track_ids) == 2
|