Beispiel #1
0
 def _check_entity_data_values(self,
                               entity_id,
                               type_id="testtype",
                               type_uri=None,
                               update="Entity",
                               parent=None,
                               update_dict=None):
     "Helper function checks content of form-updated record type entry with supplied entity_id"
     recorddata = RecordTypeData.load(self.testcoll, type_id)
     self.assertTrue(EntityData.exists(recorddata, entity_id))
     e = EntityData.load(recorddata, entity_id)
     self.assertEqual(e.get_id(), entity_id)
     self.assertEqual(
         e.get_url(""),
         TestHostUri + entity_url("testcoll", type_id, entity_id))
     v = entitydata_values(entity_id,
                           type_id=type_id,
                           type_uri=type_uri,
                           update=update)
     if update_dict:
         v.update(update_dict)
         for k in update_dict:
             if update_dict[k] is None:
                 v.pop(k, None)
     self.assertDictionaryMatch(e.get_values(), v)
     return e
Beispiel #2
0
 def test_post_edit_type_new_id(self):
     # Check logic applied when type is renamed
     (t, d1, e1) = self._create_record_type("edittype1", entity_id="typeentity")
     self.assertTrue(RecordType.exists(self.testcoll, "edittype1"))
     self.assertFalse(RecordType.exists(self.testcoll, "edittype2"))
     self.assertTrue(RecordTypeData.exists(self.testcoll, "edittype1"))
     self.assertFalse(RecordTypeData.exists(self.testcoll, "edittype2"))
     self.assertTrue(EntityData.exists(d1, "typeentity"))
     self._check_record_type_values("edittype1")
     f = recordtype_entity_view_form_data(
         type_id="edittype2", orig_id="edittype1", 
         action="edit", update="Updated RecordType"
         )
     u = entitydata_edit_url(
         "edit", "testcoll", layout.TYPE_TYPEID, entity_id="edittype1", view_id="Type_view"
         )
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content,       "")
     self.assertEqual(r['location'], self.continuation_url)
     # Check that new record type exists and old does not
     self.assertFalse(RecordType.exists(self.testcoll, "edittype1"))
     self.assertTrue(RecordType.exists(self.testcoll, "edittype2"))
     self._check_record_type_values("edittype2", update="Updated RecordType")
     # Check that type data directory has been renamed
     self.assertFalse(RecordTypeData.exists(self.testcoll, "edittype1"))
     self.assertTrue(RecordTypeData.exists(self.testcoll, "edittype2"))
     self.assertFalse(EntityData.exists(d1, "typeentity"))
     d2 = RecordTypeData.load(self.testcoll, "edittype2")
     self.assertTrue(EntityData.exists(d2, "typeentity"))
     return
Beispiel #3
0
 def setUp(self):
     self.testsite  = init_annalist_test_site()
     self.testcoll  = init_annalist_test_coll()
     self.testsubcoll = create_test_coll_inheriting(
         base_coll_id="testcoll", coll_id="testsubcoll", type_id="testtype"
         )
     create_test_user(self.testcoll,    "testuser",    "testpassword")
     create_test_user(self.testsubcoll, "testsubuser", "testpassword")
     # Allow user "testuser" access in collectrion "testsubcoll"
     user_permissions = ["VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG"]
     user_id          = "testuser"
     user_perms = self.testsubcoll.create_user_permissions(
         user_id, "mailto:%s@%s"%(user_id, TestHost),
         "Test Subuser",
         "User %s: permissions for %s in collection %s"%
           ( user_id, "Test Subuser", self.testsubcoll.get_id() ),
         user_permissions)
     # Block user "testsubuser" access in collection "testcoll"
     user_permissions = []
     user_id          = "testsubuser"
     user_perms = self.testcoll.create_user_permissions(
         user_id, "mailto:%s@%s"%(user_id, TestHost),
         "Test Subuser",
         "User %s: permissions for %s in collection %s"%
           ( user_id, "Test Subuser", self.testcoll.get_id() ),
         user_permissions)
     # Block default user access in collection "testcoll"
     user_permissions = []
     user_id          = "_default_user_perms"
     user_uri         = "annal:User/_default_user_perms"
     user_perms = self.testcoll.create_user_permissions(
         user_id, user_uri,
         "Test Subuser",
         "User %s: permissions for %s in collection %s"%
           ( user_id, "Test Subuser", self.testcoll.get_id() ),
         user_permissions)
     # Create inherited entity "testcoll/testtype/entity2"
     self.testdata    = RecordTypeData.load(self.testcoll, "testtype")
     self.testentity2 = self._create_entity_data("entity2")
     self.testsubdata = RecordTypeData.load(self.testsubcoll, "testtype")
     # loggedin = self.client.login(username="******", password="******")
     # self.assertTrue(loggedin)
     self.continuation_url = entitydata_list_type_url(
         coll_id="testsubcoll", type_id="testtype"
         )
     return
 def _check_entity_data_values(self, 
         entity_id, type_id="testtype", type_uri=None,
         update="Entity", parent=None, 
         update_dict=None):
     "Helper function checks content of form-updated record type entry with supplied entity_id"
     recorddata = RecordTypeData.load(self.testcoll, type_id)
     self.assertTrue(EntityData.exists(recorddata, entity_id))
     e = EntityData.load(recorddata, entity_id)
     self.assertEqual(e.get_id(), entity_id)
     self.assertEqual(e.get_url(""), TestHostUri + entity_url("testcoll", type_id, entity_id))
     v = entitydata_values(entity_id, type_id=type_id, type_uri=type_uri, update=update)
     if update_dict:
         v.update(update_dict)
         for k in update_dict:
             if update_dict[k] is None:
                 v.pop(k, None)
     self.assertDictionaryMatch(e.get_values(), v)
     return e
 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
Beispiel #6
0
 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
Beispiel #7
0
 def test_post_edit_type_new_id(self):
     # Check logic applied when type is renamed
     (t, d1, e1) = self._create_record_type("edittype1",
                                            entity_id="typeentity")
     self.assertTrue(RecordType.exists(self.testcoll, "edittype1"))
     self.assertFalse(RecordType.exists(self.testcoll, "edittype2"))
     self.assertTrue(RecordTypeData.exists(self.testcoll, "edittype1"))
     self.assertFalse(RecordTypeData.exists(self.testcoll, "edittype2"))
     self.assertTrue(EntityData.exists(d1, "typeentity"))
     self._check_record_type_values("edittype1")
     f = recordtype_entity_view_form_data(type_id="edittype2",
                                          orig_id="edittype1",
                                          action="edit",
                                          update="Updated RecordType")
     u = entitydata_edit_url("edit",
                             "testcoll",
                             "_type",
                             entity_id="edittype1",
                             view_id="Type_view")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code, 302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content, "")
     self.assertEqual(r['location'], self.continuation_url)
     # Check that new record type exists and old does not
     self.assertFalse(RecordType.exists(self.testcoll, "edittype1"))
     self.assertTrue(RecordType.exists(self.testcoll, "edittype2"))
     self._check_record_type_values("edittype2",
                                    update="Updated RecordType")
     # Check that type data directory has been renamed
     self.assertFalse(RecordTypeData.exists(self.testcoll, "edittype1"))
     self.assertTrue(RecordTypeData.exists(self.testcoll, "edittype2"))
     self.assertFalse(EntityData.exists(d1, "typeentity"))
     d2 = RecordTypeData.load(self.testcoll, "edittype2")
     self.assertTrue(EntityData.exists(d2, "typeentity"))
     return