def test_bogus_yaml_config(app): app = MockApp() setup_logging() settings = OntologySettings() original_config_file = settings.CONFIG_FILE log.debug("ontology original config file {0}".format(original_config_file)) # Test missing service ontology_node_id log.debug( "ontology os.environ config file {0}".format(original_config_file)) yaml_file = os.path.join(TEST_DIR, "ontology_test.yml") os.environ['SN_ONTOLOGY_CONFIG_FILE'] = yaml_file exception_caught = False try: ontology.setup_ontology(app) except RuntimeError as exception: exception_caught = True log.debug(" Expected Exception caught %s", exception) except: pass assert (exception_caught) # Test missing service name log.debug( "ontology os.environ config file {0}".format(original_config_file)) yaml_file = os.path.join(TEST_DIR, "ontology_test_2.yml") os.environ['SN_ONTOLOGY_CONFIG_FILE'] = yaml_file exception_caught = False try: ontology.setup_ontology(app) except RuntimeError as exception: exception_caught = True log.debug(" Expected Exception caught %s", exception) except: pass assert (exception_caught) # Test bad section name in yaml file log.debug( "ontology os.environ config file {0}".format(original_config_file)) yaml_file = os.path.join(TEST_DIR, "ontology_test_3.yml") os.environ['SN_ONTOLOGY_CONFIG_FILE'] = yaml_file exception_caught = False try: ontology.setup_ontology(app) except RuntimeError as exception: exception_caught = True log.debug(" Expected Exception caught %s", exception) except: pass assert (exception_caught) os.environ['SN_ONTOLOGY_CONFIG_FILE'] = original_config_file
def app(): app = MockApp() ontology.setup_ontology(app) return app