def test_solved(self): board_1 = obj.VialBoard([[1, 1], [2, 2], []]) board_2 = obj.VialBoard([[1, 2], [2, 1], []]) board_3 = obj.VialBoard([[1], [1], []]) self.assertTrue(board_1.solved()) self.assertFalse(board_2.solved()) self.assertFalse(board_3.solved())
def test_restart_game(self): board_1 = obj.VialBoard([[1, 2, 3], []]) board_2 = obj.VialBoard([[1, 2, 3], []]) board_1.move(0, 1) self.assertNotEqual(board_1, board_2) board_1.restart_game() self.assertEqual(board_1, board_2) self.assertEqual([], board_1.path)
def test_init(self): self.assertIsInstance(self.vial_board, obj.VialBoard) with self.assertRaises(AssertionError): obj.VialBoard([1, 2, 3]) with self.assertRaises(AssertionError): obj.VialBoard([self.vial_2, 2, 3]) with self.assertRaises(AssertionError): obj.VialBoard([self.vial_3])
def test_get_path(self): board = obj.VialBoard([[1, 1, 2], [2, 2, 1], []]) board.move(2, 0) self.assertEqual([], board.path) board.move(0, 2) self.assertEqual([(0, 2)], board.path) board.move(1, 0) self.assertEqual([(0, 2), (1, 0)], board.path) board.move(1, 0) self.assertEqual([(0, 2), (1, 0)], board.path) board_2 = obj.VialBoard([[1, 1], [2, 2], []]) board_2.move(0, 2) self.assertEqual([(0, 2), (0, 2)], board_2.path)
def setUp(self): self.vial_1 = obj.Vial(3, [1, 2, 3]) self.vial_2 = obj.Vial(3) self.vial_3 = obj.Vial(5, [1, 2]) self.vial_4 = obj.Vial(3, [1, 1]) self.vial_5 = obj.Vial(3, [10]) self.vial_board = obj.VialBoard( [self.vial_1, self.vial_2, self.vial_4, self.vial_5])
def test_init_from_lists(self): vial_board = obj.VialBoard([[0, 1, 1], [], [1, 0, 0]]) self.assertIsInstance(vial_board, obj.VialBoard) self.assertEqual([0, 1, 1], vial_board[0]) vial_board.move(0, 1) self.assertEqual([0], vial_board[0]) self.assertEqual([1, 1], vial_board[1]) self.assertEqual([1, 1], vial_board[1]) self.assertEqual([(0, 1), (0, 1)], vial_board.path)
def test_step_back(self): board = obj.VialBoard([[1, 1], []]) board.move(0, 1) board.step_back() self.assertEqual([[1, 1], []], board) self.assertEqual([], board.path)
def test_get_path_for_multimove(self): board = obj.VialBoard([[1, 1], []]) board.move(0, 1) self.assertEqual([(0, 1), (0, 1)], board.path)
def test_get_set_of_items(self): board_1 = obj.VialBoard([[1, 1, 3], [2, 2, 1], []]) s = board_1.get_set_of_items() self.assertEqual(s, {1, 2, 3})