def test_creating_and_extraction(self): class DummyResponse(object): def getStatus(self): return 200 class DummyRequest(dict): def __init__(self): self.response = DummyResponse() remote_task = self.providing_stub( [ITask, IAttributeAnnotatable]) request = DummyRequest() context = self.providing_stub( [ITask, IAttributeAnnotatable]) self.replay() response = Response(u'Sample text') response.creator = u'hugo.boss' response.date = DateTime("02.07.2010") response.add_change( 'review_state', 'State', 'before-state', 'after-state') response.add_change( 'responsible', 'Responsible', 'hugo.boss', 'james.bond') container = IResponseContainer(remote_task) container.add(response) # extract request.intids_mapping = {} data = ExtractResponses(remote_task, request)() # receive request['responses'] = data ReceiveResponses(context, request)() # check if the response is correctly synced self.assertTrue(len(IResponseContainer(context)) == 1) synced_response = IResponseContainer(context)[0] self.assertEquals(synced_response.text, response.text) self.assertEquals(synced_response.creator, response.creator) self.assertEquals(synced_response.date, response.date) # changes self.assertEquals( synced_response.changes, [ {u'after': u'after-state', u'id': u'review_state', u'name': u'State', u'before': u'before-state'}, {u'after': u'james.bond', u'id': u'responsible', u'name': u'Responsible', u'before': u'hugo.boss'}])
def test_migrates_plone_task_response_creator(self): task = create(Builder('task')) response = Response('') response.creator = 'HANS.MUSTER' IResponseContainer(task).add(response) PloneTasksMigrator(self.portal, { 'HANS.MUSTER': 'hans.muster' }, 'move').migrate() self.assertEquals('hans.muster', response.creator)
def test_creating_and_extraction(self): class DummyResponse(object): def getStatus(self): return 200 class DummyRequest(dict): def __init__(self): self.response = DummyResponse() remote_task = self.providing_stub([ITask, IAttributeAnnotatable]) request = DummyRequest() context = self.providing_stub([ITask, IAttributeAnnotatable]) self.replay() response = Response(u'Sample text') response.creator = u'hugo.boss' response.date = DateTime("02.07.2010") response.add_change('review_state', 'State', 'before-state', 'after-state') response.add_change('responsible', 'Responsible', 'hugo.boss', 'james.bond') container = IResponseContainer(remote_task) container.add(response) # extract request.intids_mapping = {} data = ExtractResponses(remote_task, request)() # receive request['responses'] = data ReceiveResponses(context, request)() # check if the response is correctly synced self.assertTrue(len(IResponseContainer(context)) == 1) synced_response = IResponseContainer(context)[0] self.assertEquals(synced_response.text, response.text) self.assertEquals(synced_response.creator, response.creator) self.assertEquals(synced_response.date, response.date) # changes self.assertEquals(synced_response.changes, [{ u'after': u'after-state', u'id': u'review_state', u'name': u'State', u'before': u'before-state' }, { u'after': u'james.bond', u'id': u'responsible', u'name': u'Responsible', u'before': u'hugo.boss' }])