mirror of
https://github.com/sstent/FitTrack_ReportGenerator.git
synced 2026-01-27 01:22:24 +00:00
feat: Initial implementation of FitTrack Report Generator
This commit introduces the initial version of the FitTrack Report Generator, a FastAPI application for analyzing workout files. Key features include: - Parsing of FIT, TCX, and GPX workout files. - Analysis of power, heart rate, speed, and elevation data. - Generation of summary reports and charts. - REST API for single and batch workout analysis. The project structure has been set up with a `src` directory for core logic, an `api` directory for the FastAPI application, and a `tests` directory for unit, integration, and contract tests. The development workflow is configured to use Docker and modern Python tooling.
This commit is contained in:
34
tests/unit/test_tcx_parser.py
Normal file
34
tests/unit/test_tcx_parser.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import pytest
|
||||
from unittest.mock import MagicMock, patch
|
||||
from src.core.file_parser import TcxParser, WorkoutData, WorkoutMetadata
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
@pytest.fixture
|
||||
def mock_tcx_parser():
|
||||
# Patch the TCXParser class where it's imported in src.core.file_parser
|
||||
with patch('src.core.file_parser.TCXParser') as mock_tcx_parser_class:
|
||||
mock_tcx_instance = MagicMock()
|
||||
mock_tcx_parser_class.return_value = mock_tcx_instance
|
||||
|
||||
mock_tcx_instance.started_at = datetime(2023, 1, 1, 10, 0, 0)
|
||||
mock_tcx_instance.duration = 3600 # 1 hour
|
||||
# Mock other attributes as needed for future tests
|
||||
|
||||
yield mock_tcx_parser_class
|
||||
|
||||
def test_tcx_parser_initialization():
|
||||
parser = TcxParser("dummy.tcx")
|
||||
assert parser.file_path == "dummy.tcx"
|
||||
|
||||
def test_tcx_parser_parse_method_returns_workout_data(mock_tcx_parser):
|
||||
parser = TcxParser("dummy.tcx")
|
||||
workout_data = parser.parse()
|
||||
|
||||
mock_tcx_parser.assert_called_once_with("dummy.tcx")
|
||||
|
||||
assert isinstance(workout_data, WorkoutData)
|
||||
assert isinstance(workout_data.metadata, WorkoutMetadata)
|
||||
assert workout_data.metadata.file_type == "TCX"
|
||||
assert workout_data.metadata.start_time == datetime(2023, 1, 1, 10, 0, 0)
|
||||
assert workout_data.metadata.duration == timedelta(seconds=3600)
|
||||
assert workout_data.time_series_data.empty # Currently, no time series data is mocked
|
||||
Reference in New Issue
Block a user