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 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 test_recordlist_create_load(self): t = RecordList.create(self.testcoll, "list1", recordlist_create_values(list_id="list1")) td = RecordList.load(self.testcoll, "list1").get_values() v = recordlist_read_values(list_id="list1") self.assertKeysMatch(td, v) self.assertDictionaryMatch(td, v) 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 test_migrate_list_fields(self): """ Test migration of list fields """ self.test_list = RecordList.create(self.testcoll, test_list_id, test_list_create_values) migrate_coll_data(self.testcoll) # Read field definition and check for inline field list view_data = self.check_entity_values( "_list", test_list_id, check_values=test_list_migrated_values) return
def add_list(self, list_id, list_meta): """ Add a new record list to the current collection list_id identifier for the new list, as a string with a form that is valid as URI path segment. list_meta a dictionary providing additional information about the list to be created. returns a RecordList object for the newly created list. """ l = RecordList.create(self, list_id, list_meta) return l
def add_list(self, list_id, list_meta): """ Add a new record list to the current collection list_id identifier for the new list, as a string with a form that is valid as URI path segment. list_meta a dictionary providing additional information about the list to be created. returns a RecordList object for the newly created list. """ l = RecordList.create(self, list_id, list_meta) return l
def test_post_confirmed_remove_view(self): t = RecordList.create(self.testcoll, "deleteview", recordlist_create_values("deleteview")) self.assertTrue(RecordList.exists(self.testcoll, "deleteview")) # Submit positive confirmation u = TestHostUri + recordlist_edit_url("delete", "testcoll") f = recordlist_delete_confirm_form_data("deleteview") 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 + collection_edit_url("testcoll") + r"\?info_head=.*&info_message=.*deleteview.*testcoll.*$") # Confirm deletion self.assertFalse(RecordList.exists(self.testcoll, "deleteview")) return
def _create_list_view(self, list_id): "Helper function creates record view entry with supplied list_id" t = RecordList.create(self.testcoll, list_id, recordlist_create_values(list_id=list_id)) return t