def coll123_create_data(site): coll1 = Collection.create(site, "coll1", collection_create_values("coll1")) coll2 = Collection.create(site, "coll2", collection_create_values("coll2")) coll3 = Collection.create(site, "coll3", collection_create_values("coll3")) # for coll in [coll1, coll2, coll3]: type1 = RecordType.create( coll, "type1", recordtype_create_values(coll._entityid, "type1")) view1 = RecordView.create( coll, "view1", recordview_create_values(coll._entityid, "view1")) list1 = RecordList.create( coll, "list1", recordlist_create_values(coll._entityid, "list1")) data1 = RecordTypeData.create(coll, "type1", {}) type2 = RecordType.create( coll, "type2", recordtype_create_values(coll._entityid, "type2")) view2 = RecordView.create( coll, "view2", recordview_create_values(coll._entityid, "view2")) list2 = RecordList.create( coll, "list2", recordlist_create_values(coll._entityid, "list2")) data2 = RecordTypeData.create(coll, "type2", {}) # for t, d in [(type1, data1), (type2, data2)]: for eid in ["entity1", "entity2", "entity3"]: e = EntityData.create(d, eid, entitydata_create_values(coll, t, eid)) return
def setUp(self): init_annalist_test_site() init_annalist_test_coll() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection(self.testsite, "testcoll") # Populate collection with linked record types, views and lists self.testsrc_type = RecordType.create(self.testcoll, "testsrc_type", testsrc_type_create_values) self.testtgt_type = RecordType.create(self.testcoll, "testtgt_type", testtgt_type_create_values) self.testsrc_view = RecordView.create(self.testcoll, "testsrc_view", testsrc_view_create_values) self.testtgt_view = RecordView.create(self.testcoll, "testtgt_view", testtgt_view_create_values) self.testsrc_list = RecordList.create(self.testcoll, "testsrc_list", testsrc_list_create_values) self.testtgt_list = RecordList.create(self.testcoll, "testtgt_list", testtgt_list_create_values) self.testtgtref_field = RecordField.create(self.testcoll, "testtgtref_field", testtgtref_field_create_values) self.no_options = [ FieldChoice('', label="(no options)") ] self.tgt_options = ( [ FieldChoice("testtgt_type/"+v, label="testtgt_entity %s label"%v, link=entity_url("testcoll", "testtgt_type", v)) for v in ["testtgt1", "testtgt2"] ]) # Create data records for testing: self.testtgt_type_info = EntityTypeInfo(self.testcoll, "testtgt_type", create_typedata=True) self.testsrc_type_info = EntityTypeInfo(self.testcoll, "testsrc_type", create_typedata=True) for tgt_id in ("testtgt1", "testtgt2"): self.testtgt_type_info.create_entity(tgt_id, testtgt_entity_create_values(tgt_id)) for src_id, tgt_ref in (("testsrc1", "testtgt1"), ("testsrc2", "testtgt2")): self.testsrc_type_info.create_entity(src_id, testsrc_entity_create_values(src_id, tgt_ref)) # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return
def setUp(self): init_annalist_test_site() init_annalist_test_coll() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection(self.testsite, "testcoll") # Populate collection with linked record types, views and lists self.testsrc_type = RecordType.create(self.testcoll, "testsrc_type", testsrc_type_create_values) self.testtgt_type = RecordType.create(self.testcoll, "testtgt_type", testtgt_type_create_values) self.testsrc_view = RecordView.create(self.testcoll, "testsrc_view", testsrc_view_create_values) self.testtgt_view = RecordView.create(self.testcoll, "testtgt_view", testtgt_view_create_values) self.testsrc_list = RecordList.create(self.testcoll, "testsrc_list", testsrc_list_create_values) self.testtgt_list = RecordList.create(self.testcoll, "testtgt_list", testtgt_list_create_values) self.testtgtref_field = RecordField.create( self.testcoll, "testtgtref_field", testtgtref_field_create_values) self.no_options = [FieldChoice('', label="(no options)")] self.tgt_options = ([ FieldChoice("testtgt_type/" + v, label="testtgt_entity %s label" % v, link=entity_url("testcoll", "testtgt_type", v)) for v in ["testtgt1", "testtgt2"] ]) # Create data records for testing: self.testtgt_type_info = EntityTypeInfo(self.testcoll, "testtgt_type", create_typedata=True) self.testsrc_type_info = EntityTypeInfo(self.testcoll, "testsrc_type", create_typedata=True) for tgt_id in ("testtgt1", "testtgt2"): self.testtgt_type_info.create_entity( tgt_id, testtgt_entity_create_values(tgt_id)) for src_id, tgt_ref in (("testsrc1", "testtgt1"), ("testsrc2", "testtgt2")): self.testsrc_type_info.create_entity( src_id, testsrc_entity_create_values(src_id, tgt_ref)) # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return
def _create_ref_type_view(self, view_id="Test_ref_type_view", record_type="test:testtypes"): ref_type_view = RecordView.create( self.testcoll, view_id, { 'annal:type': "annal:View", 'annal:uri': "test:" + view_id, 'rdfs:label': "Test view label", 'rdfs:comment': "Test view comment", 'annal:record_type': record_type, 'annal:add_field': True, 'annal:view_fields': [{ 'annal:field_id': layout.FIELD_TYPEID + "/Entity_id", 'annal:field_placement': "small:0,12;medium:0,6" }, { 'annal:field_id': layout.FIELD_TYPEID + "/Test_ref_type_field", 'annal:field_placement': "small:0,12;medium:6,6" }] }) self.assertTrue(ref_type_view is not None) return ref_type_view
def setUp(self): self.filepath = "%s/README.md"%TestBaseDir self.fileuri = "file://"+self.filepath self.imagepath = "%s/test-image.jpg"%TestBaseDir self.imageuri = "file://"+self.filepath init_annalist_test_site() init_annalist_test_coll() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection(self.testsite, "testcoll") # Populate collection with record type, view and field self.test_ref_type = RecordType.create( self.testcoll, "testreftype", test_image_ref_type_create_values ) self.test_ref_view = RecordView.create( self.testcoll, "testrefview", test_image_ref_view_create_values ) self.test_ref_field = RecordField.create( self.testcoll, "Test_image_ref", test_image_ref_field_create_values ) # Create data records for testing image references: self.test_ref_type_info = EntityTypeInfo( self.testcoll, "testreftype", create_typedata=True ) self.test_ref_type_info.create_entity("test1", test_ref_entity_create_values(self.imageuri)) # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return
def setUp(self): init_annalist_test_site() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll")) self.testtype = RecordType.create(self.testcoll, "testtype", recordtype_create_values("testtype")) self.testdata = RecordTypeData.create(self.testcoll, "testtype", {}) # Create view with duplicate field id self.viewdata = recordview_create_values(view_id="DupField_view") recordview_values_add_field( self.viewdata, field_id="Entity_comment", field_placement="small:0,12" ) recordview_values_add_field( self.viewdata, field_id="Entity_comment", field_property_uri="rdfs:comment_alt", field_placement="small:0,12" ) self.testview = RecordView.create(self.testcoll, "DupField_view", self.viewdata) # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return
def _create_rptimg_view(self): rptimg_view = RecordView.create( self.testcoll, "Test_rptimg_view", { 'annal:type': "annal:View", 'annal:uri': "test:rptimg_view", 'rdfs:label': "Test rptimg view label", 'rdfs:comment': "Test rptimg view comment", 'annal:record_type': "img_type", 'annal:add_field': True, 'annal:view_fields': [{ 'annal:field_id': "Entity_id", 'annal:field_placement': "small:0,12;medium:0,6" }, { 'annal:field_id': "Test_rptref_field", 'annal:field_placement': "small:0,12;medium:6,6" }] }) self.assertTrue(rptimg_view is not None) return rptimg_view
def _create_record_view(self, view_id): "Helper function creates record view entry with supplied view_id" t = RecordView.create( self.testcoll, view_id, recordview_create_values(view_id=view_id, target_record_type="annal:View") ) return t
def setUp(self): init_annalist_test_site() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll")) self.testtype = RecordType.create(self.testcoll, "testtype", recordtype_create_values("testtype")) self.testdata = RecordTypeData.create(self.testcoll, "testtype", {}) # Create view with duplicate field id self.viewdata = recordview_create_values(view_id="DupField_view") recordview_values_add_field(self.viewdata, field_id="Entity_comment", field_placement="small:0,12") recordview_values_add_field(self.viewdata, field_id="Entity_comment", field_property_uri="rdfs:comment_alt", field_placement="small:0,12") self.testview = RecordView.create(self.testcoll, "DupField_view", self.viewdata) # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return
def _create_record_view(self, view_id): "Helper function creates record view entry with supplied view_id" t = RecordView.create( self.testcoll, view_id, recordview_create_values(view_id=view_id, view_entity_type="annal:View")) return t
def setUp(self): self.fileuri = "file://%s/README.md"%TestBaseDir init_annalist_test_site() init_annalist_test_coll() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection(self.testsite, "testcoll") # Populate collection with linked record types, views and lists self.test_imp_type = RecordType.create( self.testcoll, "testimptype", test_import_type_create_values ) self.test_imp_view = RecordView.create( self.testcoll, "testimpview", test_import_view_create_values ) self.test_imp_field = RecordField.create( self.testcoll, "Test_import", test_import_field_create_values ) self.test_ref_type = RecordType.create( self.testcoll, "testreftype", test_reference_type_create_values ) self.test_ref_view = RecordView.create( self.testcoll, "testrefview", test_reference_view_create_values ) self.test_ref_field = RecordField.create( self.testcoll, "Test_reference", test_reference_field_create_values ) # Create data records for testing import and references: self.test_imp_type_info = EntityTypeInfo( self.testcoll, "testimptype", create_typedata=True ) for entity_id in ("test1", "test2"): self.test_imp_type_info.create_entity( entity_id, test_imp_entity_create_values(entity_id) ) self.test_ref_type_info = EntityTypeInfo( self.testcoll, "testreftype", create_typedata=True ) for entity_id in ("test1", "test2"): self.test_ref_type_info.create_entity( entity_id, test_ref_entity_create_values(entity_id) ) # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return
def coll123_create_data(site): coll1 = Collection.create(site, "coll1", collection_create_values("coll1")) coll2 = Collection.create(site, "coll2", collection_create_values("coll2")) coll3 = Collection.create(site, "coll3", collection_create_values("coll3")) # for coll in [coll1, coll2, coll3]: type1 = RecordType.create(coll, "type1", recordtype_create_values(coll._entityid, "type1")) view1 = RecordView.create(coll, "view1", recordview_create_values(coll._entityid, "view1")) list1 = RecordList.create(coll, "list1", recordlist_create_values(coll._entityid, "list1")) data1 = RecordTypeData.create(coll, "type1", {}) type2 = RecordType.create(coll, "type2", recordtype_create_values(coll._entityid, "type2")) view2 = RecordView.create(coll, "view2", recordview_create_values(coll._entityid, "view2")) list2 = RecordList.create(coll, "list2", recordlist_create_values(coll._entityid, "list2")) data2 = RecordTypeData.create(coll, "type2", {}) # for t,d in [(type1,data1),(type2,data2)]: for eid in ["entity1", "entity2", "entity3"]: e = EntityData.create(d, eid, entitydata_create_values(coll,t,eid)) return
def create_subproperty_field_view_entity(self): # Create test field using superproperty self.test_sup_field = RecordField.create(self.testcoll, "Test_sup_field", { ANNAL.CURIE.type: "annal:Field" , RDFS.CURIE.label: "Field using superproperty URI" , RDFS.CURIE.comment: "Field using superproperty URI" , ANNAL.CURIE.field_render_type: "_enum_render_type/Text" , ANNAL.CURIE.field_value_mode: "_enum_value_mode/Value_direct" , ANNAL.CURIE.field_entity_type: "test:testtype" , ANNAL.CURIE.placeholder: "(Test_sup_field)" , ANNAL.CURIE.property_uri: "test:superprop_uri" , ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" }) self.assertTrue(self.test_sup_field is not None) # Create test field using subproperty and declaring superproperty self.test_sub_field = RecordField.create(self.testcoll, "Test_sub_field", { ANNAL.CURIE.type: "annal:Field" , RDFS.CURIE.label: "Field using superproperty URI" , RDFS.CURIE.comment: "Field using superproperty URI" , ANNAL.CURIE.field_render_type: "_enum_render_type/Text" , ANNAL.CURIE.field_value_mode: "_enum_value_mode/Value_direct" , ANNAL.CURIE.field_entity_type: "test:testtype" , ANNAL.CURIE.placeholder: "(Test_sub_field)" , ANNAL.CURIE.property_uri: "test:subprop_uri" , ANNAL.CURIE.superproperty_uri: [{"@id": "test:superprop_uri"}] , ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" }) self.assertTrue(self.test_sub_field is not None) # Create test view using superproperty self.test_view = RecordView.create(self.testcoll, "testview", { ANNAL.CURIE.type: "annal:View" , ANNAL.CURIE.uri: "test:view" , RDFS.CURIE.label: "Test view label" , RDFS.CURIE.comment: "Test view comment" , ANNAL.CURIE.view_entity_type: "test:testtype" , ANNAL.CURIE.view_fields: [ { ANNAL.CURIE.field_id: layout.FIELD_TYPEID+"/Entity_id" , ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" } , { ANNAL.CURIE.field_id: layout.FIELD_TYPEID+"/Test_sup_field" , ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" } ] }) self.assertTrue(self.test_view is not None) # Create test entity using subproperty self.testentity_data = EntityData.create(self.testdata, "testentity", entitydata_create_values( "testentity", type_id="testtype", type_uri="test:testtype", extra_fields={"test:subprop_uri": "Test field value"} ) ) self.assertTrue(self.testentity_data is not None) return
def test_migrate_view_fields(self): """ Test migration of view fields """ self.test_view = RecordView.create(self.testcoll, test_view_id, test_view_create_values) migrate_coll_data(self.testcoll) # Read field definition and check for inline field list view_data = self.check_entity_values( "_view", test_view_id, check_values=test_view_migrated_values) return
def add_view(self, view_id, view_meta): """ Add a new record view to the current collection view_id identifier for the new view, as a string with a form that is valid as URI path segment. view_meta a dictionary providing additional information about the view to be created. returns a RecordView object for the newly created view. """ v = RecordView.create(self, view_id, view_meta) return v
def _create_testview(self): testview = RecordView.create(self.testcoll, "testview", { 'annal:type': "annal:View" , 'annal:uri': "test:testtype" , 'rdfs:label': "Test view label" , 'rdfs:comment': "Test view comment" , 'annal:view_entity_type': "testtype" , 'annal:view_fields': [ { 'annal:field_id': "Entity_id" , 'annal:field_placement': "small:0,12;medium:0,6" } , { 'annal:field_id': "Test_repeat_field" , 'annal:field_placement': "small:0,12" } ] }) self.assertTrue(testview is not None) return testview
def _create_ref_type_view(self, view_id="Test_ref_type_view", record_type="test:testtypes"): ref_type_view = RecordView.create(self.testcoll, view_id, { 'annal:type': "annal:View" , 'annal:uri': "test:"+view_id , 'rdfs:label': "Test view label" , 'rdfs:comment': "Test view comment" , 'annal:record_type': record_type , 'annal:add_field': True , 'annal:view_fields': [ { 'annal:field_id': layout.FIELD_TYPEID+"/Entity_id" , 'annal:field_placement': "small:0,12;medium:0,6" } , { 'annal:field_id': layout.FIELD_TYPEID+"/Test_ref_type_field" , 'annal:field_placement': "small:0,12;medium:6,6" } ] }) self.assertTrue(ref_type_view is not None) return ref_type_view
def setUp(self): self.filepath = "%s/testdatafile.md"%TestBaseDir self.fileuri = "file://"+self.filepath self.imagepath = "%s/test-image.jpg"%TestBaseDir self.imageuri = "file://"+self.imagepath init_annalist_test_site() init_annalist_test_coll() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection(self.testsite, "testcoll") # Populate collection with linked record types, views and lists # Types self.test_upl_type = RecordType.create( self.testcoll, "testupltype", test_upload_type_create_values ) self.test_ref_type = RecordType.create( self.testcoll, "testreftype", test_reference_type_create_values ) self.test_image_type = RecordType.create( self.testcoll, "testimgtype", test_image_type_create_values ) # Views self.test_upl_file_view = RecordView.create( self.testcoll, "testuplfileview", test_upload_file_view_create_values ) self.test_upl_image_view = RecordView.create( self.testcoll, "testuplimageview", test_upload_image_view_create_values ) self.test_ref_file_view = RecordView.create( self.testcoll, "testrefview", test_reference_view_create_values ) self.test_ref_image_view = RecordView.create( self.testcoll, "testimgrefview", test_image_ref_view_create_values ) self.test_image_view = RecordView.create( self.testcoll, "testimgview", test_image_view_create_values ) # Fields self.test_upl_file_field = RecordField.create( self.testcoll, "Test_upload_file", test_upload_file_field_create_values ) self.test_upl_image_field = RecordField.create( self.testcoll, "Test_upload_image", test_upload_image_field_create_values ) self.test_ref_file_field = RecordField.create( self.testcoll, "Test_reference", test_reference_field_create_values ) self.test_ref_image_field = RecordField.create( self.testcoll, "Test_image_ref", test_image_ref_field_create_values ) self.test_image_field = RecordField.create( self.testcoll, "Test_image", test_image_field_create_values ) # Create data records for testing import and references: test_entity_ids = ("test1", "test2") test_entity_ids = ("test1",) self.test_upl_type_info = EntityTypeInfo( self.testcoll, "testupltype", create_typedata=True ) for entity_id in test_entity_ids: self.test_upl_type_info.create_entity( entity_id, test_imp_entity_create_values(entity_id) ) self.test_ref_type_info = EntityTypeInfo( self.testcoll, "testreftype", create_typedata=True ) for entity_id in test_entity_ids: self.test_ref_type_info.create_entity( entity_id, test_ref_entity_create_values(entity_id) ) self.test_img_type_info = EntityTypeInfo( self.testcoll, "testimgtype", create_typedata=True ) for entity_id in test_entity_ids: self.test_img_type_info.create_entity( entity_id, test_img_entity_create_values(entity_id) ) # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return
def create_subproperty_list_field_view_entity(self): # Create list field using superproperty self.test_sup_list = RecordField.create(self.testcoll, "Test_sup_list", { ANNAL.CURIE.type: "annal:Field" , RDFS.CURIE.label: "List using superproperty URI" , RDFS.CURIE.comment: "List using superproperty URI" , ANNAL.CURIE.field_render_type: "_enum_render_type/Group_Seq_Row" , ANNAL.CURIE.field_value_mode: "_enum_value_mode/Value_direct" , ANNAL.CURIE.field_value_type: "annal:Test_sup_list" , ANNAL.CURIE.field_entity_type: "test:testtype" , ANNAL.CURIE.placeholder: "(Test_sup_list)" , ANNAL.CURIE.property_uri: "test:superprop_list_uri" , ANNAL.CURIE.field_placement: "small:0,12" , ANNAL.CURIE.field_fields: [ { ANNAL.CURIE.field_id: "_field/Test_sup_field" , ANNAL.CURIE.field_placement: "small:0,12" } ] , ANNAL.CURIE.repeat_label_add: "Add sup entity" , ANNAL.CURIE.repeat_label_delete: "Remove sup entity" }) self.assertTrue(self.test_sup_list is not None) # Create list field using subproperty and declaring superproperty self.test_sub_list = RecordField.create(self.testcoll, "Test_sub_list", { ANNAL.CURIE.type: "annal:Field" , RDFS.CURIE.label: "List using superproperty URI" , RDFS.CURIE.comment: "List using superproperty URI" , ANNAL.CURIE.field_render_type: "_enum_render_type/Group_Seq_Row" , ANNAL.CURIE.field_value_mode: "_enum_value_mode/Value_direct" , ANNAL.CURIE.field_value_type: "annal:Test_sub_list" , ANNAL.CURIE.field_entity_type: "test:testtype" , ANNAL.CURIE.placeholder: "(Test_sub_list)" , ANNAL.CURIE.property_uri: "test:subprop_list_uri" , ANNAL.CURIE.superproperty_uri: [{"@id": "test:superprop_list_uri"}] , ANNAL.CURIE.field_placement: "small:0,12" , ANNAL.CURIE.field_fields: [ { ANNAL.CURIE.field_id: "_field/Test_sub_field" , ANNAL.CURIE.field_placement: "small:0,12" } ] , ANNAL.CURIE.repeat_label_add: "Add sub entity" , ANNAL.CURIE.repeat_label_delete: "Remove sub entity" }) self.assertTrue(self.test_sub_list is not None) # Create test view using superproperty self.test_view = RecordView.create(self.testcoll, "testlistview", { ANNAL.CURIE.type: "annal:View" , ANNAL.CURIE.uri: "test:listview" , RDFS.CURIE.label: "Test listview label" , RDFS.CURIE.comment: "Test listview comment" , ANNAL.CURIE.view_entity_type: "test:testtype" , ANNAL.CURIE.view_fields: [ { ANNAL.CURIE.field_id: layout.FIELD_TYPEID+"/Entity_id" , ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" } , { ANNAL.CURIE.field_id: layout.FIELD_TYPEID+"/Test_sup_list" , ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" } ] }) self.assertTrue(self.test_view is not None) # Create test entity using list and item subproperty URIs self.testlistentity_data = EntityData.create(self.testdata, "testlistentity", entitydata_create_values( "testlistentity", type_id="testtype", type_uri="test:testtype", extra_fields= { "test:subprop_list_uri": [ { "test:subprop_uri": "Test field 1 value"} , { "test:subprop_uri": "Test field 2 value"} ] } ) ) self.assertTrue(self.testlistentity_data is not None) return
def create_subproperty_list_field_view_entity(self): # Create list field using superproperty self.test_sup_list = RecordField.create( self.testcoll, "Test_sup_list", { ANNAL.CURIE.type: "annal:Field", RDFS.CURIE.label: "List using superproperty URI", RDFS.CURIE.comment: "List using superproperty URI", ANNAL.CURIE.field_render_type: "_enum_render_type/Group_Seq_Row", ANNAL.CURIE.field_value_mode: "_enum_value_mode/Value_direct", ANNAL.CURIE.field_value_type: "annal:Test_sup_list", ANNAL.CURIE.field_entity_type: "test:testtype", ANNAL.CURIE.placeholder: "(Test_sup_list)", ANNAL.CURIE.property_uri: "test:superprop_list_uri", ANNAL.CURIE.field_placement: "small:0,12", ANNAL.CURIE.field_fields: [{ ANNAL.CURIE.field_id: "_field/Test_sup_field", ANNAL.CURIE.field_placement: "small:0,12" }], ANNAL.CURIE.repeat_label_add: "Add sup entity", ANNAL.CURIE.repeat_label_delete: "Remove sup entity" }) self.assertTrue(self.test_sup_list is not None) # Create list field using subproperty and declaring superproperty self.test_sub_list = RecordField.create( self.testcoll, "Test_sub_list", { ANNAL.CURIE.type: "annal:Field", RDFS.CURIE.label: "List using superproperty URI", RDFS.CURIE.comment: "List using superproperty URI", ANNAL.CURIE.field_render_type: "_enum_render_type/Group_Seq_Row", ANNAL.CURIE.field_value_mode: "_enum_value_mode/Value_direct", ANNAL.CURIE.field_value_type: "annal:Test_sub_list", ANNAL.CURIE.field_entity_type: "test:testtype", ANNAL.CURIE.placeholder: "(Test_sub_list)", ANNAL.CURIE.property_uri: "test:subprop_list_uri", ANNAL.CURIE.superproperty_uri: [{ "@id": "test:superprop_list_uri" }], ANNAL.CURIE.field_placement: "small:0,12", ANNAL.CURIE.field_fields: [{ ANNAL.CURIE.field_id: "_field/Test_sub_field", ANNAL.CURIE.field_placement: "small:0,12" }], ANNAL.CURIE.repeat_label_add: "Add sub entity", ANNAL.CURIE.repeat_label_delete: "Remove sub entity" }) self.assertTrue(self.test_sub_list is not None) # Create test view using superproperty self.test_view = RecordView.create( self.testcoll, "testlistview", { ANNAL.CURIE.type: "annal:View", ANNAL.CURIE.uri: "test:listview", RDFS.CURIE.label: "Test listview label", RDFS.CURIE.comment: "Test listview comment", ANNAL.CURIE.view_entity_type: "test:testtype", ANNAL.CURIE.view_fields: [{ ANNAL.CURIE.field_id: layout.FIELD_TYPEID + "/Entity_id", ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" }, { ANNAL.CURIE.field_id: layout.FIELD_TYPEID + "/Test_sup_list", ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" }] }) self.assertTrue(self.test_view is not None) # Create test entity using list and item subproperty URIs self.testlistentity_data = EntityData.create( self.testdata, "testlistentity", entitydata_create_values("testlistentity", type_id="testtype", type_uri="test:testtype", extra_fields={ "test:subprop_list_uri": [{ "test:subprop_uri": "Test field 1 value" }, { "test:subprop_uri": "Test field 2 value" }] })) self.assertTrue(self.testlistentity_data is not None) return
def create_subproperty_field_view_entity(self): # Create test field using superproperty self.test_sup_field = RecordField.create( self.testcoll, "Test_sup_field", { ANNAL.CURIE.type: "annal:Field", RDFS.CURIE.label: "Field using superproperty URI", RDFS.CURIE.comment: "Field using superproperty URI", ANNAL.CURIE.field_render_type: "_enum_render_type/Text", ANNAL.CURIE.field_value_mode: "_enum_value_mode/Value_direct", ANNAL.CURIE.field_entity_type: "test:testtype", ANNAL.CURIE.placeholder: "(Test_sup_field)", ANNAL.CURIE.property_uri: "test:superprop_uri", ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" }) self.assertTrue(self.test_sup_field is not None) # Create test field using subproperty and declaring superproperty self.test_sub_field = RecordField.create( self.testcoll, "Test_sub_field", { ANNAL.CURIE.type: "annal:Field", RDFS.CURIE.label: "Field using superproperty URI", RDFS.CURIE.comment: "Field using superproperty URI", ANNAL.CURIE.field_render_type: "_enum_render_type/Text", ANNAL.CURIE.field_value_mode: "_enum_value_mode/Value_direct", ANNAL.CURIE.field_entity_type: "test:testtype", ANNAL.CURIE.placeholder: "(Test_sub_field)", ANNAL.CURIE.property_uri: "test:subprop_uri", ANNAL.CURIE.superproperty_uri: [{ "@id": "test:superprop_uri" }], ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" }) self.assertTrue(self.test_sub_field is not None) # Create test view using superproperty self.test_view = RecordView.create( self.testcoll, "testview", { ANNAL.CURIE.type: "annal:View", ANNAL.CURIE.uri: "test:view", RDFS.CURIE.label: "Test view label", RDFS.CURIE.comment: "Test view comment", ANNAL.CURIE.view_entity_type: "test:testtype", ANNAL.CURIE.view_fields: [{ ANNAL.CURIE.field_id: layout.FIELD_TYPEID + "/Entity_id", ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" }, { ANNAL.CURIE.field_id: layout.FIELD_TYPEID + "/Test_sup_field", ANNAL.CURIE.field_placement: "small:0,12;medium:0,6" }] }) self.assertTrue(self.test_view is not None) # Create test entity using subproperty self.testentity_data = EntityData.create( self.testdata, "testentity", entitydata_create_values( "testentity", type_id="testtype", type_uri="test:testtype", extra_fields={"test:subprop_uri": "Test field value"})) self.assertTrue(self.testentity_data is not None) return
def setUp(self): self.filepath = "%s/testdatafile.md" % TestBaseDir self.fileuri = "file://" + self.filepath self.imagepath = "%s/test-image.jpg" % TestBaseDir self.imageuri = "file://" + self.imagepath init_annalist_test_site() init_annalist_test_coll() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection(self.testsite, "testcoll") # Populate collection with linked record types, views and lists # Types self.test_upl_type = RecordType.create(self.testcoll, "testupltype", test_upload_type_create_values) self.test_ref_type = RecordType.create( self.testcoll, "testreftype", test_reference_type_create_values) self.test_image_type = RecordType.create( self.testcoll, "testimgtype", test_image_type_create_values) # Views self.test_upl_file_view = RecordView.create( self.testcoll, "testuplfileview", test_upload_file_view_create_values) self.test_upl_image_view = RecordView.create( self.testcoll, "testuplimageview", test_upload_image_view_create_values) self.test_ref_file_view = RecordView.create( self.testcoll, "testrefview", test_reference_view_create_values) self.test_ref_image_view = RecordView.create( self.testcoll, "testimgrefview", test_image_ref_view_create_values) self.test_image_view = RecordView.create( self.testcoll, "testimgview", test_image_view_create_values) # Fields self.test_upl_file_field = RecordField.create( self.testcoll, "Test_upload_file", test_upload_file_field_create_values) self.test_upl_image_field = RecordField.create( self.testcoll, "Test_upload_image", test_upload_image_field_create_values) self.test_ref_file_field = RecordField.create( self.testcoll, "Test_reference", test_reference_field_create_values) self.test_ref_image_field = RecordField.create( self.testcoll, "Test_image_ref", test_image_ref_field_create_values) self.test_image_field = RecordField.create( self.testcoll, "Test_image", test_image_field_create_values) # Create data records for testing import and references: test_entity_ids = ("test1", "test2") test_entity_ids = ("test1", ) self.test_upl_type_info = EntityTypeInfo(self.testcoll, "testupltype", create_typedata=True) for entity_id in test_entity_ids: self.test_upl_type_info.create_entity( entity_id, test_imp_entity_create_values(entity_id)) self.test_ref_type_info = EntityTypeInfo(self.testcoll, "testreftype", create_typedata=True) for entity_id in test_entity_ids: self.test_ref_type_info.create_entity( entity_id, test_ref_entity_create_values(entity_id)) self.test_img_type_info = EntityTypeInfo(self.testcoll, "testimgtype", create_typedata=True) for entity_id in test_entity_ids: self.test_img_type_info.create_entity( entity_id, test_img_entity_create_values(entity_id)) # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return