Skip to content

Commit

Permalink
ADD: rubber tests
Browse files Browse the repository at this point in the history
Signed-off-by: Segelzwerg <25705862+Segelzwerg@users.noreply.github.com>
  • Loading branch information
Segelzwerg committed Oct 26, 2022
1 parent e482397 commit 08359a9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/whist_core/session/test_table.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from unittest.mock import patch

from tests.whist_core.base_test_case import BaseTestCase
from whist_core.error.table_error import TeamFullError, TableFullError, TableNotReadyError, \
TableNotStartedError, PlayerNotJoinedError
from whist_core.game.errors import RubberNotDoneError
from whist_core.game.rubber import Rubber
from whist_core.session.matcher import RandomMatcher, RoundRobinMatcher
from whist_core.session.table import Table
Expand Down Expand Up @@ -100,3 +103,25 @@ def test_not_ready_start(self):
def test_rubber_without_start(self):
with self.assertRaises(TableNotStartedError):
_ = self.table.current_rubber

def test_next_rubber(self):
second_player = Player(username='miles', rating=3000)
self.table.join(self.player)
self.table.join(second_player)
self.table.player_ready(self.player)
self.table.player_ready(second_player)
self.table.start()
with patch('whist_core.game.rubber.Rubber.done', return_value=True):
self.table.next_rubber()
self.assertEqual(2, len(self.table.rubbers))

def test_next_rubber_not_done(self):
second_player = Player(username='miles', rating=3000)
self.table.join(self.player)
self.table.join(second_player)
self.table.player_ready(self.player)
self.table.player_ready(second_player)
self.table.start()
with self.assertRaises(RubberNotDoneError):
self.table.next_rubber()
self.assertEqual(2, len(self.table.rubbers))

0 comments on commit 08359a9

Please sign in to comment.