示例#1
0
    def _verify_schema1_content(self, schema: SchemaDefinition, source_file,
                                addl_checks: Callable[[SchemaDefinition], None]=None) -> None:
        expected = loads(f"""{{
           "name": "{source_file}",
           "id": "http://example.org/{source_file}",
           "title": "Load Raw Schema Test",
           "metamodel_version": "0.5.0",
           "source_file": "{source_file}.yaml",
           "source_file_date": "Mon Dec 31 11:25:38 2018",
           "source_file_size": 76,
           "generation_date": "2018-12-31 11:50"
        }}""")
        schema.source_file = os.path.basename(schema.source_file)
        if addl_checks:
            addl_checks(schema)
        self.assertTrue(isinstance(schema.metamodel_version, str))
        expected.metamodel_version = schema.metamodel_version
        self.assertTrue(isinstance(schema.source_file_date, str))
        expected.source_file_date = schema.source_file_date
        self.assertTrue(isinstance(schema.source_file_size, int))
        expected.source_file_size = schema.source_file_size
        self.assertTrue(isinstance(schema.generation_date, str))
        expected.generation_date = schema.generation_date

        self.assertEqual(expected, loads(as_json(schema)))
示例#2
0
 def fix_schema_metadata(self,
                         schema: SchemaDefinition) -> SchemaDefinition:
     self.assertIsNotNone(schema.generation_date)
     schema.source_file = os.path.basename(schema.source_file)
     schema.generation_date = "2018-12-31 17:23"
     self.assertIsNotNone(schema.metamodel_version)
     schema.metamodel_version = "0.5.0"
     self.assertIsNotNone(schema.source_file_size)
     schema.source_file_size = 259
     self.assertIsNotNone(schema.source_file_date)
     schema.source_file_date = "2018-12-31 17:23"
     return schema