def test_dup_field_update(self):
     # Create entity with duplicate fields
     self._create_entity_data("entitydupfield")
     self._check_entity_data_values(
         "entitydupfield", type_id="testtype", update="Entity", 
         comment2="Comment field 2",
         comment3="Comment field 3"
         )
     # Post form data to update entity
     u = entitydata_edit_url(
         "edit", "testcoll", "testtype", 
         entity_id="entitydupfield",
         view_id="DupField_view"
         )
     f = entitydata_form_data(
         entity_id="entitydupfield",
         type_id="testtype",
         coll_id="testcoll", 
         action="edit", update="Updated Entity"
         )
     f = entitydata_form_add_field(f, "Entity_comment", 2, "Update comment 2")
     f = entitydata_form_add_field(f, "Entity_comment", 3, "Update comment 3")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "FOUND")
     # Test resulting entity value
     self._check_entity_data_values(
         "entitydupfield", type_id="testtype", update="Updated Entity", 
         comment2="Update comment 2",
         comment3="Update comment 3"
         )
     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
 def test_dup_field_update(self):
     # Create entity with duplicate fields
     self._create_entity_data("entitydupfield")
     self._check_entity_data_values("entitydupfield",
                                    type_id="testtype",
                                    update="Entity",
                                    comment2="Comment field 2",
                                    comment3="Comment field 3")
     # Post form data to update entity
     u = entitydata_edit_url("edit",
                             "testcoll",
                             "testtype",
                             entity_id="entitydupfield",
                             view_id="DupField_view")
     f = entitydata_form_data(entity_id="entitydupfield",
                              type_id="testtype",
                              coll_id="testcoll",
                              action="edit",
                              update="Updated Entity")
     f = entitydata_form_add_field(f, "Entity_comment", 2,
                                   "Update comment 2")
     f = entitydata_form_add_field(f, "Entity_comment", 3,
                                   "Update comment 3")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code, 302)
     self.assertEqual(r.reason_phrase, "FOUND")
     # Test resulting entity value
     self._check_entity_data_values("entitydupfield",
                                    type_id="testtype",
                                    update="Updated Entity",
                                    comment2="Update comment 2",
                                    comment3="Update comment 3")
     return
 def test_post_new_entity_missing_id(self):
     f = entitydata_form_data(action="new")
     u = entitydata_edit_url("new", "testcoll", "testtype")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code, 200)
     self.assertEqual(r.reason_phrase, "OK")
     self.assertContains(r, "<h3>Problem with entity identifier</h3>")
     # Test context
     expect_context = entitydata_context_data(action="new")
     self.assertDictionaryMatch(r.context, expect_context)
     return
 def new_data(self):
     # requires CREATE
     u = entitydata_edit_url(action="new",
                             coll_id="testcoll",
                             type_id="Default_type",
                             view_id="Default_view")
     f = entitydata_form_data(action="new",
                              coll_id="testcoll",
                              type_id="Default_type",
                              entity_id="new_entity")
     r = self.client.post(u, f)
     return r
示例#6
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
 def edit_data(self):
     # requires UPDATE
     e = self.create_data("edit_entity")
     u = entitydata_edit_url(action="edit",
                             coll_id="testcoll",
                             type_id="Default_type",
                             entity_id="edit_entity",
                             view_id="Default_view")
     f = entitydata_form_data(action="edit",
                              coll_id="testcoll",
                              type_id="Default_type",
                              entity_id="edit_entity")
     r = self.client.post(u, f)
     # log.info("r %s"%r)
     return r
示例#8
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
 def test_post_copy_entity_invalid_id(self):
     f = entitydata_form_data(entity_id="!badentity",
                              orig_id="orig_entity_id",
                              action="copy")
     u = entitydata_edit_url("copy",
                             "testcoll",
                             "testtype",
                             entity_id="entity1")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code, 200)
     self.assertEqual(r.reason_phrase, "OK")
     self.assertContains(r, "<h3>Problem with entity identifier</h3>")
     expect_context = entitydata_context_data(entity_id="!badentity",
                                              orig_id="orig_entity_id",
                                              action="copy")
     self.assertDictionaryMatch(r.context, expect_context)
     return
 def test_post_new_entity_invalid_id(self):
     f = entitydata_form_data(entity_id="!badentity",
                              orig_id="orig_entity_id",
                              action="new")
     u = entitydata_edit_url("new", "testcoll", "testtype")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code, 200)
     self.assertEqual(r.reason_phrase, "OK")
     self.assertContains(r, "<h3>Problem with entity identifier</h3>")
     # Test context
     expect_context = entitydata_context_data(entity_id="!badentity",
                                              orig_id="orig_entity_id",
                                              action="new")
     # log.info(repr(f))
     # log.info(repr(r.context['fields'][1]))
     self.assertDictionaryMatch(r.context, expect_context)
     return
示例#11
0
 def test_post_edit_entity(self):
     self._create_entity_data("entityedit")
     self._check_entity_data_values("entityedit")
     f = entitydata_form_data(entity_id="entityedit",
                              action="edit",
                              update="Updated entity")
     u = entitydata_edit_url("edit",
                             "testcoll",
                             "testtype",
                             entity_id="entityedit")
     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"))
     self._check_entity_data_values("entityedit", update="Updated entity")
     return
 def test_post_edit_entity_missing_id(self):
     self._create_entity_data("edittype")
     self._check_entity_data_values("edittype")
     # Form post with ID missing
     f = entitydata_form_data(action="edit", update="Updated entity")
     u = entitydata_edit_url("edit",
                             "testcoll",
                             "testtype",
                             entity_id="edittype")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code, 200)
     self.assertEqual(r.reason_phrase, "OK")
     self.assertContains(r, "<h3>Problem with entity identifier</h3>")
     # Test context for re-rendered form
     expect_context = entitydata_context_data(action="edit",
                                              update="Updated entity")
     self.assertDictionaryMatch(r.context, expect_context)
     # Check stored entity is unchanged
     self._check_entity_data_values("edittype")
     return
 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
示例#14
0
 def test_post_edit_entity_cancel(self):
     self._create_entity_data("edittype")
     self._check_entity_data_values("edittype")
     # Post from cancelled edit form
     f = entitydata_form_data(entity_id="edittype",
                              action="edit",
                              cancel="Cancel",
                              update="Updated entity")
     u = entitydata_edit_url("edit",
                             "testcoll",
                             "testtype",
                             entity_id="edittype")
     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 target record type still does not exist and unchanged
     self._check_entity_data_values("edittype")
     return
示例#15
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
示例#16
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 = entitydata_recordtype_view_form_data(coll_id="testcoll",
                                              type_id="_type",
                                              entity_id="newtype",
                                              action="new")
     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 = entitydata_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