def test_post_delete_all_entity(self): f = entitylist_form_data("delete", entities=["testtype/entity1"]) u = entitydata_list_all_url("testcoll") r = self.client.post(u, f) self.assertEqual(r.status_code, 200) self.assertEqual(r.reason_phrase, "OK") self.assertContains(r, "<h3>%s</h3>"%message.CONFIRM_REQUESTED_ACTION) # print "**********" # print r.content # print "**********" msg_text = make_message(message.REMOVE_ENTITY_DATA, type_id="testtype", id="entity1" ) self.assertContains(r, msg_text + ": " + message.ARE_YOU_SURE) self.assertContains(r, message.CONFIRM_OR_CANCEL) self.assertContains(r, '<input type="hidden" name="confirmed_action" value="/testsite/c/testcoll/d/testtype/!delete_confirmed"/>', html=True ) self.assertEqual(r.context['action_description'], msg_text) self.assertEqual(r.context['confirmed_action'], '/testsite/c/testcoll/d/testtype/!delete_confirmed') self.assertEqual(r.context['action_params'], confirm_delete_params(button_id="entity_delete", entity_id="entity1", type_id=None) ) self.assertEqual(r.context['cancel_action'], '/testsite/c/testcoll/d/') return
def test_get_view_no_view(self): u = entitydata_edit_url("edit", "testcoll", "testtype", entity_id="entity1", view_id="no_view") with SuppressLogging(logging.WARNING): r = self.client.get(u) self.assertEqual(r.status_code, 200) self.assertEqual(r.reason_phrase, "OK") msg_text = make_message(message.RECORD_VIEW_NOT_EXISTS, id="no_view") self.assertContains(r, msg_text) return
def test_get_view_no_type(self): u = entitydata_edit_url("edit", "testcoll", "no_type", entity_id="entity1", view_id="Type_view") with SuppressLogging(logging.WARNING): r = self.client.get(u) self.assertEqual(r.status_code, 404) self.assertEqual(r.reason_phrase, "Not found") msg_text = make_message(message.RECORD_TYPE_NOT_EXISTS, id="no_type") self.assertContains(r, msg_text, status_code=404) return
def test_get_view_no_collection(self): u = entitydata_edit_url("view", "no_collection", "testtype", entity_id="entity1", view_id="Type_view") r = self.client.get(u) self.assertEqual(r.status_code, 404) self.assertEqual(r.reason_phrase, "Not found") msg_text = make_message(message.COLLECTION_NOT_EXISTS, id="no_collection") self.assertContains(r, msg_text, status_code=404) return
def test_get_edit_not_exists(self): u = entitydata_edit_url("edit", "testcoll", "testtype", entity_id="entitynone") r = self.client.get(u + "?continuation_url=/xyzzy/") self.assertEqual(r.status_code, 404) self.assertEqual(r.reason_phrase, "Not found") self.assertContains(r, "<title>Annalist error</title>", status_code=404) self.assertContains(r, "<h3>404: Not found</h3>", status_code=404) # log.debug(r.content) err_label = error_label("testcoll", "testtype", "entitynone") msg_text = make_message(message.ENTITY_DOES_NOT_EXIST, id="entitynone", label=err_label) self.assertContains(r, "<p>%s</p>" % msg_text, status_code=404) return
def test_get_edit_not_exists(self): u = entitydata_edit_url("edit", "testcoll", layout.VOCAB_TYPEID, entity_id="novocab", view_id="Vocab_view") r = self.client.get(u) # log.info(r.content) self.assertEqual(r.status_code, 404) self.assertEqual(r.reason_phrase, "Not found") self.assertContains(r, "<title>Annalist error</title>", status_code=404) self.assertContains(r, "<h3>404: Not found</h3>", status_code=404) err_label = error_label("testcoll", layout.VOCAB_TYPEID, "novocab") msg_text = make_message(message.ENTITY_DOES_NOT_EXIST, id="novocab", type_id=layout.VOCAB_TYPEID, label=err_label) self.assertContains(r, "<p>%s</p>" % msg_text, status_code=404) return