def test_custom_fields_are_preserved(self): ec = ElucidateClient(BASE_URI) container_name = 'custom_container_name4' container_id = ec.read_container_identifier(name=container_name) if not container_id: container_id = ec.create_container(label='This is the label', container_id=container_name) ic(container_id) expected_url = f"{BASE_URI}/{ec.version}/{container_name}/" self.assertEqual(expected_url, container_id.url) custom_context = {'custom_field': 'urn:custom_field'} annotation_id = ec.create_annotation( container_id=container_id, body={"custom_field": "custom_value"}, target={}, custom_contexts=custom_context) ic(annotation_id) annotation = ec.read_annotation(annotation_identifier=annotation_id) ic(annotation) self.assertEqual("custom_value", annotation['body']['urn:custom_field']) ok = ec.delete_annotation(annotation_identifier=annotation_id) assert ok
def test_create_container_and_annotation_with_custom_names(self): ec = ElucidateClient(BASE_URI) container_name = 'custom_container_name4' container_id = ec.read_container_identifier(name=container_name) if not container_id: container_id = ec.create_container(label='This is the label', container_id=container_name) ic(container_id) expected_url = f"{BASE_URI}/{ec.version}/{container_name}/" self.assertEqual(expected_url, container_id.url) annotation_name = "custom_annotation_name" annotation_id = ec.create_annotation(container_id=container_id, body={}, target={}, annotation_id=annotation_name) ic(annotation_id) expected_url = f"{BASE_URI}/{ec.version}/{container_name}/{annotation_name}" self.assertEqual(expected_url, annotation_id.url) ok = ec.delete_annotation(annotation_identifier=annotation_id) assert ok