コード例 #1
0
 def test_post_edit_entity_new_type(self):
     self._create_entity_data("entityedittype")
     e1 = self._check_entity_data_values("entityedittype")
     self.assertFalse(RecordType.exists(self.testcoll, "newtype"))
     newtype     = RecordType.create(self.testcoll, "newtype", recordtype_create_values("newtype"))
     newtypedata = RecordTypeData(self.testcoll, "newtype")
     self.assertTrue(RecordType.exists(self.testcoll, "newtype"))
     self.assertFalse(RecordTypeData.exists(self.testcoll, "newtype"))
     # Now post edit form submission with new type id
     f = default_view_form_data(
         entity_id="entityedittype", orig_id="entityedittype", 
         type_id="newtype", orig_type="testtype",
         action="edit")
     u = entitydata_edit_url("edit", "testcoll", "testtype", entity_id="entityedittype")
     r = self.client.post(u, f)
     # log.info("***********\n"+r.content)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "Found")
     self.assertEqual(r.content,       b"")
     self.assertEqual(r['location'],   entitydata_list_type_url("testcoll", "testtype"))
     # Check that new record type data now exists, and that new record exists and old does not
     self.assertTrue(RecordTypeData.exists(self.testcoll, "newtype"))
     self.assertFalse(EntityData.exists(self.testdata, "entityedittype"))
     self.assertTrue(EntityData.exists(newtypedata, "entityedittype"))
     self._check_entity_data_values("entityedittype", type_id="newtype")
     return
コード例 #2
0
 def test_post_edit_entity_new_type(self):
     self._create_entity_data("entityedittype")
     e1 = self._check_entity_data_values("entityedittype")
     self.assertFalse(RecordType.exists(self.testcoll, "newtype"))
     newtype = RecordType.create(self.testcoll, "newtype",
                                 recordtype_create_values("newtype"))
     newtypedata = RecordTypeData(self.testcoll, "newtype")
     self.assertTrue(RecordType.exists(self.testcoll, "newtype"))
     self.assertFalse(RecordTypeData.exists(self.testcoll, "newtype"))
     # Now post edit form submission with new type id
     f = entitydata_form_data(entity_id="entityedittype",
                              orig_id="entityedittype",
                              type_id="newtype",
                              orig_type="testtype",
                              action="edit")
     u = entitydata_edit_url("edit",
                             "testcoll",
                             "testtype",
                             entity_id="entityedittype")
     r = self.client.post(u, f)
     # log.info("***********\n"+r.content)
     self.assertEqual(r.status_code, 302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content, "")
     self.assertEqual(
         r['location'],
         TestHostUri + entitydata_list_type_url("testcoll", "testtype"))
     # Check that new record type data now exists, and that new record exists and old does not
     self.assertTrue(RecordTypeData.exists(self.testcoll, "newtype"))
     self.assertFalse(EntityData.exists(self.testdata, "entityedittype"))
     self.assertTrue(EntityData.exists(newtypedata, "entityedittype"))
     self._check_entity_data_values("entityedittype", type_id="newtype")
     return
コード例 #3
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
コード例 #4
0
 def test_post_copy_entity_cancel(self):
     self.assertFalse(EntityData.exists(self.testdata, "copytype"))
     f = default_view_form_data(entity_id="copytype", action="copy", cancel="Cancel")
     u = entitydata_edit_url("copy", "testcoll", "testtype", entity_id="entity1")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "Found")
     self.assertEqual(r.content,       b"")
     self.assertEqual(r['location'],   entitydata_list_type_url("testcoll", "testtype"))
     # Check that target record type still does not exist
     self.assertFalse(EntityData.exists(self.testdata, "copytype"))
     return
コード例 #5
0
 def test_new_entity_new_type(self):
     # Checks logic for creating an entity which may require creation of new recorddata
     # Create new type
     self.assertFalse(RecordType.exists(self.testcoll, "newtype"))
     f = type_view_form_data(action="new",
         coll_id="testcoll", 
         type_entity_id="newtype",            
         )
     u = entitydata_edit_url("new", "testcoll", type_id="_type", 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,       b"")
     self.assertEqual(r['location'],   entitydata_list_type_url("testcoll", "_type"))
     self.assertTrue(RecordType.exists(self.testcoll, "newtype"))
     # Create new entity
     self.assertFalse(EntityData.exists(self.testdata, "newentity"))
     f = default_view_form_data(entity_id="newentity", type_id="newtype", action="new")
     u = entitydata_edit_url("new", "testcoll", "newtype", view_id="Default_view")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "Found")
     self.assertEqual(r.content,       b"")
     self.assertEqual(r['location'],   entitydata_list_type_url("testcoll", "newtype"))
     # Check new entity data created
     self._check_entity_data_values("newentity", type_id="newtype")
     return
コード例 #6
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
コード例 #7
0
 def test_post_new_entity_cancel(self):
     self.assertFalse(EntityData.exists(self.testdata, "newentity"))
     f = entitydata_form_data(entity_id="newentity",
                              action="new",
                              cancel="Cancel")
     u = entitydata_edit_url("new", "testcoll", "testtype")
     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'],
         TestHostUri + entitydata_list_type_url("testcoll", "testtype"))
     # Check that new record type still does not exist
     self.assertFalse(EntityData.exists(self.testdata, "newentity"))
     return
コード例 #8
0
 def test_post_default_form_use_view(self):
     self._create_entity_data("entityuseview")
     self.assertTrue(EntityData.exists(self.testdata, "entityuseview"))
     f = entitydata_default_view_form_data(
         entity_id="entityuseview",
         action="view",
         use_view="_view/Type_view",
     )
     f.pop('entity_id', None)
     u = entitydata_edit_url("view",
                             "testcoll",
                             "testtype",
                             "entityuseview",
                             view_id="Default_view")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code, 302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content, "")
     v = TestHostUri + entitydata_edit_url("view",
                                           "testcoll",
                                           "testtype",
                                           entity_id="entityuseview",
                                           view_id="Type_view")
     c = continuation_url_param("/testsite/c/testcoll/d/testtype/")
     self.assertIn(v, r['location'])
     self.assertIn(c, r['location'])
     self._check_entity_data_values("entityuseview")
     return
コード例 #9
0
 def test_post_new_entity_enum_type_new(self):
     self.assertFalse(EntityData.exists(self.testdata, "entitynewtype"))
     f = default_view_form_data(entity_id="entitynewtype",
                                action="new",
                                update="Updated entity",
                                new_enum="entity_type__new_edit")
     u = entitydata_edit_url("new",
                             "testcoll",
                             "testtype",
                             view_id="Default_view")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code, 302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content, "")
     # v = entitydata_edit_url("new", "testcoll", "_type", view_id="Type_view")
     v = entitydata_edit_url("edit",
                             "testcoll",
                             "_type",
                             "testtype",
                             view_id="Type_view")
     w = entitydata_edit_url("edit",
                             "testcoll",
                             "testtype",
                             entity_id="entitynewtype",
                             view_id="Default_view")
     c = continuation_url_param(w)
     self.assertIn(TestHostUri + v, r['location'])
     self.assertIn(c, r['location'])
     self._check_entity_data_values("entitynewtype",
                                    update="Updated entity")
     return
コード例 #10
0
 def test_post_copy_inherited_entity_no_access(self):
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     self.assertFalse(EntityData.exists(self.testsubdata, "entity2"))
     f = default_view_form_data(action="copy", 
         entity_id="entity2", type_id="testtype", coll_id="testsubcoll",
         orig_coll="testcoll"
         )
     u = entitydata_edit_url(action="copy", 
         coll_id="testsubcoll", type_id="testtype", entity_id="entity2", 
         view_id="Default_view"
         )
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   403)
     self.assertEqual(r.reason_phrase, "Forbidden")
     # Check that no new data exists
     self.assertFalse(EntityData.exists(self.testsubdata, "entity2"))
     return
コード例 #11
0
ファイル: test_entitydelete.py プロジェクト: gklyne/annalist
 def test_post_confirmed_remove_entity(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")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,    302)
     self.assertEqual(r.reason_phrase,  "Found")
     self.assertEqual(r.content,        b"")
     v  = entitydata_list_all_url("testcoll")
     self.assertIn(v, r['location'])
     self.assertIn("info_head=",         r['location'])
     self.assertIn("info_message=",      r['location'])
     self.assertNotIn("search=testcoll", r['location'])
     # Confirm deletion
     self.assertFalse(EntityData.exists(self.testcoll, "deleteentity"))
     return
コード例 #12
0
 def test_post_copy_inherited_entity(self):
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     self.assertFalse(EntityData.exists(self.testsubdata, "entity2"))
     f = default_view_form_data(action="copy", 
         entity_id="entity2", type_id="testtype", coll_id="testsubcoll",
         orig_coll="testcoll"
         )
     u = entitydata_edit_url(action="copy", 
         coll_id="testsubcoll", type_id="testtype", entity_id="entity2", 
         view_id="Default_view"
         )
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content,       "")
     self.assertIn(self.continuation_url, r['location'])
     # Check that new data exists
     self.assertTrue(EntityData.exists(self.testsubdata, "entity2"))
     return
コード例 #13
0
 def test_post_new_entity(self):
     self.assertFalse(EntityData.exists(self.testdata, "newentity"))
     f = default_view_form_data(entity_id="newentity", action="new")
     u = entitydata_edit_url("new", "testcoll", "testtype", view_id="Default_view")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "Found")
     self.assertEqual(r.content,       b"")
     self.assertEqual(r['location'],   entitydata_list_type_url("testcoll", "testtype"))
     # Check new entity data created
     self._check_entity_data_values("newentity")
     return
コード例 #14
0
 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
コード例 #15
0
 def test_get_view_inherited_entity(self):
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     self.assertFalse(EntityData.exists(self.testsubdata, "entity2"))
     u = entitydata_edit_url(
         "edit", "testsubcoll", 
         "testtype", entity_id="entity2", 
         view_id="Default_view"
         )
     r = self.client.get(u)
     self.assertEqual(r.status_code,   200)
     self.assertEqual(r.reason_phrase, "OK")
     # self.assertEqual(r.content,       "")
     return
コード例 #16
0
 def test_post_new_entity(self):
     self.assertFalse(EntityData.exists(self.testdata, "newentity"))
     f = entitydata_form_data(entity_id="newentity", action="new")
     u = entitydata_edit_url("new", "testcoll", "testtype")
     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'],
         TestHostUri + entitydata_list_type_url("testcoll", "testtype"))
     # Check new entity data created
     self._check_entity_data_values("newentity")
     return
コード例 #17
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
コード例 #18
0
 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
コード例 #19
0
 def test_post_edit_entity_new_id(self):
     self._create_entity_data("entityeditid1")
     e1 = self._check_entity_data_values("entityeditid1")
     # Now post edit form submission with different values and new id
     f  = default_view_form_data(entity_id="entityeditid2", orig_id="entityeditid1", action="edit")
     u  = entitydata_edit_url("edit", "testcoll", "testtype", entity_id="entityeditid1")
     r  = self.client.post(u, f)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "Found")
     self.assertEqual(r.content,       b"")
     self.assertEqual(r['location'],   entitydata_list_type_url("testcoll", "testtype"))
     # Check that new record type exists and old does not
     self.assertFalse(EntityData.exists(self.testdata, "entityeditid1"))
     self._check_entity_data_values("entityeditid2")
     return
コード例 #20
0
 def test_post_copy_entity(self):
     self.assertFalse(EntityData.exists(self.testdata, "copytype"))
     f = default_view_form_data(entity_id="copytype", action="copy")
     u = entitydata_edit_url("copy",
                             "testcoll",
                             "testtype",
                             entity_id="entity1")
     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'],
         TestHostUri + entitydata_list_type_url("testcoll", "testtype"))
     # Check that new record type exists
     self._check_entity_data_values("copytype")
     return
コード例 #21
0
 def test_new_entity_default_type(self):
     # Checks logic related to creating a new recorddata entity in collection 
     # for type defined in site data
     self.assertFalse(EntityData.exists(self.testdata, "newentity"))
     f = default_view_form_data(entity_id="newentity", type_id="Default_type", action="new")
     u = entitydata_edit_url("new", "testcoll", "Default_type", view_id="Default_view")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "Found")
     self.assertEqual(r.content,       b"")
     self.assertEqual(r['location'],   entitydata_list_type_url("testcoll", "Default_type"))
     # Check new entity data created
     self._check_entity_data_values(
         "newentity", type_id="Default_type", type_uri="annal:Default_type",
         update_dict=
             { '@type': ['annal:Default_type', 'annal:EntityData'] }
         )
     return
コード例 #22
0
 def test_post_new_entity_new_type(self):
     self.assertFalse(EntityData.exists(self.testdata, "entitynewtype"))
     f = entitydata_default_view_form_data(
         entity_id="entitynewtype", action="new", update="Updated entity", 
         new_type="New type"
         )
     u = entitydata_edit_url("new", "testcoll", "testtype", view_id="Default_view")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content,       "")
     v = TestHostUri + entitydata_edit_url("new", "testcoll", "_type", view_id="Type_view")
     w = entitydata_edit_url("edit", "testcoll", "testtype", entity_id="entitynewtype", view_id="Default_view")
     c = continuation_url_param(w)
     self.assertIn(v, r['location'])
     self.assertIn(c, r['location'])
     self._check_entity_data_values("entitynewtype", update="Updated entity")
     return
コード例 #23
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
コード例 #24
0
 def test_new_entity_default_type(self):
     # Checks logic related to creating a new recorddata entity in collection
     # for type defined in site data
     self.assertFalse(EntityData.exists(self.testdata, "newentity"))
     f = entitydata_form_data(entity_id="newentity",
                              type_id="Default_type",
                              action="new")
     u = entitydata_edit_url("new", "testcoll", "Default_type")
     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'],
         TestHostUri + entitydata_list_type_url("testcoll", "Default_type"))
     # Check new entity data created
     self._check_entity_data_values(
         "newentity",
         type_id="Default_type",
         update_dict={'@type': ['annal:Default_type', 'annal:EntityData']})
     return
コード例 #25
0
 def test_post_edit_entity_new_id(self):
     self._create_entity_data("entityeditid1")
     e1 = self._check_entity_data_values("entityeditid1")
     # Now post edit form submission with different values and new id
     f = entitydata_form_data(entity_id="entityeditid2",
                              orig_id="entityeditid1",
                              action="edit")
     u = entitydata_edit_url("edit",
                             "testcoll",
                             "testtype",
                             entity_id="entityeditid1")
     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'],
         TestHostUri + entitydata_list_type_url("testcoll", "testtype"))
     # Check that new record type exists and old does not
     self.assertFalse(EntityData.exists(self.testdata, "entityeditid1"))
     self._check_entity_data_values("entityeditid2")
     return
コード例 #26
0
 def test_post_default_form_use_view(self):
     self._create_entity_data("entityuseview")
     self.assertTrue(EntityData.exists(self.testdata, "entityuseview"))
     f = default_view_form_data(
             entity_id="entityuseview", action="view",
             use_view="_view/Type_view", 
             )
     f.pop('entity_id', None)
     u = entitydata_edit_url(
         "view", "testcoll", "testtype", "entityuseview", view_id="Default_view"
         )
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "Found")
     self.assertEqual(r.content,       b"")
     v = entitydata_edit_url(
         "view", "testcoll", "testtype", entity_id="entityuseview", view_id="Type_view"
         )
     c = continuation_url_param("/testsite/c/testcoll/d/testtype/")
     self.assertIn(v, r['location'])
     self.assertIn(c, r['location'])
     self._check_entity_data_values("entityuseview")
     return
コード例 #27
0
 def test_new_entity_new_type(self):
     # Checks logic for creating an entity which may require creation of new recorddata
     # Create new type
     self.assertFalse(RecordType.exists(self.testcoll, "newtype"))
     f = type_view_form_data(
         action="new",
         coll_id="testcoll",
         type_entity_id="newtype",
     )
     u = entitydata_edit_url("new",
                             "testcoll",
                             type_id="_type",
                             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'],
         TestHostUri + entitydata_list_type_url("testcoll", "_type"))
     self.assertTrue(RecordType.exists(self.testcoll, "newtype"))
     # Create new entity
     self.assertFalse(EntityData.exists(self.testdata, "newentity"))
     f = default_view_form_data(entity_id="newentity",
                                type_id="newtype",
                                action="new")
     u = entitydata_edit_url("new", "testcoll", "newtype")
     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'],
         TestHostUri + entitydata_list_type_url("testcoll", "newtype"))
     # Check new entity data created
     self._check_entity_data_values("newentity", type_id="newtype")
     return