def test_getCurrentDraft_draft_details_set_not_in_storage_create(self): request = self.request management = ICurrentDraftManagement(request) management.userId = u'user1' management.targetKey = u'123' management.draftName = u'bogus' draft = getCurrentDraft(request, create=True) inStorage = getUtility(IDraftStorage).getDraft( u'user1', u'123', draft.__name__) self.assertEqual(inStorage, draft) response = request.response self.assertTrue('plone.app.drafts.targetKey' in response.cookies) self.assertTrue('plone.app.drafts.draftName' in response.cookies) self.assertEqual( '123', response.cookies['plone.app.drafts.targetKey']['value'], ) self.assertEqual( draft.__name__, response.cookies['plone.app.drafts.draftName']['value'], )
def test_userId(self): request = self.request current = ICurrentDraftManagement(request) self.assertEquals(TEST_USER_ID, current.userId) current.userId = u"third-user" self.assertEquals(u"third-user", current.userId)
def test_userId(self): request = self.request current = ICurrentDraftManagement(request) self.assertEqual(TEST_USER_ID, current.userId) current.userId = u'third-user' self.assertEqual(u'third-user', current.userId)
def test_userId(self): request = self.app.REQUEST current = ICurrentDraftManagement(request) self.assertEquals(ptc.default_user, current.userId) current.userId = u"third-user" self.assertEquals(u"third-user", current.userId)
def test_getCurrentDraft_draft_details_set_not_in_storage(self): request = self.request management = ICurrentDraftManagement(request) management.userId = u"user1" management.targetKey = u"123" management.draftName = u"bogus" draft = getCurrentDraft(request) self.assertEquals(None, draft) response = request.response self.failIf('plone.app.drafts.targetKey' in response.cookies) self.failIf('plone.app.drafts.draftName' in response.cookies)
def test_getCurrentDraft_draft_details_set_not_in_storage(self): request = self.request management = ICurrentDraftManagement(request) management.userId = u'user1' management.targetKey = u'123' management.draftName = u'bogus' draft = getCurrentDraft(request) self.assertEqual(None, draft) response = request.response self.assertFalse('plone.app.drafts.targetKey' in response.cookies) self.assertFalse('plone.app.drafts.draftName' in response.cookies)
def test_getCurrentDraft_draft_details_set_in_storage_create(self): request = self.request inStorage = getUtility(IDraftStorage).createDraft(u"user1", u"123") management = ICurrentDraftManagement(request) management.userId = u"user1" management.targetKey = u"123" management.draftName = inStorage.__name__ draft = getCurrentDraft(request, create=True) self.assertEquals(inStorage, draft) response = request.response self.failIf('plone.app.drafts.targetKey' in response.cookies) self.failIf('plone.app.drafts.draftName' in response.cookies)
def test_getCurrentDraft_draft_details_set_in_storage_create(self): request = self.request inStorage = getUtility(IDraftStorage).createDraft(u'user1', u'123') management = ICurrentDraftManagement(request) management.userId = u'user1' management.targetKey = u'123' management.draftName = inStorage.__name__ draft = getCurrentDraft(request, create=True) self.assertEqual(inStorage, draft) response = request.response self.assertFalse('plone.app.drafts.targetKey' in response.cookies) self.assertFalse('plone.app.drafts.draftName' in response.cookies)
def test_getCurrentDraft_draft_details_set_in_storage(self): request = self.request inStorage = getUtility(IDraftStorage).createDraft(u'user1', u'123') management = ICurrentDraftManagement(request) management.userId = u'user1' management.targetKey = u'123' management.draftName = inStorage.__name__ draft = getCurrentDraft(request) self.assertEqual(inStorage, draft) response = request.response self.assertFalse('plone.app.drafts.targetKey' in response.cookies) self.assertFalse('plone.app.drafts.draftName' in response.cookies)
def test_getCurrentDraft_draft_details_set_not_in_storage_create(self): request = self.request management = ICurrentDraftManagement(request) management.userId = u"user1" management.targetKey = u"123" management.draftName = u"bogus" draft = getCurrentDraft(request, create=True) inStorage = getUtility(IDraftStorage).getDraft(u"user1", u"123", draft.__name__) self.assertEquals(inStorage, draft) response = request.response self.failUnless('plone.app.drafts.targetKey' in response.cookies) self.failUnless('plone.app.drafts.draftName' in response.cookies) self.assertEquals('123', response.cookies['plone.app.drafts.targetKey']['value']) self.assertEquals(draft.__name__, response.cookies['plone.app.drafts.draftName']['value'])
def test_draft(self): request = self.request current = ICurrentDraftManagement(request) self.assertEquals(None, current.draft) current.userId = u"user1" current.targetKey = u"123" current.draftName = u"draft" self.assertEquals(None, current.draft) storage = getUtility(IDraftStorage) created = storage.createDraft(u"user1", u"123") current.draftName = created.__name__ self.assertEquals(created, current.draft) newDraft = storage.createDraft(u"user1", u"123") current.draft = newDraft self.assertEquals(newDraft, current.draft)
def test_draft(self): request = self.request current = ICurrentDraftManagement(request) self.assertEqual(None, current.draft) current.userId = u'user1' current.targetKey = u'123' current.draftName = u'draft' self.assertEqual(None, current.draft) storage = getUtility(IDraftStorage) created = storage.createDraft(u'user1', u'123') current.draftName = created.__name__ self.assertEqual(created, current.draft) newDraft = storage.createDraft(u'user1', u'123') current.draft = newDraft self.assertEqual(newDraft, current.draft)
def _get_adapted_request(self): # returns the adapted request for the draft stuff adapted_request = ICurrentDraftManagement(self.request, None) adapted_request.userId = getCurrentUserId() adapted_request.targetKey = getDefaultKey(self.context) return adapted_request