def init_board(self, size_x, size_y): self.size_x = size_x self.size_y = size_y self.rect = pygame.Rect( 0, 0, self.size_x * case_width + (self.size_x - 1) * card_extern_interval + 2 * boarding, self.size_y * case_height + (self.size_y - 1) * card_extern_interval + 2 * boarding) self.rect.center = (board_px, board_py) self.table = [[ Case(x, y, self.rect.x, self.rect.y, self.screen) for x in range(size_x) ] for y in range(size_y)]
def test_case_board_rect_is_None(self): with pytest.raises(CaseParameterException): Case(one, one, one, None)
def test_case_y_decimal(self): with pytest.raises(CaseParameterException): Case(one, 3.5, one, one)
def test_case_y_too_high(self): with pytest.raises(CaseParameterException): Case(one, 10, one, one)
def test_case_y_negative(self): with pytest.raises(CaseParameterException): Case(one, -1, one, one)
def test_case_y_is_not_number(self): with pytest.raises(CaseParameterException): Case(one, "Tests", one, one)
class TestCasePutFunctionClass(object): def test_case_put_function_on_occupied_case(self): with pytest.raises(CaseParameterException): case = Case(one, one, one, one) case.put(Card(one, one, tuple_ones)) case.put(Card(one, one, tuple_ones)) def test_case_put_function_on_crushed_case(self): with pytest.raises(CaseParameterException): case = Case(one, one, one, one) case.crush() case.put(Card(one, one, tuple_ones)) def test_case_put_function_change_card_x_value(self): case = Case(2, 1, one, one) case.put(Card(one, one, tuple_ones)) assert case.inside.x == 1 def test_case_put_function_change_card_y_value(self): case = Case(1, 2, one, one) case.put(Card(one, one, tuple_ones)) assert case.inside.y == 1 def test_case_put_function_change_card_px_value(self): case = Case(one, one, one, one) case.put(Card(one, one, tuple_ones)) assert case.inside.px == case.px + 2 def test_case_put_function_change_card_py_value(self): case = Case(one, one, one, one)
def test_case_is_crushed_is_none(self): with pytest.raises(CaseParameterException): Case(one, one, one, one).is_crushed = None
def test_case_is_cursor_on_function_first_argument_is_negative(self): with pytest.raises(CaseParameterException): case = Case(one, one, one, one) case.is_cursor_on(-1, one)
class TestCaseIsOccupiedFunctionClass(object): def test_case_is_occupied_function_result_is_bool(self): case = Case(one, one, one, one) assert isinstance(case.is_occupied(), bool)
class TestCaseCrushFunctionClass(object): def test_case_crush_function_result(self): case = Case(one, one, one, one) assert not case.is_crushed case.crush() assert case.is_crushed
def test_case_put_function_on_crushed_case(self): with pytest.raises(CaseParameterException): case = Case(one, one, one, one) case.crush() case.put(Card(one, one, tuple_ones))
class TestCaseConstructorClass(object): def test_case_init_values(self): case = Case(1, 2, one, one) assert case.x == 2 assert case.y == 1
def test_case_rect_is_h_is_incorrect(self): with pytest.raises(CaseParameterException): case = Case(one, one, one, one) case.rect = pygame.Rect(case.px, case.py, case_width, 4)
def test_case_rect_is_not_rect(self): with pytest.raises(CaseParameterException): Case(one, one, one, one).rect = "Tests"
def test_case_board_rect_is_not_number(self): with pytest.raises(CaseParameterException): Case(one, one, one, -1)
def test_case_board_rect_is_not_decimal(self): with pytest.raises(CaseParameterException): Case(one, one, one, 3.5)
def test_case_is_cursor_on_function_second_argument_is_not_number(self): with pytest.raises(CaseParameterException): case = Case(one, one, one, one) case.is_cursor_on(one, "Tests")
def test_case_is_selected_is_not_bool(self): with pytest.raises(CaseParameterException): Case(one, one, one, one).is_crushed = "Tests"
def test_case_is_cursor_on_function_second_argument_is_decimal(self): with pytest.raises(CaseParameterException): case = Case(one, one, one, one) case.is_cursor_on(one, 3.5)