def test_arrow_init_values(self): arrow = Arrow(1, 2, 3, color=red) assert arrow.direction == 1 assert arrow.px == 2 assert arrow.py == 3 assert arrow.color == red assert arrow.polygone is not None
def __init__(self, card_number, player_number, color, screen, number_of_arrows=None): self.player = player_number self.number = card_number self.color = color self.screen = screen if self.number == 1: self.number_of_arrows = randint(1, 2) self.image_key = golem_image_key elif self.number == 2: self.number_of_arrows = randint(2, 4) self.image_key = golem_image_key elif self.number == 3: self.number_of_arrows = randint(3, 6) self.image_key = golem_image_key elif self.number == 4: self.number_of_arrows = 4 self.image_key = golem_image_key elif self.number == 5: self.number_of_arrows = number_of_arrows self.image_key = golem_image_key self.is_selected = False self.combo_percent = 0 self.combo_color = None self.combo_direction = None self.rect = pygame.Rect(0, 0, card_width, card_height) self.name = str(self.number) + str(self.player)[0] self.life_point = 20 - 2 * self.number_of_arrows self.max_life_point = self.life_point self.arrows = { direction: None for direction in Directions.all_directions } while len(self.get_arrows_directions()) != self.number_of_arrows: direction = Directions.all_directions[randint( 0, len(Directions.all_directions) - 1)] if not self.arrows.get(direction): self.arrows[direction] = Arrow(direction, self.rect.x, self.rect.y, self.screen)
def test_arrow_py_is_not_number(self): with pytest.raises(ArrowParameterException): Arrow(one, one, "Tests")
def test_arrow_py_negative(self): with pytest.raises(ArrowParameterException): Arrow(one, one, -1)
def test_arrow_px_negative(self): with pytest.raises(ArrowParameterException): Arrow(one, -1, tuple_ones)
def test_arrow_px_decimal(self): with pytest.raises(ArrowParameterException): Arrow(one, 3.5, tuple_ones)
def test_arrow_color_r_decimal(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one, color=(3.5, 1, 1))
def test_arrow_polygone_is_none(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one).polygone = None
def test_arrow_color_not_tuple(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one, color="Tests")
def test_arrow_color_r_negative(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one, color=(-1, 1, 1))
def test_arrow_polygone_3_coor_2_negative(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one).polygone = [[one, one], [one, one], [one, -1]]
def test_arrow_py_decimal(self): with pytest.raises(ArrowParameterException): Arrow(one, one, 3.5)
def test_arrow_polygone_3_coor_2_not_number(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one).polygone = [[one, one], [one, one], [one, "Tests"]]
def test_arrow_polygone_3_incorect_length(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one).polygone = [[one, one], [one, one], [one]]
def test_arrow_polygone_3_not_list(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one).polygone = [[one, one], [one, one], "Tests"]
def test_arrow_direction_negative(self): with pytest.raises(ArrowParameterException): Arrow(-1, one, one)
def test_arrow_direction_is_not_number(self): with pytest.raises(ArrowParameterException): Arrow("Tests", one, one)
def test_arrow_color_is_none(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one, color=None)
def test_arrow_direction_too_high(self): with pytest.raises(ArrowParameterException): Arrow(1000, one, one)
def test_arrow_color_size_too_high(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one, color=(1, 1, 1, 1))
def test_arrow_bool_value(self): assert Arrow(one, one, one)
def test_arrow_color_r_to_big(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one, color=(300, 1, 1))
def test_arrow_set_position_function(self): arrow = Arrow(one, one, one) arrow.set_position(2, 3) assert arrow.px == 2 assert arrow.py == 3
def test_arrow_color_g_not_number(self): with pytest.raises(ArrowParameterException): Arrow(one, one, one, color=(1, "Tests", 1))
def test_arrow_direction_decimal(self): with pytest.raises(ArrowParameterException): Arrow(3.5, one, one)