def test_correct_file_without_header(self): args = {'file_loc': os.getcwd()+'/files/csv/without_header/SalesJan2009_without_header_correct_file.csv', 'config': os.getcwd()+'/files/configs/config_without_header.json'} parsed_config = TestsFunctional.open_config_file(args['config']) settings = {'skip_column_validations_on_empty_file': True, 'raise_exception_and_halt_on_found_validation_error': False} obj = ValidationRunner(parsed_config, settings) result = obj.run(args['file_loc']) assert result == 0
def test_empty_file_dont_skip_column_validations_without_header(self, caplog): args = {'file_loc': os.getcwd()+'/files/csv/without_header/SalesJan2009_without_header_empty_file.csv', 'config': os.getcwd()+'/files/configs/config_without_header.json'} parsed_config = TestsFunctional.open_config_file(args['config']) settings = {'skip_column_validations_on_empty_file': False, 'raise_exception_and_halt_on_found_validation_error': False} caplog.set_level(logging.INFO) obj = ValidationRunner(parsed_config, settings) result = obj.run(args['file_loc']) assert "Column validations set in the config, but none of the expected columns found in the file" in caplog.text assert result == 1
def test_empty_file_skip_column_validations_with_header(self, caplog): args = {'file_loc': os.getcwd()+'/files/csv/with_header/SalesJan2009_with_header_empty_file.csv', 'config': os.getcwd()+'/files/configs/config_with_header.json'} parsed_config = TestsFunctional.open_config_file(args['config']) settings = {'skip_column_validations_on_empty_file': True, 'raise_exception_and_halt_on_found_validation_error': False} caplog.set_level(logging.INFO) obj = ValidationRunner(parsed_config, settings) result = obj.run(args['file_loc']) assert 'File has no rows to validate, skipping column level validations' in caplog.text assert result == 0
def test_incorrect_file_without_header(self, caplog): args = {'file_loc': os.getcwd()+'/files/csv/without_header/SalesJan2009_without_header_incorrect_file.csv', 'config': os.getcwd()+'/files/configs/config_without_header.json'} parsed_config = TestsFunctional.open_config_file(args['config']) settings = {'skip_column_validations_on_empty_file': True, 'raise_exception_and_halt_on_found_validation_error': False} caplog.set_level(logging.ERROR) obj = ValidationRunner(parsed_config, settings) result = obj.run(args['file_loc']) assert 'failed to meet this value' in caplog.text assert result == 1
def test_config_with_header_file_without_header(self, caplog): args = {'file_loc': os.getcwd()+'/files/csv/without_header/SalesJan2009_without_header_correct_file.csv', 'config': os.getcwd()+'/files/configs/config_with_header.json'} parsed_config = TestsFunctional.open_config_file(args['config']) settings = {'skip_column_validations_on_empty_file': True, 'raise_exception_and_halt_on_found_validation_error': False} caplog.set_level(logging.ERROR) obj = ValidationRunner(parsed_config, settings) result = obj.run(args['file_loc']) assert "check_file_header_column_names - failed to meet this value : ['Transaction_date', 'Product', 'Price', 'Payment_Type', 'Name', 'City', 'State', 'Country', 'Account_Created', 'Last_Login', 'Latitude', 'Longitude']" in caplog.text assert result == 1