def generate_schema(cls, context, *args, **kwargs): session = execution_session.ExecutionSession() session.token = context['token'] session.project_id = context['project_id'] with package_loader.CombinedPackageLoader(session) as pkg_loader: return schema_generator.generate_schema( pkg_loader, ContextManager(), *args, **kwargs)
def setUp(self): super(TestSchemaGeneration, self).setUp() schema = schema_generator.generate_schema( self.package_loader, runner.TestContextManager({}), 'TestSchema') self._class_schema = schema.pop('') self._model_builders_schema = schema
def test_generate_schema_with_extra_params(self): schema = schema_generator.generate_schema(self.package_loader, runner.TestContextManager( {}), 'TestSchema', method_names='modelBuilder', package_name='tests') expected_schema = { '$schema': 'http://json-schema.org/draft-04/schema#', 'additionalProperties': False, 'formSections': {}, 'properties': { 'arg1': { 'title': 'Arg1!', 'type': 'string' }, 'arg2': { 'type': 'integer' } }, 'title': 'Model Builder!', 'type': 'object' } self.assertIn('modelBuilder', schema) self.assertEqual(expected_schema, schema['modelBuilder'])