Example #1
0
 def get_coll_info(self, coll_id):
     """
     Check collection identifier, and get reference to collection object.
     """
     assert (self.site is not None)
     if not self.http_response:
         if not Collection.exists(self.site, coll_id):
             self.http_response = self.view.error(
                 dict(self.view.error404values(),
                      message=message.COLLECTION_NOT_EXISTS %
                      {'id': coll_id}))
         else:
             self.coll_id = coll_id
             #@@TODO: try with altscope="site"?
             self.collection = Collection.load(self.site,
                                               coll_id,
                                               altscope="all")
             self.coll_perms = self.collection
             ver = self.collection.get(ANNAL.CURIE.software_version,
                                       None) or "0.0.0"
             if LooseVersion(ver) > LooseVersion(annalist.__version__):
                 self.http_response = self.view.error(
                     dict(self.view.error500values(),
                          message=message.COLLECTION_NEWER_VERSION % {
                              'id': coll_id,
                              'ver': ver
                          }))
     return self.http_response
Example #2
0
 def get_coll_info(self, coll_id):
     """
     Check collection identifier, and get reference to collection object.
     """
     assert (self.site is not None)
     if not self.http_response:
         if not Collection.exists(self.site, coll_id):
             self.http_response = self.view.error(
                 dict(self.view.error404values(),
                     message=message.COLLECTION_NOT_EXISTS%{'id': coll_id}
                     )
                 )
         else:
             self.coll_id    = coll_id
             #@@TODO: try with altscope="site"?
             self.collection = Collection.load(self.site, coll_id, altscope="all")
             self.coll_perms = self.collection
             ver = self.collection.get(ANNAL.CURIE.software_version, None) or "0.0.0"
             if LooseVersion(ver) > LooseVersion(annalist.__version__):
                 self.http_response = self.view.error(
                     dict(self.view.error500values(),
                         message=message.COLLECTION_NEWER_VERSION%{'id': coll_id, 'ver': ver}
                         )
                     )
     return self.http_response
 def _check_collection_data_values(self, coll_id=None):
     """
     Helper function checks content of annalist collection data
     """
     self.assertTrue(Collection.exists(self.testsite, coll_id))
     t = Collection.load(self.testsite, coll_id)
     self.assertEqual(t.get_id(), coll_id)
     self.assertEqual(t.get_view_url_path(), collection_view_url(coll_id="testcoll"))
     v = collectiondata_values(coll_id=coll_id)
     self.assertDictionaryMatch(t.get_values(), v)
     return t
Example #4
0
 def _check_collection_data_values(self, coll_id=None):
     """
     Helper function checks content of annalist collection data
     """
     self.assertTrue(Collection.exists(self.testsite, coll_id))
     t = Collection.load(self.testsite, coll_id)
     self.assertEqual(t.get_id(), coll_id)
     self.assertEqual(t.get_view_url_path(),
                      collection_view_url(coll_id="testcoll"))
     v = collectiondata_values(coll_id=coll_id)
     self.assertDictionaryMatch(t.get_values(), v)
     return t
Example #5
0
 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