def testInvalidFilesFail(self): # just one test file for now msg = '' frag = 'amendment-incomplete.json' inp = pathmap.amendment_obj(frag) aa = validate_amendment(inp) if len(aa) > 0: errors = aa[0] if len(errors) == 0: ofn = pathmap.amendment_source_path(frag + '.output') testing_write_json(errors, ofn) msg = "Failed to reject invalid file (no errors found)" self.assertTrue(False, msg)
def testValidFilesPass(self): # just one test file for now msg = '' frag = 'amendment-good.json' amendment = pathmap.amendment_obj(frag) aa = validate_amendment(amendment) errors = aa[0] for e in errors: _LOG.debug('unexpected error from {f}: {m}'.format(f=frag, m=UNICODE(e))) if len(errors) > 0: ofn = pathmap.amendment_source_path(frag + '.output') testing_write_json(errors, ofn) msg = "File failed to validate cleanly. See {o}".format(o=ofn) self.assertEqual(len(errors), 0, msg)
def testInvalidDOIsFail(self): # all DOIs should be in URL form msg = '' frag = 'amendment-bad-dois.json' inp = pathmap.amendment_obj(frag) aa = validate_amendment(inp) if len(aa) > 0: errors = aa[0] ofn = pathmap.amendment_source_path(frag + '.output') testing_write_json(errors, ofn) if len(errors) == 0: msg = "Failed to reject bare DOI (no errors found)" self.assertTrue(False, msg) else: self.assertTrue('should be a URL' in errors[0])