Skip to content

Commit aa4d383

Browse files
Shi-553Shi-553
authored andcommitted
Refactor: Reorganize fixture structure and update documentation
- Move fixture generation to separate repository (music_assistant_nicovideo_fixtures) - Restructure fixtures: use fixture_data/ for generated data - Update fixture loading to use new structure with fixture_type_mappings - Remove embedded fixture generation scripts from tests - Add comprehensive README for test directory - Update VS Code tasks for easier fixture updates - Delete obsolete GitHub workflow for fixture generation
1 parent e7a93ca commit aa4d383

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2039
-1140
lines changed

.github/workflows/nicovideo-fixtures-update-and-test.yml

Lines changed: 0 additions & 119 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Niconico Provider Tests
2+
3+
Test suite for the Niconico music provider in Music Assistant.
4+
5+
## Fixtures
6+
7+
Test fixtures are JSON snapshots of Niconico API responses used for testing converters and business logic.
8+
9+
### Updating Fixtures
10+
11+
Fixtures are generated using a dedicated tool repository:
12+
13+
**[music-assistant-nicovideo-fixtures](https://github.com/Shi-553/music-assistant-nicovideo-fixtures)**
14+
15+
To update fixtures:
16+
17+
1. Clone the fixtures repository (if not already cloned)
18+
2. Follow setup instructions in that repository
19+
3. Generate new fixtures with your test account: `python scripts/main.py`
20+
4. Copy generated fixtures `cp -r /path/to/music_assistant_nicovideo_fixtures/fixture_data tests/providers/nicovideo/`
21+
22+
**Important:** Always use a dedicated test account, never your personal account!
23+
24+
## Running Tests
25+
26+
```bash
27+
# Run all nicovideo provider tests
28+
pytest tests/providers/nicovideo/
29+
30+
# Run specific test file
31+
pytest tests/providers/nicovideo/test_converters.py
32+
33+
# Run with coverage
34+
pytest --cov=music_assistant.providers.nicovideo tests/providers/nicovideo/
35+
```
36+
37+
## Test Structure
38+
39+
```
40+
tests/providers/nicovideo/
41+
├── fixture_data/ # Fixture data from generator repository
42+
│ ├── fixtures/ # Static JSON fixtures (API responses)
43+
│ ├── fixture_type_mappings.py # Auto-generated type mappings
44+
│ └── shared_types.py # Custom fixture types
45+
├── fixtures/ # Fixture loading utilities
46+
├── __snapshots__/ # Generated snapshots for comparison
47+
└── test_*.py # Test files
48+
```

tests/providers/nicovideo/constants.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
# Test fixtures directories
88
_BASE_DIR = pathlib.Path(__file__).parent
9-
GENERATED_DIR = _BASE_DIR / "generated"
10-
GENERATED_FIXTURES_DIR = GENERATED_DIR / "fixtures"
11-
GENERATED_SNAPSHOTS_DIR = GENERATED_DIR / "snapshots"
9+
FIXTURE_DATA_DIR = _BASE_DIR / "fixture_data"
10+
GENERATED_FIXTURES_DIR = FIXTURE_DATA_DIR / "fixtures"
1211

1312
# Sample test data IDs
1413
SAMPLE_VIDEO_ID = "sm45285955"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Fixture data package for nicovideo provider tests."""

tests/providers/nicovideo/generated/fixture_types.py renamed to tests/providers/nicovideo/fixture_data/fixture_type_mappings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from niconico.objects.video import Mylist
2020
from niconico.objects.video.watch import WatchData
2121

22-
from music_assistant.providers.nicovideo.converters.stream import StreamConversionData
22+
from .shared_types import StreamFixtureData
2323

2424
if TYPE_CHECKING:
2525
from pydantic import BaseModel
@@ -43,5 +43,5 @@
4343
"search/series_search.json": ListSearchData,
4444
"history/user_history.json": HistoryData,
4545
"history/user_likes.json": LikeHistoryData,
46-
"stream/stream_data.json": StreamConversionData,
46+
"stream/stream_data.json": StreamFixtureData,
4747
}

0 commit comments

Comments
 (0)