def test_post_named_edit(self): u = collectiondata_view_url(coll_id="testcoll", action="edit") f = coll_view_form_data(coll_id="testcoll", action="edit") 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'], TestBaseUri+"/c/_annalist_site/d/_coll/") # Check updated collection data self._check_collection_data_values(coll_id="testcoll") return
def test_post_named_edit(self): u = collectiondata_view_url(coll_id="testcoll", action="edit") f = collectiondata_view_form_data(coll_id="testcoll", action="edit") 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'], TestBaseUri+"/c/_annalist_site/d/_coll/") # Check updated collection data self._check_collection_data_values(coll_id="testcoll") return
def test_post_metadata(self): form_data = ( { "metadata": "Collection metadata" }) r = self.client.post(self.edit_url, form_data) self.assertEqual(r.status_code, 302) self.assertEqual(r.reason_phrase, "FOUND") self.assertEqual(r.content, "") metadataurl = collectiondata_view_url(coll_id="coll1", action="edit") self.assertEqual(r['location'], TestHostUri+metadataurl+self.continuation) return
def test_get_named_edit(self): u = collectiondata_view_url(coll_id="testcoll", action="edit") r = self.client.get(u) self.assertEqual(r.status_code, 200) self.assertEqual(r.reason_phrase, "OK") self.assertEqual(r.context['coll_id'], "_annalist_site") self.assertEqual(r.context['type_id'], "_coll") self.assertEqual(r.context['entity_id'], "testcoll") self.assertEqual(r.context['orig_id'], "testcoll") self.assertEqual(r.context['action'], "edit") self.assertEqual(r.context['continuation_url'], "") return
def test_get_named_view(self): u = collectiondata_view_url(coll_id="testcoll", action="view") r = self.client.get(u) self.assertEqual(r.status_code, 200) self.assertEqual(r.reason_phrase, "OK") self.assertEqual(r.context['coll_id'], layout.SITEDATA_ID) self.assertEqual(r.context['type_id'], layout.COLL_TYPEID) self.assertEqual(r.context['entity_id'], "testcoll") self.assertEqual(r.context['orig_id'], "testcoll") self.assertEqual(r.context['action'], "view") self.assertEqual(r.context['continuation_url'], "") return
def test_edit_collection_metadata(self): # This test performs a GET to retrieve values used in a form, # then a POST to save updated collection metadata. # This test is intended to test a problem encountered with updated # entity copying logic that needs to take special account of collection # entities being presented as offspring of the site while being stored # as part of a collection. # coll_id = "testcoll" self.assertTrue(Collection.exists(self.testsite, coll_id)) c = Collection.load(self.testsite, coll_id) self.assertEqual(c.get_id(), coll_id) self.assertEqual(c.get_view_url_path(), collection_view_url(coll_id="testcoll")) # GET collection metadata form data, and test values u = collectiondata_url(coll_id="testcoll") r = self.client.get(u) self.assertEqual(r.status_code, 200) self.assertEqual(r.reason_phrase, "OK") self.assertEqual(r.context['coll_id'], layout.SITEDATA_ID) self.assertEqual(r.context['type_id'], layout.COLL_TYPEID) self.assertEqual(r.context['entity_id'], "testcoll") self.assertEqual(r.context['orig_id'], "testcoll") self.assertEqual(r.context['orig_coll'], layout.SITEDATA_ID) self.assertEqual(r.context['action'], "view") self.assertEqual(r.context['continuation_url'], "") orig_coll = r.context['orig_coll'] # Assemble and POST form data to =updated collection metadata new_label = "Updated collection metadata" f = coll_view_form_data( coll_id="testcoll", action="edit", coll_label=new_label, # orig_coll="None" orig_coll=layout.SITEDATA_ID ) u = collectiondata_view_url(coll_id="testcoll", action="edit") 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'], TestBaseUri+"/c/_annalist_site/d/_coll/") # Check updated collection data self._check_collection_data_values(coll_id="testcoll", coll_label=new_label) return