Example #1
0
 def test_run(self):
     background = Background((7, 3))
     polygon = TestUtils.generate_test_polygon(seed=0,
                                               points=12,
                                               radius_range=(1, 10))
     polygon_copy = copy.deepcopy(polygon)
     objects = [background, polygon, Translatable()]
     self.__backend.draw_objects = MagicMock()
     self.__backend.create_canvas = MagicMock()
     self.__backend.export_to_file = MagicMock()
     self.__backend.run(objects, "testname")
     self.__backend.draw_objects.assert_called(objects)
     self.__backend.create_canvas.assert_called(objects)
     self.__backend.export_to_file.assert_called_with("testname")
     assert TestUtils.unordered_lists_equal(
         self.__backend.draw_objects.call_args[0][0], objects)
Example #2
0
    def test_run(self):
        parser = StyleParser()
        arrow_style = Style('_arrow_', 'fill', ['red'], 1)
        fill_style = Style('.*', 'fill', ['blue'], 0)
        line_style = Style('_line_', 'fill', ['green'], 2)
        frame_style = Style('.*', 'frame', [[0.1, 0.2, 0.3]], 0)
        custom_fill_style = Style('(abc)|(def)', 'fill', [[0.3, 0.2, 0.3]], 3)
        custom_line_style = Style('line', 'fill', [[0.4, 0.3, 0.3]], 3)
        custom_frame_style = Style('(abc)|(def)', 'frame', [[0.5, 0.2, 0.3]],
                                   3)
        polygon1 = Polygon([Node(0, 0)])
        opengraph1 = OpenGraph()
        opengraph2 = OpenGraph()
        opengraph2.add_name('line')
        arrow = Arrow()
        background = Background()
        polygon2 = Polygon([Node(0, 0)])
        polygon2.add_name('abc')
        polygon3 = Polygon([Node(0, 0)])
        polygon3.add_name('def')

        objects = [
            arrow_style, fill_style, line_style, frame_style,
            custom_fill_style, custom_line_style, custom_frame_style, polygon1,
            polygon2, polygon3, opengraph1, opengraph2, arrow, background
        ]
        parser.run([], objects)
        assert arrow.style().color() == arrow_style.color(), str(
            arrow.style().color()) + " != " + str(arrow_style.color())
        assert polygon1.style().color() == fill_style.color(), str(
            polygon1.style().color()) + " != " + str(fill_style.color())
        assert polygon1.frame().style().color() == frame_style.color()
        assert opengraph1.style().color() == line_style.color()
        assert opengraph2.style().color() == custom_line_style.color()
        assert polygon2.style().color() == custom_fill_style.color()
        assert polygon3.style().color() == custom_fill_style.color()
        assert polygon2.frame().style().color() == custom_frame_style.color()
        assert polygon3.frame().style().color() == custom_frame_style.color()
Example #3
0
 def test_init(self):
     background = Background((10, 20))
     assert type(background) == Background
Example #4
0
 def test_maxn(self):
     background = Background((50, 60))
     assert background.max() == (50, 60)
Example #5
0
 def test_min(self):
     background = Background((50, 60))
     assert background.min() == (0, 0)
Example #6
0
 def test_scale(self):
     background = Background((50, 60))
     background.scale((5.5, 2.3))
     assert background.size() == (50 * 5.5, 60 * 2.3)
Example #7
0
 def test_size(self):
     background = Background((50, 60))
     assert background.size() == (50, 60)