コード例 #1
0
 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
コード例 #2
0
 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
コード例 #3
0
 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
コード例 #4
0
 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