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("testcoll", "testtype")) self.testtype2 = RecordType.create( self.testcoll, "testtype2", recordtype_create_values("testcoll", "testtype2")) self.testdata = RecordTypeData.create(self.testcoll, "testtype", {}) self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {}) e1 = self._create_entity_data("entity1") e2 = self._create_entity_data("entity2") e3 = self._create_entity_data("entity3") e4 = EntityData.create( self.testdata2, "entity4", entitydata_create_values("entity4", type_id="testtype2")) self.type_ids = get_site_types_linked("testcoll") self.type_ids.append( FieldChoice("testtype", label="RecordType testcoll/testtype", link=recordtype_url("testcoll", "testtype"))) self.list_ids = get_site_lists_linked("testcoll") # 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 test_entitydata2_data(self): e = EntityData(self.testdata, "entitydata2") e.set_values(entitydata_create_values("entitydata2")) ed = e.get_values() self.assertEqual(set(ed.keys()), set(entitydata_value_keys())) v = entitydata_values("entitydata2") self.assertEqual(ed, {k:v[k] for k in entitydata_value_keys()}) return
def test_entitydata_create_load(self): e = EntityData.create(self.testdata, "entitydata1", entitydata_create_values("entitydata1")) self.assertEqual(e._entitydir, entitydata_dir(entity_id="entitydata1")) self.assertTrue(os.path.exists(e._entitydir)) ed = EntityData.load(self.testdata, "entitydata1").get_values() v = entitydata_values("entitydata1") self.assertKeysMatch(ed, v) self.assertDictionaryMatch(ed, v) return
def create_data(self, entity_id): # Create placeholder for testing typedata = RecordTypeData.create(self.testcoll, "Default_type", {}) assert typedata is not None e = EntityData.create( typedata, entity_id, entitydata_create_values(entity_id, coll_id="testcoll", type_id="Default_type")) return e
def _create_entity_data(self, entity_id, type_id="testtype", update="Entity", comment2="Comment field 2", comment3="Comment field 3" ): "Helper function creates entity data with supplied entity_id" v = entitydata_create_values(entity_id, type_id=type_id, update=update) v = entitydata_values_add_field(v, "rdfs:comment", 2, comment2) v = entitydata_values_add_field(v, "rdfs:comment_alt", 3, comment3) e = EntityData.create(self.testdata, entity_id, v) return e
def setUp(self): init_annalist_test_site() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection(self.testsite, "testcoll") self.testcoll1_a = Collection(self.testsite, "testcoll1") self.testcoll1_b = Collection(self.testsite, "testcoll1") self.testcoll2_a = Collection(self.testsite, "testcoll2") self.testcoll2_b = Collection(self.testsite, "testcoll2") self.vocabcache = CollectionVocabCache() self.vocab1 = RecordVocab(self.testcoll1_a, "vocab1") self.vocab1.set_values( entitydata_create_values("vocab1", type_id="_vocab", entity_uri="test:vocab1")) self.vocab2 = RecordVocab(self.testcoll1_a, "vocab2") self.vocab2.set_values( entitydata_create_values("vocab2", type_id="_vocab", entity_uri="test:vocab2")) return
def setUp(self): self.testsite = init_annalist_test_site() self.testcoll = init_annalist_named_test_coll(layout.BIBDATA_ID) self.testdata = RecordTypeData.load(self.testcoll, "testtype") self.testtype2 = RecordType.create( self.testcoll, "testtype2", recordtype_create_values("testcoll", "testtype2") ) self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {}) create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) e1 = self._create_entity_data("entity1") e2 = self._create_entity_data("entity2") e3 = self._create_entity_data("entity3") e4 = EntityData.create(self.testdata2, "entity4", entitydata_create_values("entity4", type_id="testtype2") ) self.list_ids = get_site_bib_lists_linked("testcoll") return
def test_post_confirmed_remove_entity_from_search(self): t = EntityData.create(self.testdata, "deleteentity", entitydata_create_values("deleteentity")) self.assertTrue(EntityData.exists(self.testdata, "deleteentity")) # Submit positive confirmation u = entitydata_delete_confirm_url("testcoll", "testtype") f = entitydata_delete_confirm_form_data("deleteentity", search="testcoll") r = self.client.post(u, f) self.assertEqual(r.status_code, 302) self.assertEqual(r.reason_phrase, "FOUND") self.assertEqual(r.content, "") self.assertMatch(r['location'], "^"+TestHostUri+ entitydata_list_all_url("testcoll") ) self.assertMatch(r['location'], r"info_head=.*&info_message=.*deleteentity.*testcoll.*$" ) self.assertIn("search=testcoll", r['location']) # Confirm deletion self.assertFalse(EntityData.exists(self.testcoll, "deleteentity")) 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("testcoll", "testtype")) self.testtype2 = RecordType.create(self.testcoll, "testtype2", recordtype_create_values("testcoll", "testtype2")) self.testdata = RecordTypeData.create(self.testcoll, "testtype", {}) self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {}) # self.user = User.objects.create_user('testuser', '*****@*****.**', 'testpassword') # self.user.save() create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) e1 = self._create_entity_data("entity1") e2 = self._create_entity_data("entity2") e3 = self._create_entity_data("entity3") e4 = EntityData.create(self.testdata2, "entity4", entitydata_create_values("entity4", type_id="testtype2") ) self.list_ids = get_site_lists_linked("testcoll") return
def test_post_confirmed_remove_entity_from_search(self): t = EntityData.create(self.testdata, "deleteentity", entitydata_create_values("deleteentity")) self.assertTrue(EntityData.exists(self.testdata, "deleteentity")) # Submit positive confirmation u = entitydata_delete_confirm_url("testcoll", "testtype") f = entitydata_delete_confirm_form_data("deleteentity", search="testcoll") r = self.client.post(u, f) self.assertEqual(r.status_code, 302) self.assertEqual(r.reason_phrase, "FOUND") self.assertEqual(r.content, "") self.assertMatch(r['location'], "^"+TestHostUri+ entitydata_list_all_url("testcoll") ) self.assertMatch(r['location'], r"info_head=.*$" ) self.assertMatch(r['location'], r"info_message=.*deleteentity.*testcoll.*$" ) self.assertIn("search=testcoll", r['location']) # Confirm deletion self.assertFalse(EntityData.exists(self.testcoll, "deleteentity")) return
def _create_entity_data(self, entity_id, update="Entity"): "Helper function creates entity data in 'testcoll/testtype' with supplied id" e = EntityData.create(self.testdata, entity_id, entitydata_create_values(entity_id, update=update) ) return e
def _create_entity_data(self, entity_id, update="Entity"): "Helper function creates entity data with supplied entity_id" e = EntityData.create(self.testdata, entity_id, entitydata_create_values(entity_id, update=update) ) return e
def setUp(self): init_annalist_test_site() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection.create( self.testsite, "testcoll", collection_create_values("testcoll") ) # Create test types self.testtypes = RecordType.create( self.testcoll, "testtypes", recordtype_create_values( coll_id="testcoll", type_id="testtypes", type_uri="test:testtypes", supertype_uris=[] ) ) self.testtype1 = RecordType.create( self.testcoll, "testtype1", recordtype_create_values( coll_id="testcoll", type_id="testtype1", type_uri="test:testtype1", supertype_uris=["test:testtypes"] ) ) self.testtype2 = RecordType.create( self.testcoll, "testtype2", recordtype_create_values( coll_id="testcoll", type_id="testtype2", type_uri="test:testtype2", supertype_uris=["test:testtypes"] ) ) self.ref_type = RecordType.create( self.testcoll, "ref_type", recordtype_create_values( coll_id="testcoll", type_id="ref_type", type_uri="test:ref_type", supertype_uris=[] ) ) # Create test type data parents self.testdatas = RecordTypeData.create(self.testcoll, "testtypes", {}) self.testdata1 = RecordTypeData.create(self.testcoll, "testtype1", {}) self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {}) self.ref_data = RecordTypeData.create(self.testcoll, "ref_type", {}) # Create test type data es = EntityData.create(self.testdatas, "entitys", entitydata_create_values( "entitys", type_id="testtypes", extra_fields={"test:turi": "test:testtypes"} ) ) e1 = EntityData.create(self.testdata1, "entity1", entitydata_create_values( "entity1", type_id="testtype1", extra_fields={"test:turi": "test:testtype1"} ) ) e2 = EntityData.create(self.testdata2, "entity2", entitydata_create_values( "entity2", type_id="testtype2", extra_fields={"test:turi": "test:testtype2"} ) ) # 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")) # Create test types self.testtypes = RecordType.create( self.testcoll, "testtypes", recordtype_create_values(coll_id="testcoll", type_id="testtypes", type_uri="test:testtypes", supertype_uris=[])) self.testtype1 = RecordType.create( self.testcoll, "testtype1", recordtype_create_values(coll_id="testcoll", type_id="testtype1", type_uri="test:testtype1", supertype_uris=["test:testtypes"])) self.testtype2 = RecordType.create( self.testcoll, "testtype2", recordtype_create_values(coll_id="testcoll", type_id="testtype2", type_uri="test:testtype2", supertype_uris=["test:testtypes"])) self.ref_type = RecordType.create( self.testcoll, "ref_type", recordtype_create_values(coll_id="testcoll", type_id="ref_type", type_uri="test:ref_type", supertype_uris=[])) # Create test type data parents self.testdatas = RecordTypeData.create(self.testcoll, "testtypes", {}) self.testdata1 = RecordTypeData.create(self.testcoll, "testtype1", {}) self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {}) self.ref_data = RecordTypeData.create(self.testcoll, "ref_type", {}) # Create test type data es = EntityData.create( self.testdatas, "entitys", entitydata_create_values( "entitys", type_id="testtypes", extra_fields={"test:turi": "test:testtypes"})) e1 = EntityData.create( self.testdata1, "entity1", entitydata_create_values( "entity1", type_id="testtype1", extra_fields={"test:turi": "test:testtype1"})) e2 = EntityData.create( self.testdata2, "entity2", entitydata_create_values( "entity2", type_id="testtype2", extra_fields={"test:turi": "test:testtype2"})) # 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_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 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