def test_raises_when_both_context_and_inbox_are_missing(self): with self.assertRaises(ValueError) as cm: get_current_yearfolder() self.assertEquals( 'Context or the current inbox itself must be given.', str(cm.exception))
def test_returns_yearfolder_of_the_current_year(self): yearfolder = create(Builder('yearfolder') .within(self.client1_inbox) .having(id=self.current_year)) self.assertEquals(self.current_year, yearfolder.getId()) self.assertEquals(yearfolder, get_current_yearfolder(inbox=self.client1_inbox))
def store_in_yearfolder(self): """Move the forwarding (adapted context) in the actual yearfolder.""" inbox = aq_parent(aq_inner(self.context)) yearfolder = get_current_yearfolder(inbox=inbox) self.context.REQUEST.set(DISABLE_DOCPROPERTY_UPDATE_FLAG, True) with elevated_privileges(): clipboard = inbox.manage_cutObjects((self.context.getId(),)) yearfolder.manage_pasteObjects(clipboard)
def test_observe_current_inbox_when_context_is_given(self): client1_yearfolder = create(Builder('yearfolder') .within(self.client1_inbox) .having(id=self.current_year)) create(Builder('yearfolder') .within(self.client2_inbox) .having(id=self.current_year)) self.assertEquals(client1_yearfolder, get_current_yearfolder(context=self.portal))
def get_yearfolder(self): if not self.yearfolder: self.yearfolder = get_current_yearfolder(context=self.context) return self.yearfolder
def test_creates_yearfolder_of_the_current_year_when_not_exists(self): yearfolder = get_current_yearfolder(inbox=self.client1_inbox) self.assertEquals(self.current_year, yearfolder.getId()) self.assertEquals('Closed {}'.format(self.current_year), yearfolder.Title())