def test_non_supported_dataset(self): """try a non supported dataset""" file_s = \ read_file( 'data/lidar/19930208.dial.lotard.001.crestech.csv' ) with self.assertRaises(WOUDCQaNotImplementedError): qa(file_s, rule_path=WOUDC_QA_RULES)
def test_validator_error1(self): """test that bad metadata throws error""" file_s = read_file( 'data/totalozone/19870501.Dobson.Beck.092.DMI-sample3.csv') with self.assertRaises(woudc_extcsv.ExtCSVValidatorException): qa(file_s, rule_path=WOUDC_QA_RULES, summary=True, validate_metadata=True)
def test_non_supported_dataset(self): """try a non supported dataset""" file_s = \ read_file( 'data/lidar/19930208.dial.lotard.001.crestech.csv' ) with self.assertRaises(WOUDCQaNotImplementedError): qa(file_s, rule_path=WOUDC_QA_RULES)
def test_validator_error2(self): """test that bad metadata results in correct error""" file_s = read_file( 'data/totalozone/19870501.Dobson.Beck.092.DMI-sample3.csv') try: qa(file_s, rule_path=WOUDC_QA_RULES, summary=True, validate_metadata=True) except Exception, err: self.assertTrue('Platform name of Arhus does \ not match database' in str(err))
def test_bad_related_test(self): """test bad related test""" # ozonesonde file_s = read_file('data/ozonesonde/20070505.ecc.2z.6674.uah.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertFalse(qa_results['file1']['38'][1]['related_test_result'], 'related test result check')
def test_bad_related_test(self): """test bad related test""" # ozonesonde file_s = read_file('data/ozonesonde/20070505.ecc.2z.6674.uah.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertFalse(qa_results['file1']['38'][1]['related_test_result'], 'related test result check')
def test_good_related_test(self): """test good/pass related test""" # ozonesonde file_s = read_file('data/ozonesonde/20070505.ecc.2z.6674.uah.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertEqual(True, qa_results['file1']['40'][1]['related_test_result'], 'related test result result check')
def test_bad_preconditions(self): """test bad/fail precondition""" # totalozone file_s = read_file( 'data/totalozone/19870501.Dobson.Beck.092.DMI-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertFalse(qa_results['file1']['35'][1]['precond_result'], 'precond result check')
def test_bad_related_test_profile(self): """test bad related test in profile""" # ozonesonde file_s = read_file( 'data/ozonesonde/20130227.ECC.6A.6A28027.UKMO-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertFalse(qa_results['file1']['25P'][7]['related_test_result'], 'related test result in profile check')
def test_good_presence_check2(self): """test good presence""" # totalozone file_s = read_file( 'data/totalozone/19870501.Dobson.Beck.092.DMI-sample2.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertEqual('100', qa_results['file1']['41'][20]['result'], 'presence check in profile')
def test_bad_related_test_profile(self): """test bad related test in profile""" # ozonesonde file_s = read_file( 'data/ozonesonde/20130227.ECC.6A.6A28027.UKMO-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertFalse(qa_results['file1']['25P'][7]['related_test_result'], 'related test result in profile check')
def test_good_range_check(self): """test good range check""" # ozonesonde file_s = read_file( 'data/ozonesonde/20130227.ECC.6A.6A28027.UKMO-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertEqual('100', qa_results['file1']['25P'][10]['result'], 'range check in profile')
def test_bad_range_check2(self): """test bad range check""" # totalozone file_s = read_file( 'data/totalozone/19870501.Dobson.Beck.092.DMI-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertIsNone(qa_results['file1']['36'][1]['result'], 'range check in profile')
def test_bad_preconditions(self): """test bad/fail precondition""" # totalozone file_s = read_file( 'data/totalozone/19870501.Dobson.Beck.092.DMI-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertFalse(qa_results['file1']['35'][1]['precond_result'], 'precond result check')
def test_bad_step_check(self): """test bad step check""" # ozonesonde file_s = read_file( 'data/ozonesonde/20130227.ECC.6A.6A28027.UKMO-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertEqual('0', qa_results['file1']['23P'][2]['result'], 'step check in profile')
def test_good_related_test(self): """test good/pass related test""" # ozonesonde file_s = read_file('data/ozonesonde/20070505.ecc.2z.6674.uah.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertEqual(True, qa_results['file1']['40'][1]['related_test_result'], 'related test result result check')
def test_bad_step_check(self): """test bad step check""" # ozonesonde file_s = read_file( 'data/ozonesonde/20130227.ECC.6A.6A28027.UKMO-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertEqual('0', qa_results['file1']['23P'][2]['result'], 'step check in profile')
def test_bad_range_check2(self): """test bad range check""" # totalozone file_s = read_file( 'data/totalozone/19870501.Dobson.Beck.092.DMI-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertIsNone(qa_results['file1']['36'][1]['result'], 'range check in profile')
def test_good_range_check(self): """test good range check""" # ozonesonde file_s = read_file( 'data/ozonesonde/20130227.ECC.6A.6A28027.UKMO-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertEqual('100', qa_results['file1']['25P'][10]['result'], 'range check in profile')
def test_good_presence_check2(self): """test good presence""" # totalozone file_s = read_file( 'data/totalozone/19870501.Dobson.Beck.092.DMI-sample2.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertEqual('100', qa_results['file1']['41'][20]['result'], 'presence check in profile')
def test_validator_warnings(self): """test that warnings are passed along""" file_s = read_file( 'data/totalozone/19870501.Dobson.Beck.092.DMI-sample4.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES, summary=True, validate_metadata=True) self.assertTrue('Some lines in this file have \ fewer commas than there are headers' in qa_results)
def test_validator_no_warnings(self): """test that a file with no warnings affects nothing""" file_s = read_file( 'data/totalozone/19870501.Dobson.Beck.092.DMI-sample2.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES, summary=True, validate_metadata=True) self.assertEqual( 'File passed all defined WOUDC \ quality assessment checks.', qa_results)
def test_good_preconditions(self): """test good/pass preconditions""" # ozonesonde file_s = read_file( 'data/ozonesonde/20130227.ECC.6A.6A28027.UKMO-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertTrue('file1' in qa_results.keys(), 'file check') self.assertTrue('1' in qa_results['file1'].keys(), 'test id check') self.assertTrue(qa_results['file1']['1'][1]['precond_result'], 'precond result check')
def test_good_preconditions(self): """test good/pass preconditions""" # ozonesonde file_s = read_file( 'data/ozonesonde/20130227.ECC.6A.6A28027.UKMO-sample1.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertTrue('file1' in qa_results.keys(), 'file check') self.assertTrue('1' in qa_results['file1'].keys(), 'test id check') self.assertTrue(qa_results['file1']['1'][1]['precond_result'], 'precond result check')
def test_bad_range_check4(self): """test range check""" # spectral file_s = read_file( 'data/spectral/20030215.brewer.mkiv.130.epa_uga-good.csv') qa_results = qa(file_s, rule_path=WOUDC_QA_RULES) self.assertEqual('100', qa_results['file1']['36'][1]['result'], 'range check') self.assertEqual('100', qa_results['file1']['36'][2]['result'], 'range check') self.assertEqual('100', qa_results['file1']['36'][23]['result'], 'range check') self.assertEqual('100', qa_results['file1']['36'][23]['result'], 'range check') self.assertEqual('100', qa_results['file1']['36'][4]['result'], 'range check') self.assertEqual('100', qa_results['file1']['36'][6]['result'], 'range check')
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. # # ================================================================= # Perform Qa interactively import logging import argparse from woudc_qa import \ qa LOGGER = logging.getLogger(__name__) PARSER = \ argparse.ArgumentParser(description='Execute Qa.') PARSER.add_argument( '--file', required=True, help='Path to extended CSV file to be quality assessed.') ARGS = PARSER.parse_args() if ARGS.file is not None: file_str = open(ARGS.file).read() print qa(file_str, summary=True)
qa,\ WOUDCQaExecutionError,\ WOUDCQaNotImplementedError,\ WOUDCQaValidationError LOGGER = logging.getLogger(__name__) PARSER = \ argparse.ArgumentParser(description='Execute Qa.') PARSER.add_argument( '--file', required=True, help='Path to extended CSV file to be quality assessed.') ARGS = PARSER.parse_args() if ARGS.file is not None: file_str = open(ARGS.file).read() try: qa(file_str, summary=True) except WOUDCQaNotImplementedError as err: print err except WOUDCQaExecutionError as err: print err except WOUDCQaValidationError as err: explanation = '%s: %s' % (err.message, '\n'.join(err.errors)) print explanation except Exception as err: print err
from woudc_qa import \ qa,\ WOUDCQaExecutionError,\ WOUDCQaNotImplementedError,\ WOUDCQaValidationError LOGGER = logging.getLogger(__name__) PARSER = \ argparse.ArgumentParser(description='Execute Qa.') PARSER.add_argument('--file', required=True, help='Path to extended CSV file to be quality assessed.') ARGS = PARSER.parse_args() if ARGS.file is not None: file_str = open(ARGS.file).read() try: qa(file_str, summary=True) except WOUDCQaNotImplementedError as err: print err except WOUDCQaExecutionError as err: print err except WOUDCQaValidationError as err: explanation = '%s: %s' % (err.message, '\n'.join(err.errors)) print explanation except Exception as err: print err
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. # # ================================================================= # Perform Qa interactively import logging import argparse from woudc_qa import \ qa LOGGER = logging.getLogger(__name__) PARSER = \ argparse.ArgumentParser(description='Execute Qa.') PARSER.add_argument( '--file', required=True, help='Path to extended CSV file to be quality assessed.') ARGS = PARSER.parse_args() if ARGS.file is not None: file_str = open(ARGS.file).read() print qa(file_str)