Example #1
0
    def test_init(self):
        with pytest.raises(AssertionError, match="Number less than 1"):
            Cell(MIN_NUMBER - 1)

        c = Cell(MIN_NUMBER)
        assert c.get_number() == MIN_NUMBER
        assert c.is_expunged() is False
Example #2
0
    def test_str(self):
        a = Cell(MIN_NUMBER)
        assert str(a) == str(MIN_NUMBER)

        b = Cell(MAX_NUMBER)
        b.expunge()
        assert str(b) == "+" + str(MAX_NUMBER)
Example #3
0
    def test_eq(self):
        a = Cell(MIN_NUMBER)
        assert a != 1

        b = Cell(MAX_NUMBER)
        assert a != b

        c = Cell(MIN_NUMBER)
        assert a == c
Example #4
0
    def test_сell_at(self, ticket_numbers):
        ticket = Ticket(ticket_numbers)

        with pytest.raises(AssertionError, match="Incorrect row or column"):
            ticket.cell_at(0, 1)

        ticket.cell_at(1, 1) == Cell(1)
Example #5
0
    def test_check(self):
        with pytest.raises(AssertionError, match="Number less than 1"):
            Cell._check(MIN_NUMBER - 1)

        with pytest.raises(AssertionError, match="Number greater than 90"):
            Cell._check(MAX_NUMBER + 1)

        try:
            Cell._check(NO_NUMBER)
        except AssertionError:
            pytest.fail("Unexpected AssertionError!")
Example #6
0
    def test_expunge(self):
        c = Cell(MAX_NUMBER)
        assert c.is_expunged() is False

        c.expunge()
        assert c.is_expunged() is True
Example #7
0
 def test_is_no_number(self):
     assert Cell(MAX_NUMBER).is_no_number() is False
     assert Cell(NO_NUMBER).is_no_number() is True
Example #8
0
 def test_get_number(self):
     assert Cell(MIN_NUMBER).get_number() == MIN_NUMBER
     assert Cell(MAX_NUMBER).get_number() == MAX_NUMBER
Example #9
0
    def test_iter(self, ticket_numbers):
        cells = Cells(ticket_numbers)
        expected = [
            Cell(1),
            Cell(11),
            Cell(21),
            Cell(31),
            Cell(41),
            Cell("*"),
            Cell("*"),
            Cell("*"),
            Cell("*"),
            Cell(2),
            Cell(12),
            Cell(22),
            Cell(32),
            Cell(42),
            Cell("*"),
            Cell("*"),
            Cell("*"),
            Cell("*"),
            Cell(3),
            Cell(13),
            Cell(23),
            Cell(33),
            Cell(43),
            Cell("*"),
            Cell("*"),
            Cell("*"),
            Cell("*"),
        ]

        assert list(cells) == expected
Example #10
0
 def test_eq(self, ticket_numbers, other_ticket_numbers):
     assert Cells(ticket_numbers) != Cell(MIN_NUMBER)
     assert Cells(ticket_numbers) != Cells(other_ticket_numbers)
     assert Cells(ticket_numbers) == Cells(ticket_numbers)