예제 #1
0
def _get_pair(par, f, s):
    bf = os.path.join(par, f)
    hbf = os.path.join(par, s)
    fp, sp = pathmap.nexson_source_path(bf), pathmap.nexson_source_path(hbf)
    if not os.path.exists(fp):
        _LOG.warn('\nTest skipped because {s} does not exist'.format(s=fp))
        return None, None
    if not os.path.exists(sp):
        _LOG.warn('\nTest skipped because {s} does not exist'.format(s=sp))
        return None, None
    return pathmap.nexson_obj(bf), pathmap.nexson_obj(hbf)
예제 #2
0
def _get_pair(par, f, s):
    bf = os.path.join(par, f)
    hbf = os.path.join(par, s)
    fp, sp = pathmap.nexson_source_path(bf), pathmap.nexson_source_path(hbf)
    if not os.path.exists(fp):
        _LOG.warn('\nTest skipped because {s} does not exist'.format(s=fp))
        return None, None
    if not os.path.exists(sp):
        _LOG.warn('\nTest skipped because {s} does not exist'.format(s=sp))
        return None, None
    return pathmap.nexson_obj(bf), pathmap.nexson_obj(hbf)
예제 #3
0
 def testInvalidFilesFail(self):
     msg = ''
     for fn in pathmap.all_files(os.path.join('nexson', 'lacking_otus')):
         if fn.endswith('.input'):
             frag = fn[:-len('.input')]
             inp = read_json(fn)
             aa = validate_nexson(inp)
             annot = aa[0]
             if len(annot.errors) == 0:
                 ofn = pathmap.nexson_source_path(frag + '.output')
                 ew_dict = annot.get_err_warn_summary_dict()
                 write_json(ew_dict, ofn)
                 msg = "Failed to reject file. See {o}".format(o=str(msg))
                 self.assertTrue(False, msg)
 def testInvalidFilesFail(self):
     msg = ''
     for fn in pathmap.all_files(os.path.join('nexson', 'lacking_otus')):
         if fn.endswith('.input'):
             frag = fn[:-len('.input')]
             inp = read_json(fn)
             aa = validate_nexson(inp)
             annot = aa[0]
             if len(annot.errors) == 0:
                 ofn = pathmap.nexson_source_path(frag + '.output')
                 ew_dict = annot.get_err_warn_summary_dict()
                 write_json(ew_dict, ofn)
                 msg = "Failed to reject file. See {o}".format(o=str(msg))
                 self.assertTrue(False, msg)
예제 #5
0
 def testValidFilesPass(self):
     format_list = ['1.2']
     msg = ''
     for d in VALID_NEXSON_DIRS:
         for nf in format_list:
             frag = os.path.join(d, 'v{f}.json'.format(f=nf))
             nexson = pathmap.nexson_obj(frag)
             aa = validate_nexson(nexson)
             annot = aa[0]
             for e in annot.errors:
                 _LOG.debug('unexpected error from {f}: {m}'.format(f=frag, m=UNICODE(e)))
             if len(annot.errors) > 0:
                 ofn = pathmap.nexson_source_path(frag + '.output')
                 ew_dict = annot.get_err_warn_summary_dict()
                 testing_write_json(ew_dict, ofn)
                 msg = "File failed to validate cleanly. See {o}".format(o=ofn)
             self.assertEqual(len(annot.errors), 0, msg)
예제 #6
0
 def testValidFilesPass(self):
     format_list = ['1.2']
     msg = ''
     for d in VALID_NEXSON_DIRS:
         for nf in format_list:
             frag = os.path.join(d, 'v{f}.json'.format(f=nf))
             nexson = pathmap.nexson_obj(frag)
             aa = validate_nexson(nexson)
             annot = aa[0]
             for e in annot.errors:
                 _LOG.debug('unexpected error from {f}: {m}'.format(
                     f=frag, m=UNICODE(e)))
             if len(annot.errors) > 0:
                 ofn = pathmap.nexson_source_path(frag + '.output')
                 ew_dict = annot.get_err_warn_summary_dict()
                 testing_write_json(ew_dict, ofn)
                 msg = "File failed to validate cleanly. See {o}".format(
                     o=ofn)
             self.assertEqual(len(annot.errors), 0, msg)