Refactor tools module: removed unused tools, commented out legacy registrations, updated mock data in tests, consolidated imports, and standardized naming conventions in the codebase.
This commit is contained in:
parent
ec0fe38861
commit
328e597f48
16 changed files with 86 additions and 386 deletions
|
|
@ -32,6 +32,7 @@ def mock_profile_data():
|
|||
"isVerified": True,
|
||||
"level": 50,
|
||||
"rating": {"rating": 1500, "deviation": 100},
|
||||
"isProUser": True,
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -45,7 +46,38 @@ def mock_game_data():
|
|||
"player": {
|
||||
"guesses": [
|
||||
{"roundScoreInPoints": 5000, "distanceInMeters": 0, "time": 10},
|
||||
{"roundScoreInPoints": 4500, "distanceInMeters": 100, "time": 15},
|
||||
{"roundScoreInPoints": 4500, "distanceInMeters": 120, "time": 15},
|
||||
{"roundScoreInPoints": 3800, "distanceInMeters": 100, "time": 20},
|
||||
{"roundScoreInPoints": 4900, "distanceInMeters": 100, "time": 25},
|
||||
{"roundScoreInPoints": 5000, "distanceInMeters": 100, "time": 35},
|
||||
]
|
||||
},
|
||||
"state": "finished",
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_stats_data():
|
||||
"""Standard user stats response data."""
|
||||
return {
|
||||
"games": 100,
|
||||
"totalRounds": 500,
|
||||
"score": 2250000,
|
||||
"perfectGames": 10,
|
||||
"winRate": 0.65,
|
||||
"bestStreak": 25,
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_season_stats_data():
|
||||
"""Standard season stats response data."""
|
||||
return {
|
||||
"id": "season-2024-1",
|
||||
"name": "Season 1 2024",
|
||||
"position": 150,
|
||||
"elo": 1850,
|
||||
"games": 45,
|
||||
"wins": 30,
|
||||
"tier": "Gold",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class TestSessionManager:
|
|||
"""Tests for SessionManager."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_login_success(self, mock_profile_response):
|
||||
async def test_login_success(self, mock_profile_data):
|
||||
"""Test successful login flow."""
|
||||
manager = SessionManager()
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ class TestSessionManager:
|
|||
# Mock profile response
|
||||
profile_response = MagicMock()
|
||||
profile_response.status_code = 200
|
||||
profile_response.json.return_value = mock_profile_response
|
||||
profile_response.json.return_value = mock_profile_data
|
||||
|
||||
mock_client.post = AsyncMock(return_value=login_response)
|
||||
mock_client.get = AsyncMock(return_value=profile_response)
|
||||
|
|
@ -113,7 +113,7 @@ class TestSessionManager:
|
|||
assert session_token is not None
|
||||
assert len(session_token) > 0
|
||||
assert session.ncfa_cookie == "test_ncfa_cookie_value"
|
||||
assert session.user_id == "test-user-id-123"
|
||||
assert session.user_id == "test-user-id"
|
||||
assert session.username == "TestPlayer"
|
||||
assert session.is_valid()
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ class TestSessionManager:
|
|||
await manager.login("test@example.com", "password")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_logout(self, mock_profile_response):
|
||||
async def test_logout(self, mock_profile_data):
|
||||
"""Test logout functionality."""
|
||||
manager = SessionManager()
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ class TestSessionManager:
|
|||
|
||||
profile_response = MagicMock()
|
||||
profile_response.status_code = 200
|
||||
profile_response.json.return_value = mock_profile_response
|
||||
profile_response.json.return_value = mock_profile_data
|
||||
|
||||
mock_client.post = AsyncMock(return_value=login_response)
|
||||
mock_client.get = AsyncMock(return_value=profile_response)
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ from geoguessr_mcp.models.RoundGuess import RoundGuess
|
|||
class TestGame:
|
||||
"""Tests for Game model."""
|
||||
|
||||
def test_from_api_response(self, mock_game_response):
|
||||
def test_from_api_response(self, mock_game_data):
|
||||
"""Test creating game from API response."""
|
||||
game = Game.from_api_response(mock_game_response)
|
||||
game = Game.from_api_response(mock_game_data)
|
||||
|
||||
assert game.token == "ABC123XYZ"
|
||||
assert game.token == "ABC123"
|
||||
assert game.map_name == "World"
|
||||
assert game.mode == "standard"
|
||||
assert game.finished is True
|
||||
|
|
@ -52,11 +52,11 @@ class TestGame:
|
|||
assert guess.distance_meters == 150.5
|
||||
assert guess.time_seconds == 25
|
||||
|
||||
def test_to_dict(self, mock_game_response):
|
||||
def test_to_dict(self, mock_game_data):
|
||||
"""Test serializing game to dict."""
|
||||
game = Game.from_api_response(mock_game_response)
|
||||
game = Game.from_api_response(mock_game_data)
|
||||
result = game.to_dict()
|
||||
|
||||
assert result["token"] == "ABC123XYZ"
|
||||
assert result["token"] == "ABC123"
|
||||
assert len(result["rounds"]) == 5
|
||||
assert result["total_score"] > 0
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ from geoguessr_mcp.models import SeasonStats
|
|||
class TestSeasonStats:
|
||||
"""Tests for SeasonStats model."""
|
||||
|
||||
def test_from_api_response(self, mock_season_stats_response):
|
||||
def test_from_api_response(self, mock_season_stats_data):
|
||||
"""Test creating season stats from API response."""
|
||||
stats = SeasonStats.from_api_response(mock_season_stats_response)
|
||||
stats = SeasonStats.from_api_response(mock_season_stats_data)
|
||||
|
||||
assert stats.season_id == "season-2024-1"
|
||||
assert stats.season_name == "Season 1 2024"
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ from geoguessr_mcp.models import UserProfile
|
|||
class TestUserProfile:
|
||||
"""Tests for UserProfile model."""
|
||||
|
||||
def test_from_api_response(self, mock_profile_response):
|
||||
def test_from_api_response(self, mock_profile_data):
|
||||
"""Test creating profile from API response."""
|
||||
profile = UserProfile.from_api_response(mock_profile_response)
|
||||
profile = UserProfile.from_api_response(mock_profile_data)
|
||||
|
||||
assert profile.id == "test-user-id-123"
|
||||
assert profile.id == "test-user-id"
|
||||
assert profile.nick == "TestPlayer"
|
||||
assert profile.email == "test@example.com"
|
||||
assert profile.country == "US"
|
||||
assert profile.country == "FR"
|
||||
assert profile.level == 50
|
||||
assert profile.is_verified is True
|
||||
assert profile.is_pro is True
|
||||
|
|
@ -33,11 +33,11 @@ class TestUserProfile:
|
|||
assert profile.email == ""
|
||||
assert profile.level == 0
|
||||
|
||||
def test_to_dict(self, mock_profile_response):
|
||||
def test_to_dict(self, mock_profile_data):
|
||||
"""Test serializing profile to dict."""
|
||||
profile = UserProfile.from_api_response(mock_profile_response)
|
||||
profile = UserProfile.from_api_response(mock_profile_data)
|
||||
result = profile.to_dict()
|
||||
|
||||
assert result["id"] == "test-user-id-123"
|
||||
assert result["id"] == "test-user-id"
|
||||
assert result["nick"] == "TestPlayer"
|
||||
assert "raw_data" not in result
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ from geoguessr_mcp.models import UserStats
|
|||
class TestUserStats:
|
||||
"""Tests for UserStats model."""
|
||||
|
||||
def test_from_api_response(self, mock_stats_response):
|
||||
def test_from_api_response(self, mock_stats_data):
|
||||
"""Test creating stats from API response."""
|
||||
stats = UserStats.from_api_response(mock_stats_response)
|
||||
stats = UserStats.from_api_response(mock_stats_data)
|
||||
|
||||
assert stats.games_played == 100
|
||||
assert stats.rounds_played == 500
|
||||
|
|
@ -42,9 +42,9 @@ class TestUserStats:
|
|||
assert stats.perfect_games == 5
|
||||
assert stats.streak_best == 15
|
||||
|
||||
def test_to_dict(self, mock_stats_response):
|
||||
def test_to_dict(self, mock_stats_data):
|
||||
"""Test serializing stats to dict."""
|
||||
stats = UserStats.from_api_response(mock_stats_response)
|
||||
stats = UserStats.from_api_response(mock_stats_data)
|
||||
result = stats.to_dict()
|
||||
|
||||
assert result["games_played"] == 100
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue