def test_put_object_without_existing_object(self): app = ApplicationAPI(self.portal, '') objs = {'news1': [{'description': 'News One', 'title': 'news1', 'text': '\n<p>Hot off the press!</p>\n', 'id': 'news1'}, 'News Item']} self.login('test_user_1_') try: app.put_object(objs) except NotFound: # The expected result. pass except Exception, e: self.fail(e)
def test_put_object(self): resp = Response(FauxResponse()) app = ApplicationAPI(self.portal, '') objs = { 'front-page': [{ 'text': "<p>Action and reaction, ebb and flow, trial and error, change - this is the rhythm of living. Out of our over-confidence, fear; out of our fear, clearer vision, fresh hope. And out of hope, progress.</p><br /> --<i>Bruce Barton</i>" }], '/plone/events': [ { 'description': 'What\'s up doc?' }, ] } self.login('test_user_1_') put_obj_data = app.put_object(objs) self.logout() resp.setBody(put_obj_data) put_obj_resp, method = xmlrpclib.loads(resp._body) expected_resp = ['/plone/front-page', '/plone/events'] self.failUnlessEqual(len(put_obj_resp[0]), len(expected_resp)) for i in put_obj_resp[0]: self.failUnless(i in expected_resp, "'%s' is not in %s?" % (i, expected_resp)) self.failUnlessEqual(self.portal['front-page']['text'].getRaw(), objs['front-page'][0]['text']) self.failUnlessEqual(self.portal['events']['description'], objs['/plone/events'][0]['description'])
def test_put_object_without_existing_object(self): app = ApplicationAPI(self.portal, '') objs = { 'news1': [{ 'description': 'News One', 'title': 'news1', 'text': '\n<p>Hot off the press!</p>\n', 'id': 'news1' }, 'News Item'] } self.login('test_user_1_') try: app.put_object(objs) except NotFound: # The expected result. pass except Exception, e: self.fail(e)
def test_put_object(self): resp = Response(FauxResponse()) app = ApplicationAPI(self.portal, '') objs = {'front-page': [{'text': "<p>Action and reaction, ebb and flow, trial and error, change - this is the rhythm of living. Out of our over-confidence, fear; out of our fear, clearer vision, fresh hope. And out of hope, progress.</p><br /> --<i>Bruce Barton</i>"}], '/plone/events': [{'description': 'What\'s up doc?'},]} self.login('test_user_1_') put_obj_data = app.put_object(objs) self.logout() resp.setBody(put_obj_data) put_obj_resp, method = xmlrpclib.loads(resp._body) expected_resp = ['/plone/front-page', '/plone/events'] self.failUnlessEqual(len(put_obj_resp[0]), len(expected_resp)) for i in put_obj_resp[0]: self.failUnless(i in expected_resp, "'%s' is not in %s?" % (i, expected_resp)) self.failUnlessEqual(self.portal['front-page']['text'].getRaw(), objs['front-page'][0]['text']) self.failUnlessEqual(self.portal['events']['description'], objs['/plone/events'][0]['description'])