Esempio n. 1
0
 def test_post_edit_entity_invalid_id(self):
     self._create_entity_data("edittype")
     self._check_entity_data_values("edittype")
     # Form post with ID malformed
     f = default_view_form_data(entity_id="!badentity",
                                orig_id="edittype",
                                action="edit")
     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 = default_view_context_data(
         entity_id="!badentity",
         orig_id="edittype",
         action="edit",
         type_ref="_type/testtype",
         type_choices=self.type_ids,
         record_type="/testsite/c/testcoll/d/_type/testtype/")
     self.assertDictionaryMatch(context_bind_fields(r.context),
                                expect_context)
     # Check stored entity is unchanged
     self._check_entity_data_values("edittype")
     return
Esempio n. 2
0
 def test_get_edit(self):
     u = entitydata_edit_url("edit",
                             "testcoll",
                             "testtype",
                             entity_id="entity1")
     r = self.client.get(u + "?continuation_url=/xyzzy/")
     self.assertEqual(r.status_code, 200)
     self.assertEqual(r.reason_phrase, "OK")
     # log.info(r.content)
     self.assertContains(
         r,
         "<title>Entity testcoll/testtype/entity1 - Default record view - Collection testcoll</title>"
     )
     # Test context
     expect_context = default_view_context_data(
         coll_id="testcoll",
         type_id="testtype",
         entity_id="entity1",
         type_ref="testtype",
         type_choices=self.type_ids,
         entity_label="Entity testcoll/testtype/entity1",
         entity_descr="Entity coll testcoll, type testtype, entity entity1",
         action="edit",
         update="Entity",
         continuation_url="/xyzzy/")
     self.assertEqual(len(r.context['fields']), 3)  # 4 fields over 3 rows
     self.assertDictionaryMatch(context_bind_fields(r.context),
                                expect_context)
     return
Esempio n. 3
0
 def test_post_copy_entity_missing_id(self):
     f = default_view_form_data(action="copy",
                                entity_id="",
                                orig_id="entity1")
     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 = default_view_context_data(action="copy",
                                                orig_id="entity1",
                                                type_ref="",
                                                type_choices=self.type_ids)
     self.assertDictionaryMatch(context_bind_fields(r.context),
                                expect_context)
     return
Esempio n. 4
0
 def test_post_new_entity_missing_id(self):
     f = default_view_form_data(action="new", entity_id="")
     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 = default_view_context_data(coll_id="testcoll",
                                                type_id="testtype",
                                                entity_id="",
                                                orig_id="orig_entity_id",
                                                type_ref="",
                                                type_choices=self.type_ids,
                                                action="new")
     self.assertEqual(len(r.context['fields']), 3)  # 4 fields over 3 rows
     self.assertDictionaryMatch(context_bind_fields(r.context),
                                expect_context)
     return
Esempio n. 5
0
 def test_get_new(self):
     u = entitydata_edit_url("new", "testcoll", "testtype")
     r = self.client.get(u + "?continuation_url=/xyzzy/")
     self.assertEqual(r.status_code, 200)
     self.assertEqual(r.reason_phrase, "OK")
     # Test context
     expect_context = default_view_context_data(coll_id="testcoll",
                                                type_id="testtype",
                                                entity_id="00000001",
                                                orig_id=None,
                                                type_ref="testtype",
                                                type_choices=self.type_ids,
                                                entity_label="",
                                                entity_descr="",
                                                action="new",
                                                update="Entity",
                                                continuation_url="/xyzzy/")
     self.assertEqual(len(r.context['fields']), 3)  # 4 fields over 3 rows
     self.assertDictionaryMatch(context_bind_fields(r.context),
                                expect_context)
     return