def test_AddStone_CreatesInstance(self): "Creating stone instance" # Stone is not placed on board stone = Stone(board_id=1, user_id=1, row=0, col=2, color=0) self.assertIsNone(stone.full_clean()) stone.save()
def test_CanPlaceStone_PlaceWhiteStoneAfterBlackMove_RaisesException(self): "Checking if user with white stones can place stone after black move" # Create new black stone on board stone = Stone(board_id=1, user_id=1, row=0, col=2, color=0) stone.save() # Place white stone stone = Stone(board_id=1, user_id=2, row=0, col=3, color=1) form = StoneCreateForm(data=model_to_dict(stone)) self.assertTrue(form.is_valid())
def test_CanPlaceStone_PlaceBlackStoneAfterBlackMove_RaisesException(self): "Checking if user with black stones can place stone after black move" # Create new black stone on board stone = Stone(board_id=1, user_id=1, row=0, col=2, color=0) stone.save() # Place next black stone stone = Stone(board_id=1, user_id=1, row=0, col=3, color=0) form = StoneCreateForm(data=model_to_dict(stone)) self.assertFalse(form.is_valid()) self.assertEqual(form.non_field_errors(), [u'ERR_STONE_002'])