Пример #1
0
 def test_get_object_without_existing_object(self):
     app = ApplicationAPI(self.portal, '')
     objs = ['news1']
     self.logout()
     try:
         app.get_object(objs)
     except NotFound:
         # The expected result.
         pass
     except Exception, e:
         self.fail(e)
Пример #2
0
 def test_get_object_without_existing_object(self):
     app = ApplicationAPI(self.portal, '')
     objs = ['news1']
     self.logout()
     try:
         app.get_object(objs)
     except NotFound:
         # The expected result.
         pass
     except Exception, e:
         self.fail(e)
Пример #3
0
 def test_anonymous_private_get_object(self):
     app = ApplicationAPI(self.portal, '')
     fp = self.portal['front-page']
     portal_workflow = getToolByName(self.portal, 'portal_workflow')
     self.loginAsPortalOwner()
     portal_workflow.doActionFor(fp, 'retract')
     self.logout()
     try:
         app.get_object(['/'.join(fp.getPhysicalPath()), ''])
     except Unauthorized:
         # The expected result.
         pass
     except Exception, e:
         self.fail(e)
Пример #4
0
 def test_anonymous_private_get_object(self):
     app = ApplicationAPI(self.portal, '')
     fp = self.portal['front-page']
     portal_workflow = getToolByName(self.portal, 'portal_workflow')
     self.loginAsPortalOwner()
     portal_workflow.doActionFor(fp, 'retract')
     self.logout()
     try:
         app.get_object(['/'.join(fp.getPhysicalPath()), ''])
     except Unauthorized:
         # The expected result.
         pass
     except Exception, e:
         self.fail(e)
Пример #5
0
 def __call__(self, REQUEST, RESPONSE):
     '''Returns a JSON representation of the current object'''
     wsapi = ApplicationAPI(self.context, self.request)
     results = wsapi.get_object()
     # One result is a tuple (object_data, object_type, extra_info)
     # We're interested only in object_data
     result = results.values()[0][0]
     self._sanitize_results(result)
     RESPONSE.setHeader('Content-Type', 'application/json')
     return json.dumps(result)
Пример #6
0
 def test_anonymous_get_object(self):
     resp = Response(FauxResponse())
     app = ApplicationAPI(self.portal, '')
     get_obj_data = app.get_object(['/'.join(self.folder.getPhysicalPath()), ''])
     resp.setBody(get_obj_data)
     get_obj_resp, method = xmlrpclib.loads(resp._body)
     get_obj_results = get_obj_resp[0]
     for path in get_obj_results:
         self.failUnless(type(get_obj_results[path][0]) == dict)
         self.failUnless(type(get_obj_results[path][1]) == str)
         self.failUnless(type(get_obj_results[path][2]) == dict or get_obj_results[path][2] == None)
Пример #7
0
 def test_anonymous_get_object(self):
     resp = Response(FauxResponse())
     app = ApplicationAPI(self.portal, '')
     get_obj_data = app.get_object(
         ['/'.join(self.folder.getPhysicalPath()), ''])
     resp.setBody(get_obj_data)
     get_obj_resp, method = xmlrpclib.loads(resp._body)
     get_obj_results = get_obj_resp[0]
     for path in get_obj_results:
         self.failUnless(type(get_obj_results[path][0]) == dict)
         self.failUnless(type(get_obj_results[path][1]) == str)
         self.failUnless(
             type(get_obj_results[path][2]) == dict
             or get_obj_results[path][2] == None)