コード例 #1
0
ファイル: test_page.py プロジェクト: OddBloke/pypostscript
    def test_page_many_objects(self):
        """
        Objects appended to Page should render in its body.

        """
        circle_1 = Circle(centre_x_pts=50,
                          centre_y_pts=100,
                          radius_pts=50,
                          line_width_pts=2)
        rectangle_1 = Rectangle(x_pts=300,
                                y_pts=300,
                                height_pts=50,
                                width_pts=75,
                                line_width_pts=5)
        circle_2 = Circle(centre_x_pts=150,
                          centre_y_pts=200,
                          radius_pts=20,
                          line_width_pts=3)
        rectangle_2 = Rectangle(x_pts=100,
                                y_pts=100,
                                height_pts=5,
                                width_pts=37,
                                line_width_pts=1)
        text_line = TextLine(x_pts=250,
                             y_pts=210,
                             font=TimesBoldFont(size_pts=18),
                             text='Some Text')
        page = Page()
        page.extend(circle_1, rectangle_1, circle_2, rectangle_2, text_line)
        self.assertEqual(page.body(),
                         '\n'.join([shape.ps for shape in (circle_1,
                                                           rectangle_1,
                                                           circle_2,
                                                           rectangle_2,
                                                           text_line)]))
コード例 #2
0
ファイル: test_page.py プロジェクト: OddBloke/pypostscript
    def test_page_one_object(self):
        """
        Object appended to Page should render in its body.

        """
        circle = Circle(centre_x_pts=50,
                        centre_y_pts=100,
                        radius_pts=50,
                        line_width_pts=2)

        page = Page()
        page.extend(circle)
        self.assertEqual(page.body(),
                         circle.ps)
コード例 #3
0
ファイル: test_page.py プロジェクト: OddBloke/pypostscript
    def test_header_include_parts(self, read_part):
        """
        Page.header() should call read_part for appropriate parts.

        """
        read_part.side_effect = ['part_1', 'part_2', 'part_3']
        page = Page()
        ps_object_1 = Mock()
        ps_object_1.required_parts = ['foo']
        ps_object_2 = Mock()
        ps_object_2.required_parts = ['foo', 'bar', 'bang']
        page.extend(ps_object_1, ps_object_2)
        header = page.header()
        # Access to parts is unordered, strictly speaking
        parts_requested = [kwargs['name'] for args, kwargs in
                            read_part.call_args_list]
        self.assertEqual(len(parts_requested), 3)  # No repeat requests
        self.assertEqual(set(parts_requested),
                         set(['foo', 'bar', 'bang']))
        self.assertEqual(header,
                         'MockPageStart\n'
                         'part_1\n'
                         'part_2\n'
                         'part_3\n')