コード例 #1
0
    def test_post_template_with_odata_data(self):
        # set up data_sources
        data_sources = [ODataDataSource("", "http://odata.windward.net/Northwind/Northwind.svc", 2)]

        # initialize and process
        with open(self.odata_file, 'rb') as template:
            output = io.BytesIO(b"")
            report = restfulengine.create_report(
                self.base_uri,
                OutputFormat.pdf,
                template,
                output
            )
            report.process(data_sources)
コード例 #2
0
 def test_variables(self):
     # set up data_sources with an xml data_source that has a variable
     with open(self.mfg_xml, 'rb') as xml_file:
         xml_data = xml_file.read()
     ds = XmlDataSource("", xml_data)
     ds.variables = [TemplateVariable("Var1", "hi there")]
     data_sources = [ds]
     # initialize and process
     with open(self.var_file, 'rb') as template:
         output = io.BytesIO(b"")
         report = restfulengine.create_report(
             self.base_uri,
             OutputFormat.pdf,
             template,
             output
         )
         report.process(data_sources)
コード例 #3
0
 def test_post_template_with_xml_data(self):
     # set up data_sources
     with open(self.mfg_xml, 'rb') as xml_file:
         xml_data = xml_file.read()
     data_sources = [
         XmlDataSource("MANF_DATA_2009", xml_data)
     ]
     # initialize and process
     with open(self.mfg_file, 'rb') as template:
         output = io.BytesIO(b"")
         report = restfulengine.create_report(
             self.base_uri,
             OutputFormat.pdf,
             template,
             output
         )
         report.process(data_sources)
コード例 #4
0
 def test_post_template_returns_report_pdf(self):
     with open(self.sample1_file, 'rb') as template:
         output = io.BytesIO(b"")  # file-like object
         # initialize report and process
         report = restfulengine.create_report(
             self.base_uri,
             OutputFormat.pdf,
             template,
             output
         )
         report.process()
         # need 8 output bytes for file sig (ensure at begin);
         output.seek(0)
         output_data = output.read(8)
         assert len(output_data) == 8
         # PDF file should be "%PDF-1.5"
         assert output_data == b"%PDF-1.5"
コード例 #5
0
 def test_post_template_with_xml_data(self):
     # set up data_sources
     with open(self.mfg_xml, 'rb') as xml_file:
         xml_data = xml_file.read()
     data_sources = [
         XmlDataSource("MANF_DATA_2009", xml_data)
     ]
     # initialize and process
     with open(self.mfg_file, 'rb') as template:
         output = io.BytesIO(b"")
         report = restfulengine.create_report(
             self.base_uri,
             OutputFormat.pdf,
             template,
             output
         )
         report.process(data_sources)
コード例 #6
0
 def test_post_template_returns_report_pdf(self):
     with open(self.sample1_file, 'rb') as template:
         output = io.BytesIO(b"")  # file-like object
         # initialize report and process
         report = restfulengine.create_report(
             self.base_uri,
             OutputFormat.pdf,
             template,
             output
         )
         report.process()
         # need 8 output bytes for file sig (ensure at begin);
         output.seek(0)
         output_data = output.read(8)
         assert len(output_data) == 8
         # PDF file should be "%PDF-1.5"
         assert output_data == b"%PDF-1.5"
コード例 #7
0
 def test_variables(self):
     # set up data_sources with an xml data_source that has a variable
     with open(self.mfg_xml, 'rb') as xml_file:
         xml_data = xml_file.read()
     ds = XmlDataSource("", xml_data)
     ds.variables = [TemplateVariable("Var1", "hi there")]
     data_sources = [ds]
     # initialize and process
     with open(self.var_file, 'rb') as template:
         output = io.BytesIO(b"")
         report = restfulengine.create_report(
             self.base_uri,
             OutputFormat.pdf,
             template,
             output
         )
         report.process(data_sources)
コード例 #8
0
    def test_post_template_with_json_data(self):
        # set up data_sources
        data_sources = [JsonDataSource(
            name="",
            uri="http://json.windward.net/Northwind.json",
            username="******",
            password="******"
        )]

        # initialize and process
        with open(self.json_file, 'rb') as template:
            output = io.BytesIO(b"")
            report = restfulengine.create_report(
                self.base_uri,
                OutputFormat.pdf,
                template,
                output
            )
            report.process(data_sources)
コード例 #9
0
 def test_post_template_with_ado_data(self):
     # set up data_sources
     data_sources = [
         AdoDataSource(
             "MSSQL",
             "System.Data.SqlClient",
             "Data Source=mssql.windward.net;"
             "Initial Catalog=Northwind;"
             "User=demo;Password=demo")
     ]
     # initialize and process
     with open(self.mssql_file, "rb") as template:
         output = io.BytesIO(b"")
         report = restfulengine.create_report(
             self.base_uri,
             OutputFormat.pdf,
             template,
             output
         )
         report.process(data_sources)
コード例 #10
0
    def test_post_template_async(self):
        # set up data_sources
        with open(self.mfg_xml, 'rb') as xml_file:
            xml_data = xml_file.read()
        data_sources = [XmlDataSource("MANF_DATA_2009", xml_data)]
        # initialize and process
        with open(self.mfg_file, 'rb') as template:
            report = restfulengine.create_report(
                self.base_uri,
                OutputFormat.pdf,
                template
            )
            report.process(data_sources)
        # now wait for report
        while report.get_status() == Status.working:
            time.sleep(0.1)

        assert report.get_status() == Status.ready
        report.get_report()
        report.delete()
コード例 #11
0
 def test_post_template_with_ado_data(self):
     # set up data_sources
     data_sources = [
         AdoDataSource(
             "MSSQL",
             "System.Data.SqlClient",
             "Data Source=mssql.windward.net;"
             "Initial Catalog=Northwind;"
             "User=demo;Password=demo")
     ]
     # initialize and process
     with open(self.mssql_file, "rb") as template:
         output = io.BytesIO(b"")
         report = restfulengine.create_report(
             self.base_uri,
             OutputFormat.pdf,
             template,
             output
         )
         report.process(data_sources)
コード例 #12
0
    def test_post_template_async(self):
        # set up data_sources
        with open(self.mfg_xml, 'rb') as xml_file:
            xml_data = xml_file.read()
        data_sources = [XmlDataSource("MANF_DATA_2009", xml_data)]
        # initialize and process
        with open(self.mfg_file, 'rb') as template:
            report = restfulengine.create_report(
                self.base_uri,
                OutputFormat.pdf,
                template
            )
            report.process(data_sources)
        # now wait for report
        while report.get_status() == Status.working:
            time.sleep(0.1)

        assert report.get_status() == Status.ready
        report.get_report()
        report.delete()
コード例 #13
0
    def test_datasets(self):
        # set up data_sources
        data_sources = [
            AdoDataSource(
                "",
                "System.Data.SqlClient",
                "Data Source=mssql.windward.net;"
                "Initial Catalog=AdventureWorks;"
                "User=demo;Password=demo")
        ]

        with open(self.dataset_template, 'rb') as template, open(self.dataset_file, 'rb') as dataset:
            output = io.BytesIO(b"")
            report = restfulengine.create_report(
                self.base_uri,
                OutputFormat.pdf,
                template,
                output
            )
            report.datasets = [DataSet(data=dataset.read())]
            report.process(data_sources)