Skip to content

Commit

Permalink
chore: Fix type hinting in test_default_game_master.py and test_base.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hmasdev committed Sep 1, 2024
1 parent 20dcf44 commit 842704e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions tests/game_master/test_default_game_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def test_DefaultGameMaster_ask_to_vote(
llm_config=False,
)
master.last_message = mocker.MagicMock(return_value={'content': expected})
master._clean_name = mocker.MagicMock(side_effect=lambda _: expected)
master._clean_name = mocker.MagicMock(side_effect=lambda _: expected) # type: ignore # noqa
player = master.alive_players[0]
# execute
actual = master.ask_to_vote(player)
Expand Down Expand Up @@ -367,7 +367,7 @@ def test_DefaultGameMaster_daytime_discussion(
llm_config=False,
)
expected = {p.name: f'vote_{p.name}' for p in master.alive_players}
master.ask_to_vote = mocker.MagicMock(side_effect=lambda player, *args, **kwargs: expected.get(player.name)) # noqa
master.ask_to_vote = mocker.MagicMock(side_effect=lambda player, *args, **kwargs: expected.get(player.name)) # type: ignore # noqa
run_chat_spy = mocker.spy(master, 'run_chat')
# execute
actual = master.daytime_discussion()
Expand Down Expand Up @@ -399,7 +399,7 @@ def test_DefaultGameMaster_nighttime_action_with_2_or_more_werewolves(
)
expected = {p.name: f'vote_{p.name}' for p in master.alive_players}
for player in master.alive_players:
player.act_in_night = mocker.MagicMock(return_value=f'vote_{player.name}') # noqa
player.act_in_night = mocker.MagicMock(return_value=f'vote_{player.name}') # type: ignore # noqa
run_chat_spy = mocker.spy(master, 'run_chat')
assert len(master.alive_werewolves) == n_werewolves
# execute
Expand Down Expand Up @@ -427,7 +427,7 @@ def test_DefaultGameMaster_nighttime_action_with_1_werewolf(
)
expected = {p.name: f'vote_{p.name}' for p in master.alive_players}
for player in master.alive_players:
player.act_in_night = mocker.MagicMock(return_value=f'vote_{player.name}') # noqa
player.act_in_night = mocker.MagicMock(return_value=f'vote_{player.name}') # type: ignore # noqa
send_spy = mocker.spy(master, 'send')
assert len(master.alive_werewolves) == 1
# execute
Expand Down
11 changes: 6 additions & 5 deletions tests/game_player/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from werewolf.game_player.knight import Knight
from werewolf.game_player.villager import Villager
from werewolf.game_player.werewolf import Werewolf
from werewolf.const import ERole, EStatus
from werewolf.const import ERole, ESide, ESideVictoryCondition, EStatus


@pytest.mark.parametrize(
Expand Down Expand Up @@ -49,17 +49,18 @@ def test_BaseWerewolfPlayer_vote(mocker: MockerFixture) -> None:
assert player.vote(master) == master.ask_to_vote.return_value


def test_BaseWerewolfPlayer_act_in_night() -> None:
def test_BaseWerewolfPlayer_act_in_night(mocker: MockerFixture) -> None:
master = mocker.MagicMock(IWerewolfGameMaster)
player = BaseWerewolfPlayer('name', llm_config=False)
assert player.act_in_night(None) is None
assert player.act_in_night(master) is None


def test_BaseWerewolfPlayer_valid() -> None:
player = BaseWerewolfPlayer('name', llm_config=False)
assert not player.valid()
player.role = ERole.Werewolf
assert not player.valid()
player.side = ERole.Werewolf
player.side = ESide.Werewolf
assert not player.valid()
player.victory_condition = ERole.Werewolf
player.victory_condition = ESideVictoryCondition.WerewolvesWinCondition.value # noqa
assert player.valid()

0 comments on commit 842704e

Please sign in to comment.