Ejemplo n.º 1
0
 def test_post_new_list_cancel(self):
     self.assertFalse(RecordList.exists(self.testcoll, "newlist"))
     f = recordlist_view_form_data(list_id="newlist",
                                   action="new",
                                   cancel="Cancel",
                                   update="Updated RecordList")
     u = entitydata_edit_url("new",
                             "testcoll",
                             "_list",
                             view_id="List_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'], self.continuation_url)
     # Check that new record type still does not exist
     self.assertFalse(RecordList.exists(self.testcoll, "newview"))
     return
Ejemplo n.º 2
0
 def test_post_confirmed_remove_view(self):
     t = RecordList.create(self.testcoll, "deleteview",
                           recordlist_create_values("deleteview"))
     self.assertTrue(RecordList.exists(self.testcoll, "deleteview"))
     # Submit positive confirmation
     u = TestHostUri + recordlist_edit_url("delete", "testcoll")
     f = recordlist_delete_confirm_form_data("deleteview")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code, 302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content, "")
     self.assertMatch(
         r['location'],
         "^" + TestHostUri + collection_edit_url("testcoll") +
         r"\?info_head=.*&info_message=.*deleteview.*testcoll.*$")
     # Confirm deletion
     self.assertFalse(RecordList.exists(self.testcoll, "deleteview"))
     return
Ejemplo n.º 3
0
 def get_default_list(self):
     """
     Return the default list to be displayed for the current collection.
     """
     list_id = self.get(ANNAL.CURIE.default_list, None)
     if list_id and not RecordList.exists(
             self, list_id, altparent=self._parentsite):
         log.warning("Default list %s for collection %s does not exist" %
                     (list_id, self.get_id()))
         list_id = None
     return list_id
Ejemplo n.º 4
0
 def test_post_copy_view_cancel(self):
     self.assertFalse(RecordList.exists(self.testcoll, "copylist"))
     f = recordlist_view_form_data(list_id="copylist",
                                   orig_id="Default_list",
                                   action="copy",
                                   cancel="Cancel",
                                   update="RecordList")
     u = entitydata_edit_url("copy",
                             "testcoll",
                             "_list",
                             entity_id="Default_list",
                             view_id="List_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'], self.continuation_url)
     # Check that target record view still does not exist
     self.assertFalse(RecordList.exists(self.testcoll, "copylist"))
     return
Ejemplo n.º 5
0
 def get_default_list(self):
     """
     Return the default list to be displayed for the current collection.
     """
     list_id = self.get(ANNAL.CURIE.default_list, None)
     if list_id and not RecordList.exists(self, list_id, altscope="all"):
         log.warning(
             "Default list %s for collection %s does not exist"%
             (list_id, self.get_id())
             )
         list_id = None
     return list_id 
Ejemplo n.º 6
0
 def _check_list_view_values(self,
                             list_id,
                             list_uri=None,
                             update="RecordList",
                             num_fields=4):
     "Helper function checks content of record view entry with supplied list_id"
     self.assertTrue(RecordList.exists(self.testcoll, list_id))
     t = RecordList.load(self.testcoll, list_id)
     self.assertEqual(t.get_id(), list_id)
     self.assertEqual(t.get_view_url(),
                      TestHostUri + recordlist_url("testcoll", list_id))
     v = recordlist_values(list_id=list_id,
                           list_uri=list_uri,
                           update=update)
     if num_fields == 0:
         v['annal:list_fields'] = []
     # log.info("RecordList.load values: %r"%(t.get_values(),))
     self.assertDictionaryMatch(t.get_values(), v)
     return t
Ejemplo n.º 7
0
 def get_list_info(self, list_id):
     """
     Retrieve list definition to use for display
     """
     if not self.http_response:
         assert ((self.site and self.collection) is not None)
         assert list_id
         # log.debug(
         #     "DisplayInfo.get_list_info: collection.get_alt_entities %r"%
         #     [ c.get_id() for c in  self.collection.get_alt_entities(altscope="all") ]
         #     )
         if not RecordList.exists(self.collection, list_id, altscope="all"):
             log.warning(
                 "DisplayInfo.get_list_info: RecordList %s not found" %
                 list_id)
             self.http_response = self.view.error(
                 dict(self.view.error404values(),
                      message=message.RECORD_LIST_NOT_EXISTS %
                      ({
                          'id': list_id,
                          'coll_id': self.coll_id
                      })))
         else:
             self.list_id = list_id
             self.recordlist = RecordList.load(self.collection,
                                               list_id,
                                               altscope="all")
             if "@error" in self.recordlist:
                 self.http_response = self.view.error(
                     dict(self.view.error500values(),
                          message=message.RECORD_LIST_LOAD_ERROR %
                          ({
                              'id': list_id,
                              'file': self.recordlist["@error"],
                              'message': self.recordlist["@message"]
                          })))
             elif self.type_id is None and self.entitytypeinfo is None:
                 self.get_type_info(
                     extract_entity_id(
                         self.recordlist[ANNAL.CURIE.default_type]))
             # log.debug("DisplayInfo.get_list_info: %r"%(self.recordlist.get_values()))
     return self.http_response
Ejemplo n.º 8
0
 def test_post_new_list(self):
     self.assertFalse(RecordList.exists(self.testcoll, "newlist"))
     f = recordlist_view_form_data(list_id="newlist",
                                   action="new",
                                   update="New List")
     u = entitydata_edit_url("new",
                             "testcoll",
                             "_list",
                             view_id="List_view")
     r = self.client.post(u, f)
     # print r.content
     self.assertEqual(r.status_code, 302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content, "")
     self.assertEqual(r['location'], self.continuation_url)
     # Check that new record type exists
     self._check_list_view_values("newlist",
                                  update="New List",
                                  num_fields=0)
     return
Ejemplo n.º 9
0
 def test_post_edit_view_new_id(self):
     self._create_list_view("editlist1")
     self._check_list_view_values("editlist1")
     f = recordlist_view_form_data(list_id="editlist2",
                                   orig_id="editlist1",
                                   action="edit",
                                   update="Updated RecordList")
     u = entitydata_edit_url("edit",
                             "testcoll",
                             "_list",
                             entity_id="editlist1",
                             view_id="List_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'], self.continuation_url)
     # Check that new record list exists and old does not
     self.assertFalse(RecordList.exists(self.testcoll, "editlist1"))
     self._check_list_view_values("editlist2", update="Updated RecordList")
     return
Ejemplo n.º 10
0
 def get_list_info(self, list_id):
     """
     Retrieve list definition to use for display
     """
     if not self.http_response:
         assert ((self.site and self.collection) is not None)
         assert list_id
         # log.debug(
         #     "DisplayInfo.get_list_info: collection.get_alt_entities %r"%
         #     [ c.get_id() for c in  self.collection.get_alt_entities(altscope="all") ]
         #     )
         if not RecordList.exists(self.collection, list_id, altscope="all"):
             log.warning("DisplayInfo.get_list_info: RecordList %s not found"%list_id)
             self.http_response = self.view.error(
                 dict(self.view.error404values(),
                     message=message.RECORD_LIST_NOT_EXISTS%(
                         {'id': list_id, 'coll_id': self.coll_id})
                     )
                 )
         else:
             self.list_id    = list_id
             self.recordlist = RecordList.load(self.collection, list_id, altscope="all")
             if "@error" in self.recordlist:
                 self.http_response = self.view.error(
                     dict(self.view.error500values(),
                         message=message.RECORD_LIST_LOAD_ERROR%(
                             { 'id':       list_id
                             , 'file':     self.recordlist["@error"]
                             , 'message':  self.recordlist["@message"]
                             })
                         )
                     )
             elif self.type_id is None and self.entitytypeinfo is None:
                 self.get_type_info(
                     extract_entity_id(self.recordlist[ANNAL.CURIE.default_type])
                     )
             # log.debug("DisplayInfo.get_list_info: %r"%(self.recordlist.get_values()))
     return self.http_response