def test_extraction_with_metadata(): fname = join(dirname(__file__), '../../sample/test/simple_with_meta.xlsx') processor = exco.from_excel(fname) result = processor.process_excel(fname) assert result.cell_result_for_key( 'distance').result.metadata['unit'] == 'km'
def test_deref(): template = join(dirname(__file__), '../sample/test/simple_deref.xlsx') processor = exco.from_excel(template) data = join(dirname(__file__), '../sample/test/simple_deref_to_extract.xlsx') result = processor.process_excel(data) assert result.to_dict() == {'deref_key': 12, 'world': 34}
def test_dynamic_locator(): processor = exco.from_excel( join(dirname(__file__), '../../sample/test/dynamic_location/dynamic_location_template.xlsx')) datafile = join(dirname( __file__), '../../sample/test/dynamic_location/dynamic_location_data.xlsx') result = processor.process_excel(datafile) assert result.to_dict() == {'marker_value': 2, 'below_marker_value': 'below_marker'}
def run_exco(self): try: processor = exco.from_excel(self.path) result = processor.process_excel(self.path) pprint(result.to_dict()) except (ExcoException, TypeError, LookupError, ValueError, AttributeError): print_exc() finally: current_time = datetime.now().strftime("%H:%M:%S") print(f'Latest Result At: {current_time}')
def test_table(): fname = join(dirname(__file__), '../../sample/test/table/table_template.xlsx') template = exco.from_excel(fname) result = template.process_excel(fname) exp = {'left_table': [ {'left': 'Hello', 'right': 1}, {'left': 'world', 'right': 2}, {'left': 'foo', 'right': 3}, ]} assert result.to_dict() == exp assert len(result.table_result_for_key( 'left_table').result.row_results) == 3
def test_everything(): template = exco.from_excel(fname) result = template.process_excel(fname) exp = { 'left_table': [{ 'left': 'Hello', 'right': 1 }, { 'left': 'world', 'right': 2 }, { 'left': 'foo', 'right': 3 }], 'right_table': [{ 'left': 'aaa', 'right': 1 }, { 'left': 'bbb', 'right': 2 }, { 'left': 'ccc', 'right': 3 }], 'some_date': datetime.date(1982, 8, 23), 'some_float': 1.23, 'some_int': 1, 'some_string': 'string' } assert result.to_dict() == exp assert result.is_ok
def template() -> exco.ExcelProcessor: template_name = join( dirname(__file__), '../../sample/test/validation/validation_template.xlsx') return exco.from_excel(template_name)
def template(): fname = join(dirname(__file__), '../../sample/test/date/date_template.xlsx') return exco.from_excel(fname)