mirror of
https://github.com/sstent/FitTrack_GarminSync.git
synced 2026-01-26 17:12:00 +00:00
- Ensure code aligns with CentralDB models - Document code alignment with CentralDB models - Remove informal reference documents (data-model.md, DB_API_SPEC.json, GARMINSYNC_SPEC.md) - Run linters and formatters (black, isort, mypy) - Update project configuration files - Add .dockerignore for Docker builds - Perform code formatting and import sorting - Fix type checking issues - Update documentation files - Complete implementation tasks as per spec
74 lines
1.7 KiB
Python
74 lines
1.7 KiB
Python
from datetime import datetime
|
|
|
|
from backend.src.models.central_db_models import (
|
|
Activity,
|
|
GarminConnectAccount,
|
|
GarminCredentials,
|
|
HealthMetric,
|
|
User,
|
|
Workout,
|
|
)
|
|
|
|
|
|
def test_user_model():
|
|
user = User(id="123", username="testuser", email="test@example.com")
|
|
assert user.id == "123"
|
|
assert user.username == "testuser"
|
|
assert user.email == "test@example.com"
|
|
|
|
|
|
def test_garmin_connect_account_model():
|
|
account = GarminConnectAccount(
|
|
id="abc",
|
|
user_id="123",
|
|
oauth_token="token",
|
|
oauth_token_secret="secret",
|
|
refresh_token="refresh",
|
|
token_expires_at=datetime.now(),
|
|
)
|
|
assert account.id == "abc"
|
|
assert account.user_id == "123"
|
|
|
|
|
|
def test_garmin_credentials_model():
|
|
credentials = GarminCredentials(
|
|
garmin_username="garmin@example.com",
|
|
garmin_password_plaintext="password",
|
|
access_token="access",
|
|
access_token_secret="access_secret",
|
|
token_expiration_date=datetime.now(),
|
|
)
|
|
assert credentials.garmin_username == "garmin@example.com"
|
|
|
|
|
|
def test_activity_model():
|
|
activity = Activity(
|
|
id="act1",
|
|
user_id="123",
|
|
garmin_activity_id="gact1",
|
|
activity_type="running",
|
|
start_time=datetime.now(),
|
|
)
|
|
assert activity.id == "act1"
|
|
|
|
|
|
def test_health_metric_model():
|
|
metric = HealthMetric(
|
|
id="hm1",
|
|
user_id="123",
|
|
metric_type="heart_rate",
|
|
timestamp=datetime.now(),
|
|
value=70.5,
|
|
)
|
|
assert metric.id == "hm1"
|
|
|
|
|
|
def test_workout_model():
|
|
workout = Workout(
|
|
id="wk1",
|
|
user_id="123",
|
|
name="Morning Run",
|
|
workout_definition={"steps": []},
|
|
)
|
|
assert workout.id == "wk1"
|