def test_minimal_model(self): """ Test to make the absolute minimal model work """ YAMLGenerator(env.input_path('issue_tccm', 'minimalmodel.yaml'), mergeimports=False, log_level=logging.INFO).serialize(validateonly=True) env.make_testing_directory(env.expected_path('issue_tccm')) for generator in Generator.__subclasses__(): if not generator.__module__.startswith('linkml.generators'): pass elif not generator.directory_output: env.generate_single_file( [ 'issue_tccm', 'minimalmodel.' + generator.valid_formats[0] ], lambda: generator(env.input_path('issue_tccm', 'minimalmodel.yaml'), importmap=env.import_map, mergeimports=False, emit_metadata=False).serialize(), value_is_returned=True) else: env.generate_directory( ['issue_tccm', generator.__name__], lambda d: generator( env.input_path('issue_tccm', 'minimalmodel.yaml'), importmap=env.import_map, mergeimports=False, emit_metadata=False).serialize(directory=d))
def test_issue_121(self): """ Make sure that types are generated as part of the output """ env.generate_single_file('issue_121.py', lambda: PythonGenerator(env.input_path('issue_121.yaml')).serialize(), comparator=compare_python, value_is_returned=True) with open(env.expected_path('issue_121.py')) as f: python= f.read() has_includes = False for line in python.split("\n"): if line.startswith("from includes.types"): assert line == "from includes.types import String" has_includes = True assert has_includes module = compile_python(env.expected_path('issue_121.py')) example = module.Biosample(depth="test") assert hasattr(example, "depth") assert example.depth == "test" example2 = module.ImportedClass() def output_generator(dirname) -> None: with open(os.path.join(dirname, 'issue_121_1.json'), 'w') as f: f.write(as_json(example)) with open(os.path.join(dirname, 'issue_121_2.json'), 'w') as f: f.write(as_json(example2)) env.generate_directory('issue_121', lambda dirname: output_generator(dirname))
def test_issue_80(self): """ Make sure that types are generated as part of the output """ env.generate_single_file( 'issue_80.py', lambda: PythonGenerator(env.input_path('issue_80.yaml')).serialize( ), comparator=lambda exp, act: compare_python( exp, act, self.env.expected_path('issue_80.py')), value_is_returned=True) module = compile_python(env.expected_path('issue_80.py')) example = module.Person("http://example.org/person/17", "Fred Jones", 43) # Create output for various forms def output_generator(dirname) -> None: with open(os.path.join(dirname, 'issue_80.json'), 'w') as f: f.write(as_json(example)) context = os.path.join(dirname, 'issue_80.context.jsonld') with open(context, 'w') as f: f.write( ContextGenerator( env.input_path('issue_80.yaml')).serialize()) with open(os.path.join(dirname, 'issue_80.ttl'), 'w') as f: f.write( as_rdf( example, contexts=context).serialize(format="turtle").decode()) env.generate_directory('issue_80', lambda dirname: output_generator(dirname))
def test_issue_113(self): """ Make sure that types are generated as part of the output """ env.generate_single_file( 'issue_113.py', lambda: PythonGenerator(env.input_path('issue_113.yaml') ).serialize(), comparator=lambda exp, act: compare_python(exp, act, 'issue_113.py' ), value_is_returned=True) module = compile_python(env.expected_path('issue_113.py')) example = module.TestClass(test_attribute_2="foo") assert hasattr(example, "test_attribute_2") assert hasattr(example, "test_attribute_1") example.wiible = "foo" example.test_attribute_1 = "foo" example.test_attribute_2 = "foo" env.generate_single_file( 'issue_113.json', lambda: PythonGenerator(env.input_path('issue_113.yaml') ).serialize(), comparator=lambda exp, act: compare_python(exp, act, 'issue_113.py' ), value_is_returned=True) def output_generator(dirname) -> None: with open(os.path.join(dirname, 'issue_113.json'), 'w') as f: f.write(as_json(example)) env.generate_directory('issue_113', lambda dirname: output_generator(dirname))
def test_issue_python_ordering(self): """ Make sure that types are generated as part of the output """ env.generate_single_file('issue_134.py', lambda: PythonGenerator(env.input_path('issue_134.yaml')).serialize(), comparator=compare_python, value_is_returned=True) module = compile_python(env.expected_path('issue_134.py')) e = module.E('id:1') b = module.B('id:2') e.has_b = b def output_generator(dirname) -> None: with open(os.path.join(dirname, 'issue_134.json'), 'w') as f: f.write(as_json(e)) env.generate_directory('issue_134', lambda dirname: output_generator(dirname) )
def test_issue_179(self): """ Make sure that inheritence isn't implied by reference slots """ env.generate_directory( 'issue179', lambda d: MarkdownGenerator( env.input_path('issue_179.yaml')).serialize(directory=d))
def test_issue_65(self): """ Make sure that types are generated as part of the output """ env.generate_directory('issue65', lambda d: MarkdownGenerator(env.input_path('issue_65.yaml')).serialize(directory=d))