Esempio n. 1
0
 def test_switch_active_side(self):
     _side_a = ((1, 0), (1, 0), (1, 1), (1, 0))
     _side_b = ((1, 0), (1, 1), (1, 1), (1, 0))
     _object = FitObject(_side_a, _side_b)
     self.assertTupleEqual(_side_a, _object.active_side)
     self.assertEqual('a', _object.active_side_name)
     _object.switch_active_side()
     self.assertTupleEqual(_side_b, _object.active_side)
     self.assertEqual('b', _object.active_side_name)
Esempio n. 2
0
    def test_add_object(self):
        _board_object = FitBoard(5, 10)
        _side_a = ((1, 0), (1, 0), (1, 1), (1, 0))
        _side_b = ((1, 0), (1, 1), (1, 1), (1, 0))
        _fit_object = FitObject(_side_a, _side_b)
        _board_object.add_object(_fit_object, 0, 0)
        _expected_board = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                           [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                           [1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
                           [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
        self._test_matrix(_board_object.board, _expected_board)

        _fit_object.switch_active_side()
        self.assertEqual('b', _fit_object.active_side_name)
        self.assertEqual(1, len(_board_object.objects_list))
        self.assertEqual(
            'a', _board_object.objects_list[0].fit_object.active_side_name)