Add comprehensive unit tests: reorganized test files, removed outdated e2e and unit tests for auth and profile_service, introduced tests for SchemaRegistry, UserProfile, UserStats, Game, Achievement, and SeasonStats.
This commit is contained in:
parent
f6226f51e4
commit
f9011dbeaa
24 changed files with 623 additions and 126 deletions
62
src/tests/unit/models/test_game.py
Normal file
62
src/tests/unit/models/test_game.py
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
"""
|
||||
Unit tests for validating the functionality of the Game model and related components.
|
||||
|
||||
These tests ensure the proper creation and behavior of Game and RoundGuess
|
||||
instances when interacting with API responses or performing operations like
|
||||
serialization. The tests cover both standard and edge cases.
|
||||
"""
|
||||
|
||||
from geoguessr_mcp.models.Game import Game
|
||||
from geoguessr_mcp.models.RoundGuess import RoundGuess
|
||||
|
||||
|
||||
class TestGame:
|
||||
"""Tests for Game model."""
|
||||
|
||||
def test_from_api_response(self, mock_game_response):
|
||||
"""Test creating game from API response."""
|
||||
game = Game.from_api_response(mock_game_response)
|
||||
|
||||
assert game.token == "ABC123XYZ"
|
||||
assert game.map_name == "World"
|
||||
assert game.mode == "standard"
|
||||
assert game.finished is True
|
||||
assert len(game.rounds) == 5
|
||||
assert game.total_score == 5000 + 4500 + 3800 + 4900 + 5000
|
||||
|
||||
def test_from_api_response_minimal(self):
|
||||
"""Test creating game from minimal response."""
|
||||
data = {
|
||||
"token": "TEST",
|
||||
"type": "challenge",
|
||||
"player": {"guesses": []},
|
||||
}
|
||||
game = Game.from_api_response(data)
|
||||
|
||||
assert game.token == "TEST"
|
||||
assert game.mode == "challenge"
|
||||
assert game.total_score == 0
|
||||
assert len(game.rounds) == 0
|
||||
|
||||
def test_round_guess(self):
|
||||
"""Test creating round guess."""
|
||||
data = {
|
||||
"roundScoreInPoints": 4500,
|
||||
"distanceInMeters": 150.5,
|
||||
"time": 25,
|
||||
}
|
||||
guess = RoundGuess.from_api_response(data, round_num=1)
|
||||
|
||||
assert guess.round_number == 1
|
||||
assert guess.score == 4500
|
||||
assert guess.distance_meters == 150.5
|
||||
assert guess.time_seconds == 25
|
||||
|
||||
def test_to_dict(self, mock_game_response):
|
||||
"""Test serializing game to dict."""
|
||||
game = Game.from_api_response(mock_game_response)
|
||||
result = game.to_dict()
|
||||
|
||||
assert result["token"] == "ABC123XYZ"
|
||||
assert len(result["rounds"]) == 5
|
||||
assert result["total_score"] > 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue