Example #1
0
    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)]
Example #2
0
 def test_case_board_rect_is_None(self):
     with pytest.raises(CaseParameterException):
         Case(one, one, one, None)
Example #3
0
 def test_case_y_decimal(self):
     with pytest.raises(CaseParameterException):
         Case(one, 3.5, one, one)
Example #4
0
 def test_case_y_too_high(self):
     with pytest.raises(CaseParameterException):
         Case(one, 10, one, one)
Example #5
0
 def test_case_y_negative(self):
     with pytest.raises(CaseParameterException):
         Case(one, -1, one, one)
Example #6
0
 def test_case_y_is_not_number(self):
     with pytest.raises(CaseParameterException):
         Case(one, "Tests", one, one)
Example #7
0
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)
Example #8
0
 def test_case_is_crushed_is_none(self):
     with pytest.raises(CaseParameterException):
         Case(one, one, one, one).is_crushed = None
Example #9
0
 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)
Example #10
0
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)
Example #11
0
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
Example #12
0
 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))
Example #13
0
class TestCaseConstructorClass(object):
    def test_case_init_values(self):

        case = Case(1, 2, one, one)
        assert case.x == 2
        assert case.y == 1
Example #14
0
 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)
Example #15
0
 def test_case_rect_is_not_rect(self):
     with pytest.raises(CaseParameterException):
         Case(one, one, one, one).rect = "Tests"
Example #16
0
 def test_case_board_rect_is_not_number(self):
     with pytest.raises(CaseParameterException):
         Case(one, one, one, -1)
Example #17
0
 def test_case_board_rect_is_not_decimal(self):
     with pytest.raises(CaseParameterException):
         Case(one, one, one, 3.5)
Example #18
0
 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")
Example #19
0
 def test_case_is_selected_is_not_bool(self):
     with pytest.raises(CaseParameterException):
         Case(one, one, one, one).is_crushed = "Tests"
Example #20
0
 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)