def test_get_main_dataset_query_from_xml(self): config = Config() config.input = os.path.join(self.RESOURCES_DIR, 'reports', 'CancelAck.jrxml') instance = Report(config, config.input) dataset_query = instance.get_main_dataset_query() self.assertEqual(dataset_query, '/CancelResponse/CancelResult/ID')
def test_get_main_dataset_query_from_jsonql(self): config = Config() config.input = os.path.join(self.RESOURCES_DIR, 'reports', 'jsonql.jrxml') instance = Report(config, config.input) dataset_query = instance.get_main_dataset_query() self.assertEqual(dataset_query, 'contacts.person')
def test_get_report_parameters(self): config = Config() config.input = os.path.join(self.RESOURCES_DIR, 'reports', 'noDB-params.jrxml') instance = Report(config, config.input) result = instance.get_report_parameters() self.assertEqual(str(result[result.length - 4].getName()), "myString") self.assertEqual(str(result[result.length - 3].getName()), "myInt") self.assertEqual(str(result[result.length - 2].getName()), "myDate") self.assertEqual(str(result[result.length - 1].getName()), "myImage")
def test_compile_to_file(self): config = Config() config.input = os.path.join(self.RESOURCES_DIR, 'reports', 'csv.jrxml') config.output = os.path.join(self.RESOURCES_DIR, 'reports', 'compile_to_file') instance = Report(config, config.input) instance.fill() instance.export_jrprint() self.assertEqual(os.path.isfile(config.output + '.jrprint'), True)
def test_compile_to_file_jasperreports_functions2(self): config = Config() config.input = os.path.join(self.RESOURCES_DIR, 'reports', 'Blank_A4_1.jrxml') config.output = os.path.join(self.RESOURCES_DIR, 'reports', 'blank_A4_1') instance = Report(config, config.input) instance.fill() instance.export_jrprint() self.assertEqual(os.path.isfile(config.output + '.jrprint'), True)
def test_fill_javascript(self): config = Config() config.input = os.path.join(self.RESOURCES_DIR, 'reports', 'charactersetTestWithJavaScript.jrxml') config.output = os.path.join(self.RESOURCES_DIR, 'reports', 'characterset_test_with_javascript') instance = Report(config, config.input) instance.fill() instance.export_jrprint() self.assertEqual(os.path.isfile(config.output + '.jrprint'), True)
def test_export_csv(self): config = self.get_config_csv() instance = Report(config, config.input) instance.fill() instance.export_csv() output_file = config.output + '.csv' self.assertEqual(os.path.isfile(output_file), True) with open(output_file, 'r') as f: rows = f.readlines() self.assertEqual(rows[2], '|Name|Street||City|Phone|\n')
def test_compile_to_file_jasperreports_functions(self): config = Config() config.input = os.path.join( self.RESOURCES_DIR, 'reports', 'charactersetTestWithStudioBuiltinFunctions.jrxml') config.output = os.path.join( self.RESOURCES_DIR, 'reports', 'characterset_test_with_studio_builtin_functions') instance = Report(config, config.input) instance.fill() instance.export_jrprint() self.assertEqual(os.path.isfile(config.output + '.jrprint'), True)
def test_fill_from_jsonql_datasource(self): config = Config() config.input = os.path.join(self.RESOURCES_DIR, 'reports', 'jsonql.jrxml') config.output = os.path.join(self.RESOURCES_DIR, 'reports', 'jsonql') config.dataFile = os.path.join(self.RESOURCES_DIR, 'contacts.json') config.dbType = 'jsonql' config.jsonQuery = 'contacts.person' instance = Report(config, config.input) instance.fill() instance.export_jrprint() self.assertEqual(os.path.isfile(config.output + '.jrprint'), True)
def test_fill_from_xml_datasource_no_xpath(self): config = Config() config.input = os.path.join(self.RESOURCES_DIR, 'reports', 'CancelAck.jrxml') config.output = os.path.join(self.RESOURCES_DIR, 'reports', 'cancel_ack_no_xpath') config.dataFile = os.path.join(self.RESOURCES_DIR, 'CancelAck.xml') config.dbType = 'xml' instance = Report(config, config.input) instance.fill() instance.export_jrprint() self.assertEqual(os.path.isfile(config.output + '.jrprint'), True)
def test_export_pdf_barcode4j(self): config = Config() config.input = os.path.join(self.RESOURCES_DIR, 'reports', 'barcode4j.jrxml') config.output = os.path.join(self.RESOURCES_DIR, 'reports', 'barcode4j') config.dataFile = os.path.join(self.RESOURCES_DIR, 'barcode4j.xml') config.dbType = 'xml' config.xmlXpath = '/nalepka/ident' instance = Report(config, config.input) instance.fill() instance.export_pdf() self.assertEqual(os.path.isfile(config.output + '.pdf'), True)
def test_export_csv_meta(self): config = self.get_config_csv() config.input = os.path.join(self.RESOURCES_DIR, 'reports', 'csvMeta.jrxml') config.output = os.path.join(self.RESOURCES_DIR, 'reports', 'csvMeta') instance = Report(config, config.input) instance.fill() instance.export_csv_meta() output_file = config.output + '.csv' self.assertEqual(os.path.isfile(output_file), True) with open(output_file, 'r') as f: rows = f.readlines() self.assertEqual( rows[2], "Carl Grant|Ap #507-5431 Consectetuer, Avenue|Chippenham|1-472-350-4152\n" )
def test_export_pptx(self): config = self.get_config_csv() instance = Report(config, config.input) instance.fill() instance.export_pptx() self.assertEqual(os.path.isfile(config.output + '.pptx'), True)