Skip to content

Commit

Permalink
Other minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Askaholic committed Feb 2, 2025
1 parent 7d2aa8a commit ec6cb17
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion server/games/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ def __eq__(self, other):
return self.id == other.id

def __hash__(self):
return self.id.__hash__()
return hash(self.id)

def __str__(self) -> str:
return (
Expand Down
8 changes: 4 additions & 4 deletions tests/unit_tests/test_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ async def game_player_scores(database, game):
return set(tuple(f) for f in result.fetchall())


async def test_initialization(game: Game):
def test_initialization(game: Game):
assert game.state is GameState.INITIALIZING
assert game.enforce_rating is False


async def test_instance_logging(database, game_stats_service):
def test_instance_logging(database, game_stats_service):
logger = logging.getLogger(f"{Game.__qualname__}.5")
logger.debug = mock.Mock()
mock_parent = mock.Mock()
Expand Down Expand Up @@ -865,13 +865,13 @@ async def test_get_army_score_conflicting_results_tied(game, game_add_players):
assert game.get_army_score(1) == 123


async def test_equality(game):
def test_equality(game):
assert game == game
assert game != Game(5, mock.Mock(), mock.Mock(), mock.Mock())
assert game != "a string"


async def test_hashing(game):
def test_hashing(game):
assert {
game: 1,
Game(game.id, mock.Mock(), mock.Mock(), mock.Mock()): 1
Expand Down
6 changes: 4 additions & 2 deletions tests/unit_tests/test_game_stats_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ def achievement_service():


@pytest.fixture()
def game_stats_service(event_service, achievement_service):
return GameStatsService(event_service, achievement_service)
async def game_stats_service(event_service, achievement_service):
service = GameStatsService(event_service, achievement_service)
await service.initialize()
return service


@pytest.fixture()
Expand Down

0 comments on commit ec6cb17

Please sign in to comment.