def test_canonical_to_model(self, chunk_size): with TemporaryDirectory() as d: output_file = os.path.join(d, 'model.csv') translator = Translator( os.path.join(input_data_dir, 'canonical.csv'), output_file, os.path.join(input_data_dir, 'canonical_to_model.xslt'), os.path.join(input_data_dir, 'canonical_to_model.xsd'), chunk_size=chunk_size ) translator() self.assertTrue(filecmp.cmp(output_file, os.path.join(expected_data_dir, 'model.csv')))
def test_source_to_canonical(self, chunk_size): with TemporaryDirectory() as d: output_file = os.path.join(d, 'canonical.csv') translator = Translator( os.path.join(input_data_dir, 'source.csv'), output_file, os.path.join(input_data_dir, 'source_to_canonical.xslt'), os.path.join(input_data_dir, 'source_to_canonical.xsd'), chunk_size=chunk_size, append_row_nums=True ) translator() diff = unified_diff(output_file, os.path.join(expected_data_dir, 'canonical.csv'), as_string=True) self.assertEqual(0, len(diff), diff)
def _do_transform(progid, sourcefilename, validationfilelocname, transformationfilename, destinationfilepath, destinationfilename, do_sequence): ''' Transform source to canonical. ''' _check_file(sourcefilename) _check_file(validationfilelocname) _check_file(transformationfilename) destinationfilename = os.path.join(destinationfilepath, destinationfilename) # Pass logger? check in docker logs translator = Translator(input_path=sourcefilename, output_path=destinationfilename, xsd_path=validationfilelocname, xslt_path=transformationfilename, append_row_nums=do_sequence, logger=logging.getLogger()) translator() return _check_file(destinationfilename)