def _test(mod): """Performs standard document validation tests.""" # Set test document/error factories. error_setters = (_set_doc_errors_01, _set_doc_errors_02) if hasattr(mod, "get_document_error_setters"): error_setters += mod.get_document_error_setters() # Perform validation test. for error_setter in error_setters: # ... set valid test document. doc = tu.get_doc(mod) # ... set expected error count. expected_error_count = error_setter(doc) # ... validate document. errors = pyesdoc.validate(doc) # ... print errors if mismatch between expected & actual. # if len(errors) == expected_error_count: # for error in errors: # rt.log(error, level=rt.LOG_LEVEL_WARNING) # ... assert errors. tu.assert_iter(errors, expected_error_count, length_compare=tu.COMPARE_LTE)
def _test(mod): """Performs standard document validation tests.""" # Set test document/error factories. error_setters = (_set_doc_errors_01, _set_doc_errors_02) if hasattr(mod, "get_document_error_setters"): error_setters += mod.get_document_error_setters() # Perform validation test. for error_setter in error_setters: # ... set valid test document. doc = tu.get_doc(mod) # ... set expected error count. expected_error_count = error_setter(doc) # ... validate document. errors = pyesdoc.validate(doc) # ... print errors if mismatch between expected & actual. # if len(errors) == expected_error_count: # for error in errors: # rt.log(error, level=rt.LOG_LEVEL_WARNING) # ... assert errors. tu.assert_iter(errors, expected_error_count)
def _create_doc(mod): """Creates a document for testing.""" doc = tu.get_doc(mod) mod.DOC_ID = doc.meta.id = uuid.uuid4() mod.DOC_VERSION = doc.meta.version = 0 mod.DOC_DATE = doc.meta.create_date = datetime.datetime.now() return doc
def _test(mod): """Performs standard document extensions tests,""" doc = tu.get_doc(mod) # Note - returns an extended document tu.assert_object(doc.ext) tu.assert_str(doc.type_key, doc.meta.type) tu.assert_str(doc.type_key, doc.ext.type) if hasattr(mod, "assert_doc_extensions"): mod.assert_doc_extensions(doc)
def _main(): """Main entry point.""" for mod in tt.MODULES: doc = tu.get_doc(mod) try: _write(doc) except Exception as err: print "ERR ::", doc.type_key, " ::", err
def _main(): """Main entry point.""" for mod in tt.MODULES: doc = tu.get_doc(mod) for encoding in pyesdoc.ESDOC_ENCODINGS_FILE: try: _write_file(mod, doc, encoding) except Exception as err: print "ERR ::", doc.type_key, " ::", err
def _main(): """Main entry point. """ for doc in [tu.get_doc(m) for m in tt.MODULES]: try: _write(doc) except Exception as err: msg = "ERR:: {0} :: {1}".format(doc.type_key, err) print(msg)
def _main(): """Main entry point. """ for mod in tt.MODULES: doc = tu.get_doc(mod) for encoding in pyesdoc.ENCODINGS_FILE: try: _write_file(mod, doc, encoding) except Exception as err: msg = "ERR:: {0} :: {1}".format(doc.type_key, err) print(msg)
def test(): """Performs serialization tests over the set of test documents.""" for mod in tt.MODULES: # Get doc instance. doc = tu.get_doc(mod) # Test json. tu.init(_test, 'serialization', mod, 'JSON') yield _test, mod, doc, pyesdoc.ESDOC_ENCODING_JSON # Test xml. tu.init(_test, 'serialization', mod, 'XML') yield _test, mod, doc, pyesdoc.ESDOC_ENCODING_XML # Test metafor cim v1 xml. tu.init(_test_metafor_xml, 'serialization', mod, 'XML Metafor CIM v1') yield _test_metafor_xml, doc # Test html. tu.init(_test_html, 'serialization', mod, 'HTML') yield _test_html, mod, doc
def test(): """Performs serialization tests over the set of test documents.""" for mod in tt.MODULES: # Get doc instance. doc = tu.get_doc(mod) # Test json. tu.init(_test, 'serialization', mod, 'JSON') yield _test, mod, doc, pyesdoc.ENCODING_JSON # Test xml. tu.init(_test, 'serialization', mod, 'XML') yield _test, mod, doc, pyesdoc.ENCODING_XML # Test metafor cim v1 xml. tu.init(_test_metafor_xml, 'serialization', mod, 'XML Metafor CIM v1') yield _test_metafor_xml, doc # Test html. tu.init(_test_html, 'serialization', mod, 'HTML') yield _test_html, mod, doc