def test_create_turtle_instance(self): organization = self.client.organizations.read("test") if organization is None: self.client.organizations.create( Organization.create_new("test", "An organization for tests")) domain = self.client.domains.read("test", "core") if domain is None: self.client.domains.create( Domain.create_new("test", "core", "A domain for tests")) schema = self.client.schemas.read("test", "core", "turtle", "v0.0.4") if schema is None: schema = self.client.schemas.create( Schema.create_new("test", "core", "turtle", "v0.0.4", self.test_turtle_schema, is_turtle=True)) if not schema.is_published(): self.client.schemas.publish(schema, True) instance = self.client.instances.create( Instance.create_new("test", "core", "turtle", "v0.0.4", self.test_turtle_instance, is_turtle=True)) instance = self.client.instances.read(instance.get_organization(), instance.get_domain(), instance.get_schema(), instance.get_version(), instance.get_id()) print instance
def test_create_and_deprecate(self): random_name = "{}".format(uuid.uuid4()).replace("-", "") entity = Schema.create_new(self.default_prefix, "core", random_name, "v0.0.1", self.test_schema) result = self.repository.create(entity) assert_that(result, equal_to(entity)) self._assert_valid_default_entity(result, self.default_prefix+"/core/"+random_name+"/v0.0.1") assert_that(result.get_revision(), equal_to(1)) self._test_deprecate(entity)
def _create_and_publish_testschema(self): schema = self.repository.read("hbp", "core", "testschema", "v0.0.1") if schema is None: schema = self.repository.create( Schema.create_new("hbp", "core", "testschema", "v0.0.1", self.test_schema)) if not schema.is_published(): self.repository.publish(schema, True)
def _create_schema(self, data, force_domain_creation, update_if_already_exists, publish): entity = Schema.create_new(data.organization, data.domain, data.name, data.version, data.content) return self._create_schema_or_context("schema", self._client.schemas, entity, data, force_domain_creation, update_if_already_exists, publish)
def test_create_turtle_schema(self): schema = self.client.schemas.read("test", "core", "turtle", "v0.0.3") if schema is None: self.client.schemas.create( Schema.create_new("test", "core", "turtle", "v0.0.3", self.test_turtle_schema, is_turtle=True))
def create_schema(self, name: str, version: str, data: JSON, publish: bool) -> Schema: key = self._entity_name(name, version) schema = self.client.schemas.read(self.organization, self.domain, name, version) if schema is not None: self._print_already_created(key) return schema else: local = Schema.create_new(self.organization, self.domain, name, version, data) schema = self.client.schemas.create(local) self.client.schemas.publish(schema, publish=publish) self._print_created(key) return schema
def create_publish_schema(self, name: str, version: str, data: JSON) -> Optional[Schema]: key = self._entity_name(name, version) if self.is_schema_pushed(name, version): self._print_already_pushed(key) return None else: local = Schema.create_new(self.organization, self.domain, name, version, data) schema = self.client.schemas.create(local) self.client.schemas.publish(schema, publish=True) self._print_pushed(key) return schema
def _create_testschema_v2(self): schema = self.repository.read("hbp", "core", "testschema", "v0.0.1") if schema is None: self.repository.create(Schema.create_new("hbp", "core", "testschema", "v0.0.1", self.test_schema))
def resolve(self, search_result): identifier = Entity.extract_id_from_url(search_result.self_link, self.path) data = self._read(identifier) return Schema(identifier, data, self.path) if data is not None else None
def read(self, organization, domain, schema, version, revision=None): identifier = Schema.create_id(organization, domain, schema, version) data = self._read(identifier, revision) return Schema(identifier, data, self.path) if data is not None else None