def testValidateBadEntityTypeFormat(self): parsed = dict( instance_parser.parse_yaml( os.path.join(_TESTCASE_PATH, 'BAD', 'bad_building_type.yaml'))) entity_name = list(parsed.keys())[0] entity = dict(parsed[entity_name]) instance = entity_instance.EntityInstance(entity, self.universe) if instance.IsValidEntityInstance(): self.fail('exception not raised')
def testValidateGoodExample(self): parsed = instance_parser.parse_yaml( os.path.join(_TESTCASE_PATH, 'GOOD', 'good_building_type.yaml')) parsed = dict(parsed) entity_name = list(parsed.keys())[0] entity = dict(parsed[entity_name]) instance = entity_instance.EntityInstance(entity, self.universe, parsed.keys()) if not instance.IsValidEntityInstance(): self.fail('exception incorrectly raised')
def testValidateBadTranslationStates(self): parsed = instance_parser.parse_yaml( os.path.join(_TESTCASE_PATH, 'BAD', 'bad_translation_states.yaml')) parsed = dict(parsed) entity_name = list(parsed.keys())[0] entity = dict(parsed[entity_name]) instance = entity_instance.EntityInstance(entity, self.universe, parsed.keys()) if instance.IsValidEntityInstance(): self.fail('exception not raised')
def testValidateTranslationUnitsAndStates(self): parsed = instance_parser.parse_yaml( os.path.join(_TESTCASE_PATH, 'GOOD', 'good_translation_units_and_states.yaml')) parsed = dict(parsed) entity_name = list(parsed.keys())[0] entity = dict(parsed[entity_name]) instance = entity_instance.EntityInstance(entity, self.universe, parsed.keys()) if not instance.IsValidEntityInstance(): self.fail('exception incorrectly raised')
def testInstanceValidatorParseProperFormat(self): parsed_yaml = instance_parser.parse_yaml(os.path.join( _TESTCASE_PATH, 'GOOD', 'good_building_type.yaml')) self.assertTrue(parsed_yaml.data)
def testInstanceValidatorDetectImproperTabbing(self): self.assertIsNone(instance_parser.parse_yaml(os.path.join( _TESTCASE_PATH, 'BAD', 'bad_tabbing.yaml')))
def testInstanceValidatorDetectMissingColon(self): self.assertIsNone(instance_parser.parse_yaml(os.path.join( _TESTCASE_PATH, 'BAD', 'bad_missing_colon.yaml')))
def testInstanceValidatorDetectDuplicateKeys(self): self.assertIsNone(instance_parser.parse_yaml(os.path.join( _TESTCASE_PATH, 'BAD', 'bad_duplicate_keys.yaml')))
help='Filepath to YAML building configuration', metavar='FILE') parser.add_argument('-m', '--modified-ontology-types', dest='modified_types_filepath', required=False, help='Filepath to modified type filepaths', metavar='MODIFIED_TYPE_FILEPATHS') arg = parser.parse_args() # SYNTAX VALIDATION print('\nValidator starting ...\n') filename = arg.filename # throws errors for syntax raw_parse = instance_parser.parse_yaml(filename) if raw_parse is None: print('\nSyntax error') sys.exit(0) print('Passed syntax checks!') modified_types_filepath = arg.modified_types_filepath print('Generating universe ...') universe = generate_universe.BuildUniverse(modified_types_filepath) if universe is None: print('\nError generating universe') sys.exit(0)
def testInstanceValidatorDetectImproperUnitsKeys(self): with self.assertRaises(SystemExit): parse = instance_parser.parse_yaml( os.path.join(_TESTCASE_PATH, 'BAD', 'bad_translation_units_format.yaml')) self.assertIsNone(parse)
def testInstanceValidatorParseProperConnections(self): parse = instance_parser.parse_yaml( os.path.join(_TESTCASE_PATH, 'GOOD', 'good_building_connections.yaml')) self.assertIsNotNone(parse)
def testInstanceValidatorDetectImproperTabbing(self): with self.assertRaises(SystemExit): parse = instance_parser.parse_yaml( os.path.join(_TESTCASE_PATH, 'BAD', 'bad_tabbing.yaml')) self.assertIsNone(parse)
def testInstanceValidatorDetectMissingColon(self): with self.assertRaises(SystemExit): parse = instance_parser.parse_yaml( os.path.join(_TESTCASE_PATH, 'BAD', 'bad_missing_colon.yaml')) self.assertIsNone(parse)
def testInstanceValidatorDetectDuplicateKeys(self): with self.assertRaises(SystemExit): parse = instance_parser.parse_yaml( os.path.join(_TESTCASE_PATH, 'BAD', 'bad_duplicate_keys.yaml')) self.assertIsNone(parse)