def test_draw_objects(self): polygon1 = TestUtils.generate_test_polygon(seed=0, points=12, radius_range=(1, 10)) polygon2 = copy.deepcopy(polygon1) polygon2.style().set_shadow('off') opengraph1 = TestUtils.generate_test_opengraph(seed=0, points=12, radius_range=(1, 10)) opengraph2 = copy.deepcopy(opengraph1) opengraph2.style().set_shadow('off') text = Text() arrow1 = RightArrow() arrow2 = RightArrow() arrow2.style().set_shadow('off') objects = [ polygon1, polygon2, opengraph1, opengraph2, text, arrow2, arrow1 ] self.__backend.push_surface = MagicMock() self.__backend.pop_surface = MagicMock() self.__backend.draw_polygon_shadow = MagicMock() self.__backend.draw_polygon = MagicMock() self.__backend.draw_open_graph_shadow = MagicMock() self.__backend.draw_open_graph = MagicMock() self.__backend.draw_text = MagicMock() self.__backend.draw_text_shadow = MagicMock() self.__backend.translate = MagicMock() self.__backend.blur_surface = MagicMock() self.__backend.draw_objects(objects) assert self.__backend.push_surface.call_count == self.__backend.pop_surface.call_count assert self.__backend.translate.call_count == 2 assert self.__backend.draw_polygon.call_count == 4 self.__backend.draw_polygon.assert_any_call(polygon1) self.__backend.draw_polygon.assert_any_call(polygon2) self.__backend.draw_polygon.assert_any_call(arrow1) self.__backend.draw_polygon.assert_any_call(arrow2) assert self.__backend.draw_polygon_shadow.call_count == 2 self.__backend.draw_polygon_shadow.assert_any_call(polygon1) self.__backend.draw_polygon_shadow.assert_any_call(arrow1) assert self.__backend.draw_open_graph.call_count == 4 self.__backend.draw_open_graph.assert_any_call(polygon1.frame()) self.__backend.draw_open_graph.assert_any_call(polygon2.frame()) self.__backend.draw_open_graph.assert_any_call(opengraph1) self.__backend.draw_open_graph.assert_any_call(opengraph2) self.__backend.draw_open_graph_shadow.assert_called_once_with( opengraph1) self.__backend.draw_text.assert_called_once_with(text) assert self.__backend.blur_surface.call_count == 2
def test_draw_objects(self): polygon1 = TestUtils.generate_test_polygon(seed = 0, points = 12, radius_range = (1, 10)) polygon2 = copy.deepcopy(polygon1) polygon2.style().set_shadow('off') opengraph1 = TestUtils.generate_test_opengraph(seed = 0, points = 12, radius_range = (1, 10)) opengraph2 = copy.deepcopy(opengraph1) opengraph2.style().set_shadow('off') text = Text() arrow1 = RightArrow() arrow2 = RightArrow() arrow2.style().set_shadow('off') objects = [polygon1, polygon2, opengraph1, opengraph2, text, arrow2, arrow1] self.__backend.push_surface = MagicMock() self.__backend.pop_surface = MagicMock() self.__backend.draw_polygon_shadow = MagicMock() self.__backend.draw_polygon = MagicMock() self.__backend.draw_open_graph_shadow = MagicMock() self.__backend.draw_open_graph = MagicMock() self.__backend.draw_text = MagicMock() self.__backend.draw_text_shadow = MagicMock() self.__backend.translate = MagicMock() self.__backend.blur_surface = MagicMock() self.__backend.draw_objects(objects) assert self.__backend.push_surface.call_count == self.__backend.pop_surface.call_count assert self.__backend.translate.call_count == 2 assert self.__backend.draw_polygon.call_count == 4 self.__backend.draw_polygon.assert_any_call(polygon1) self.__backend.draw_polygon.assert_any_call(polygon2) self.__backend.draw_polygon.assert_any_call(arrow1) self.__backend.draw_polygon.assert_any_call(arrow2) assert self.__backend.draw_polygon_shadow.call_count == 2 self.__backend.draw_polygon_shadow.assert_any_call(polygon1) self.__backend.draw_polygon_shadow.assert_any_call(arrow1) assert self.__backend.draw_open_graph.call_count == 4 self.__backend.draw_open_graph.assert_any_call(polygon1.frame()) self.__backend.draw_open_graph.assert_any_call(polygon2.frame()) self.__backend.draw_open_graph.assert_any_call(opengraph1) self.__backend.draw_open_graph.assert_any_call(opengraph2) self.__backend.draw_open_graph_shadow.assert_called_once_with(opengraph1) self.__backend.draw_text.assert_called_once_with(text) assert self.__backend.blur_surface.call_count == 2
def test_init(self): arrow = RightArrow() assert arrow != None arrow = RightArrow((3, -1)) assert arrow.position() == (3, -1)