def test_added_dossiers(self, browser): self.login(self.records_manager, browser=browser) self.set_workflow_state("dossier-state-resolved", self.dossier, self.empty_dossier) self.dossier1 = create(Builder('dossier') .having(archival_value=ARCHIVAL_VALUE_UNWORTHY) .as_expired() .within(self.leaf_repofolder)) self.dossier2 = create(Builder('dossier') .having(archival_value=ARCHIVAL_VALUE_SAMPLING) .as_expired() .within(self.leaf_repofolder)) ILifeCycle(self.expired_dossier).archival_value = ARCHIVAL_VALUE_WORTHY ILifeCycle(self.empty_dossier).archival_value = ARCHIVAL_VALUE_UNCHECKED ILifeCycle(self.dossier).archival_value = ARCHIVAL_VALUE_PROMPT dossiers = [self.dossier, self.expired_dossier, self.empty_dossier, self.inactive_dossier, self.dossier1] disposition = create(Builder('disposition').having(dossiers=dossiers) .within(self.repository_root)) self.assertItemsEqual(dossiers, disposition.get_dossiers()) self.assertFalse(IAppraisal(disposition).get(self.dossier1)) self.assertTrue(IAppraisal(disposition).get(self.expired_dossier)) self.assertIsNone(IAppraisal(disposition).get(self.empty_dossier)) self.assertIsNone(IAppraisal(disposition).get(self.dossier2)) self.assertIsNone(IAppraisal(disposition).get(self.dossier))
def test_update_appraisal_for_multiple_dossiers_via_update_view( self, browser): repository2 = create(Builder('repository').within(self.root)) dossier3 = create( Builder('dossier').having(archival_value=ARCHIVAL_VALUE_SAMPLING). as_expired().within(repository2)) dossier4 = create( Builder('dossier').having(archival_value=ARCHIVAL_VALUE_SAMPLING). as_expired().within(repository2)) disposition = create( Builder('disposition').within(self.root).having( dossiers=[self.dossier1, self.dossier2, dossier3, dossier4])) intids = getUtility(IIntIds) dossier_ids = [ intids.getId(self.dossier1), intids.getId(dossier3), intids.getId(dossier4) ] browser.login().open(disposition, view='update_appraisal_view', data={ '_authenticator': createToken(), 'dossier-ids': json.dumps(dossier_ids), 'should_be_archived': json.dumps(True) }) self.assertTrue(IAppraisal(disposition).get(self.dossier1)) self.assertTrue(IAppraisal(disposition).get(dossier3)) self.assertTrue(IAppraisal(disposition).get(dossier4))
def test_is_updated_when_editing_the_dossier_list(self, browser): disposition = create( Builder('disposition').having(dossiers=[self.dossier1]).within( self.root)) browser.login().open(disposition, view='edit') browser.fill({'Dossiers': [self.dossier1, self.dossier2]}) browser.find('Save').click() self.assertFalse(IAppraisal(disposition).get(self.dossier1)) self.assertTrue(IAppraisal(disposition).get(self.dossier2))
def test_inactive_dossiers_are_always_not_archival_worthy(self): self.login(self.records_manager) self.set_workflow_state("dossier-state-inactive", self.empty_dossier) ILifeCycle(self.inactive_dossier).archival_value = ARCHIVAL_VALUE_WORTHY ILifeCycle(self.empty_dossier).archival_value = ARCHIVAL_VALUE_SAMPLING disposition = create(Builder('disposition') .having(dossiers=[self.inactive_dossier, self.expired_dossier]) .within(self.repository_root)) self.assertFalse(IAppraisal(disposition).get(self.inactive_dossier)) self.assertFalse(IAppraisal(disposition).get(self.empty_dossier))
def test_archivist_is_not_allowed_to_dispose_a_disposition(self): disposition = create( Builder('disposition').in_state('disposition-state-appraised')) IAppraisal(disposition).update(dossier=self.dossier1, archive=True) IAppraisal(disposition).update(dossier=self.dossier2, archive=True) with self.assertRaises(InvalidParameterError): self.grant('Archivist') api.content.transition(disposition, 'disposition-transition-dispose') self.grant('Records Manager') api.content.transition(disposition, 'disposition-transition-dispose')
def test_direct_close_is_not_allowed_for_archivists(self): self.grant('Archivist') appraisal = IAppraisal(self.disposition) appraisal.update(dossier=self.dossier1, archive=False) appraisal.update(dossier=self.dossier2, archive=False) api.content.transition(self.disposition, 'disposition-transition-appraise') with self.assertRaises(InvalidParameterError): api.content.transition( self.disposition, 'disposition-transition-appraised-to-closed') self.grant('Records Manager') api.content.transition(self.disposition, 'disposition-transition-appraised-to-closed')
def test_when_appraising_final_archival_value_is_stored_on_dossier(self): self.grant('Archivist') IAppraisal(self.disposition).update(dossier=self.dossier1, archive=False) IAppraisal(self.disposition).update(dossier=self.dossier2, archive=True) api.content.transition(self.disposition, transition='disposition-transition-appraise') self.assertEquals(ARCHIVAL_VALUE_UNWORTHY, ILifeCycle(self.dossier1).archival_value) self.assertEquals(ARCHIVAL_VALUE_WORTHY, ILifeCycle(self.dossier2).archival_value)
def test_dispose_is_only_allowed_when_disposition_contains_dossier_to_archive(self): self.grant('Archivist') appraisal = IAppraisal(self.disposition) appraisal.update(dossier=self.dossier1, archive=False) appraisal.update(dossier=self.dossier2, archive=False) api.content.transition(self.disposition, 'disposition-transition-appraise') self.grant('Records Manager') with self.assertRaises(InvalidParameterError): api.content.transition(self.disposition, 'disposition-transition-dispose') appraisal.update(dossier=self.dossier1, archive=True) api.content.transition(self.disposition, 'disposition-transition-dispose')
def test_direct_close_is_not_allowed_for_archivists(self): self.grant('Archivist') appraisal = IAppraisal(self.disposition) appraisal.update(dossier=self.dossier1, archive=False) appraisal.update(dossier=self.dossier2, archive=False) api.content.transition(self.disposition, 'disposition-transition-appraise') with self.assertRaises(InvalidParameterError): api.content.transition(self.disposition, 'disposition-transition-appraised-to-closed') self.grant('Records Manager') api.content.transition(self.disposition, 'disposition-transition-appraised-to-closed')
def setUp(self): super(TestHistoryListingInOverview, self).setUp() self.root = create(Builder('repository_root')) self.repository = create(Builder('repository').within(self.root)) self.dossier1 = create(Builder('dossier') .as_expired() .having(archival_value=ARCHIVAL_VALUE_WORTHY) .within(self.repository)) self.dossier2 = create(Builder('dossier') .as_expired() .having(archival_value=ARCHIVAL_VALUE_WORTHY) .within(self.repository)) self.grant( 'Contributor', 'Editor', 'Reader', 'Reviewer', 'Records Manager', 'Archivist') self.disposition = create(Builder('disposition') .having(dossiers=[self.dossier1, self.dossier2]) .within(self.root)) IAppraisal(self.disposition).update( dossier=self.dossier2, archive=False) api.content.transition(obj=self.disposition, transition='disposition-transition-appraise') transaction.commit()
def test_direct_close_is_not_allowed_for_archivists(self): self.login(self.archivist) appraisal = IAppraisal(self.disposition) appraisal.update(dossier=self.offered_dossier_to_archive, archive=False) api.content.transition(obj=self.disposition, transition='disposition-transition-appraise') with self.assertRaises(InvalidParameterError): api.content.transition( obj=self.disposition, transition='disposition-transition-appraised-to-closed') self.login(self.records_manager) api.content.transition(self.disposition, 'disposition-transition-appraised-to-closed')
def test_inactive_dossiers_are_always_not_archival_worthy(self): dossier1 = create( Builder('dossier').having( archival_value=ARCHIVAL_VALUE_SAMPLING).as_expired().in_state( 'dossier-state-inactive').within(self.repository)) dossier2 = create( Builder('dossier').having( archival_value=ARCHIVAL_VALUE_WORTHY).as_expired().in_state( 'dossier-state-inactive').within(self.repository)) disposition = create( Builder('disposition').having( dossiers=[dossier1, dossier2]).within(self.root)) self.assertFalse(IAppraisal(disposition).get(dossier1)) self.assertFalse(IAppraisal(disposition).get(dossier2))
def test_details_list_dossier_snapshot(self, browser): self.login(self.archivist, browser) IAppraisal(self.disposition).update( dossier=self.offered_dossier_to_archive, archive=False) api.content.transition(obj=self.disposition, transition='disposition-transition-appraise') browser.open(self.disposition, view='overview') appraise = browser.css('div.details ul')[0] add = browser.css('div.details ul')[1] self.assertEquals([ "Client1 1.1 / 12 Hannah Baufrau Don't archive", "Client1 1.1 / 14 Hans Baumann Don't archive" ], appraise.css('li').text) self.assertEquals([ 'Client1 1.1 / 12 Hannah Baufrau Archive', "Client1 1.1 / 14 Hans Baumann Don't archive" ], add.css('li').text)
def test_appraisal_is_in_complete_when_not_all_dossiers_are_appraised(self): dossier3 = create(Builder('dossier') .having(archival_value=ARCHIVAL_VALUE_SAMPLING) .as_expired() .within(self.repository)) disposition = create(Builder('disposition') .having(dossiers=[self.dossier1, self.dossier2, dossier3]) .within(self.root)) appraisal = IAppraisal(disposition) self.assertFalse(appraisal.is_complete()) appraisal.update(dossier=dossier3, archive=True) self.assertTrue(appraisal.is_complete())
def test_update_appraisal_via_update_view(self, browser): disposition = create( Builder('disposition').having( dossiers=[self.dossier1, self.dossier2]).within(self.root)) self.assertFalse(IAppraisal(disposition).get(self.dossier1)) intid = getUtility(IIntIds).getId(self.dossier1) browser.login().open(disposition, view='update_appraisal_view', data={ '_authenticator': createToken(), 'dossier-id': json.dumps(intid), 'should_be_archived': json.dumps(True) }) self.assertTrue(IAppraisal(disposition).get(self.dossier1))
def test_when_archiving_all_dossiers_moved_to_archived_set_to_archive_state( self): self.grant('Archivist', 'Records Manager') IAppraisal(self.disposition).update(dossier=self.dossier1, archive=True) IAppraisal(self.disposition).update(dossier=self.dossier2, archive=True) api.content.transition(self.disposition, transition='disposition-transition-appraise') api.content.transition(self.disposition, transition='disposition-transition-dispose') api.content.transition(self.disposition, transition='disposition-transition-archive') self.assertEquals('dossier-state-archived', api.content.get_state(self.dossier1)) self.assertEquals('dossier-state-archived', api.content.get_state(self.dossier2))
def test_appraising_is_not_possible_if_the_appraisal_is_incomplete(self, browser): self.grant('Archivist') browser.login().open(self.disposition) browser.click_on('disposition-transition-appraise') self.assertEquals( ['The appraisal is incomplete, appraisal could not be finalized.'], error_messages()) self.assertEquals('disposition-state-in-progress', api.content.get_state(self.disposition)) appraisal = IAppraisal(self.disposition) appraisal.update(dossier=self.dossier1, archive=False) appraisal.update(dossier=self.dossier2, archive=True) transaction.commit() browser.login().open(self.disposition) browser.click_on('disposition-transition-appraise') self.assertEquals('disposition-state-appraised', api.content.get_state(self.disposition))
def test_update_appraisal_via_update_view(self, browser): self.login(self.records_manager, browser=browser) self.set_workflow_state("dossier-state-resolved", self.empty_dossier) ILifeCycle(self.expired_dossier).archival_value = ARCHIVAL_VALUE_SAMPLING ILifeCycle(self.empty_dossier).archival_value = ARCHIVAL_VALUE_UNWORTHY disposition = create(Builder('disposition') .having(dossiers=[self.expired_dossier, self.empty_dossier]) .within(self.repository_root)) self.assertFalse(IAppraisal(disposition).get(self.expired_dossier)) self.assertFalse(IAppraisal(disposition).get(self.empty_dossier)) intid = getUtility(IIntIds).getId(self.expired_dossier) browser.open(disposition, view='update_appraisal_view', data={'_authenticator': createToken(), 'dossier-id': json.dumps(intid), 'should_be_archived': json.dumps(True)}) self.assertTrue(IAppraisal(disposition).get(self.expired_dossier)) self.assertFalse(IAppraisal(disposition).get(self.empty_dossier))
def test_added_dossiers(self): dossier3 = create( Builder('dossier').having( archival_value=ARCHIVAL_VALUE_SAMPLING).as_expired().within( self.repository)) dossier4 = create( Builder('dossier').having( archival_value=ARCHIVAL_VALUE_UNCHECKED).as_expired().within( self.repository)) dossier5 = create( Builder('dossier').having( archival_value=ARCHIVAL_VALUE_PROMPT).as_expired().within( self.repository)) disposition = create( Builder('disposition').having(dossiers=[ self.dossier1, self.dossier2, dossier3, dossier4, dossier5 ]).within(self.root)) self.assertFalse(IAppraisal(disposition).get(self.dossier1)) self.assertTrue(IAppraisal(disposition).get(self.dossier2)) self.assertIsNone(IAppraisal(disposition).get(dossier3)) self.assertIsNone(IAppraisal(disposition).get(dossier4)) self.assertIsNone(IAppraisal(disposition).get(dossier5))
def test_add_history_entry_when_directly_close_a_disposition(self): IAppraisal(self.disposition).update(dossier=self.dossier1, archive=False) api.content.transition(obj=self.disposition, transition='disposition-transition-appraise') api.content.transition(obj=self.disposition, transition='disposition-transition-appraised-to-closed') entry = IHistoryStorage(self.disposition).get_history()[0] self.assertTrue(isinstance(entry, AppraisedToClosed)) self.assertEquals('close', entry.css_class) self.assertEquals( u'Disposition closed and all dossiers destroyed by {}'.format( self.user_link), translate(entry.msg(), context=self.request))
def test_ignores_modified_events_during_dossier_destruction(self): api.content.transition(obj=self.disposition, transition='disposition-transition-appraise') IAppraisal(self.disposition).update(dossier=self.dossier1, archive=True) api.content.transition(obj=self.disposition, transition='disposition-transition-dispose') api.content.transition(obj=self.disposition, transition='disposition-transition-archive') api.content.transition(obj=self.disposition, transition='disposition-transition-close') history = IHistoryStorage(self.disposition).get_history() self.assertEquals( 'disposition-transition-close', history[0].transition) self.assertEquals( 'disposition-transition-archive', history[1].transition)
def test_update_appraisal_for_multiple_dossiers_via_update_view(self, browser): self.login(self.records_manager, browser=browser) self.set_workflow_state("dossier-state-resolved", self.empty_dossier) ILifeCycle(self.expired_dossier).archival_value = ARCHIVAL_VALUE_SAMPLING ILifeCycle(self.empty_dossier).archival_value = ARCHIVAL_VALUE_UNWORTHY repository2 = create(Builder('repository').within(self.repository_root)) dossier1 = create(Builder('dossier') .having(archival_value=ARCHIVAL_VALUE_SAMPLING) .as_expired() .within(repository2)) dossier2 = create(Builder('dossier') .having(archival_value=ARCHIVAL_VALUE_SAMPLING) .as_expired() .within(repository2)) disposition = create(Builder('disposition') .within(self.repository_root) .having(dossiers=[self.expired_dossier, self.empty_dossier, dossier1, dossier2])) self.assertFalse(IAppraisal(disposition).get(self.expired_dossier)) self.assertFalse(IAppraisal(disposition).get(self.empty_dossier)) self.assertFalse(IAppraisal(disposition).get(dossier1)) self.assertFalse(IAppraisal(disposition).get(dossier2)) intids = getUtility(IIntIds) dossier_ids = [intids.getId(self.expired_dossier), intids.getId(dossier1), intids.getId(dossier2)] browser.open(disposition, view='update_appraisal_view', data={'_authenticator': createToken(), 'dossier-ids': json.dumps(dossier_ids), 'should_be_archived': json.dumps(True)}) self.assertTrue(IAppraisal(disposition).get(self.expired_dossier)) self.assertFalse(IAppraisal(disposition).get(self.empty_dossier)) self.assertTrue(IAppraisal(disposition).get(dossier1)) self.assertTrue(IAppraisal(disposition).get(dossier2))
def test_add_history_entry_when_directly_close_a_disposition(self): self.login(self.records_manager) IAppraisal(self.disposition).update( dossier=self.offered_dossier_to_archive, archive=False) with elevated_privileges(): api.content.transition( obj=self.disposition, transition='disposition-transition-appraise') api.content.transition( obj=self.disposition, transition='disposition-transition-appraised-to-closed') entry = IHistoryStorage(self.disposition).get_history()[0] self.assertTrue(isinstance(entry, AppraisedToClosed)) self.assertEquals('close', entry.css_class) self.assertEquals( u'Disposition closed and all dossiers destroyed by {}'.format( self.current_user_link), translate(entry.msg(), context=self.request))
def test_dispose_is_only_allowed_when_disposition_contains_dossier_to_archive( self): self.login(self.archivist) appraisal = IAppraisal(self.disposition) appraisal.update(dossier=self.offered_dossier_to_archive, archive=False) api.content.transition(obj=self.disposition, transition='disposition-transition-appraise') self.login(self.records_manager) with self.assertRaises(InvalidParameterError): api.content.transition(self.disposition, 'disposition-transition-dispose') appraisal.update(dossier=self.offered_dossier_to_archive, archive=True) api.content.transition(self.disposition, 'disposition-transition-dispose')
def test_dispose_is_only_allowed_when_disposition_contains_dossier_to_archive( self): self.grant('Archivist') appraisal = IAppraisal(self.disposition) appraisal.update(dossier=self.dossier1, archive=False) appraisal.update(dossier=self.dossier2, archive=False) api.content.transition(self.disposition, 'disposition-transition-appraise') self.grant('Records Manager') with self.assertRaises(InvalidParameterError): api.content.transition(self.disposition, 'disposition-transition-dispose') appraisal.update(dossier=self.dossier1, archive=True) api.content.transition(self.disposition, 'disposition-transition-dispose')
def test_appraisal_is_in_complete_when_not_all_dossiers_are_appraised( self): dossier3 = create( Builder('dossier').having( archival_value=ARCHIVAL_VALUE_SAMPLING).as_expired().within( self.repository)) disposition = create( Builder('disposition').having( dossiers=[self.dossier1, self.dossier2, dossier3]).within( self.root)) appraisal = IAppraisal(disposition) self.assertFalse(appraisal.is_complete()) appraisal.update(dossier=dossier3, archive=True) self.assertTrue(appraisal.is_complete())
def test_ignores_modified_events_during_dossier_destruction(self): self.login(self.records_manager) with elevated_privileges(): api.content.transition( obj=self.disposition, transition='disposition-transition-appraise') IAppraisal(self.disposition).update( dossier=self.offered_dossier_to_destroy, archive=True) api.content.transition(obj=self.disposition, transition='disposition-transition-dispose') api.content.transition(obj=self.disposition, transition='disposition-transition-archive') api.content.transition(obj=self.disposition, transition='disposition-transition-close') self.assertEquals([ 'disposition-transition-close', 'disposition-transition-archive', 'disposition-transition-dispose', 'disposition-transition-appraise', 'added' ], [ item.transition for item in IHistoryStorage(self.disposition).get_history() ])
def test_unarchived_dossiers_get_removed_when_closing_disposition(self): self.login(self.manager) expected_difference = [ self.offered_dossier_to_archive, self.offered_dossier_to_destroy ] api.content.transition(obj=self.disposition, transition='disposition-transition-appraise') content_before = self.leaf_repofolder.listFolderContents() ILifeCycle(self.offered_dossier_to_archive ).archival_value = ARCHIVAL_VALUE_UNWORTHY IAppraisal(self.disposition).initialize( self.offered_dossier_to_archive) api.content.transition( obj=self.disposition, transition='disposition-transition-appraised-to-closed') content_after = self.leaf_repofolder.listFolderContents() self.assertItemsEqual( expected_difference, set(content_before).difference(set(content_after)))
def test_appraisal_is_incomplete_when_not_all_dossiers_are_appraised(self): self.login(self.records_manager) self.set_workflow_state("dossier-state-resolved", self.dossier, self.empty_dossier) ILifeCycle(self.expired_dossier).archival_value = ARCHIVAL_VALUE_WORTHY ILifeCycle(self.empty_dossier).archival_value = ARCHIVAL_VALUE_UNWORTHY ILifeCycle(self.dossier).archival_value = ARCHIVAL_VALUE_SAMPLING disposition = create(Builder('disposition') .having(dossiers=[self.expired_dossier, self.empty_dossier, self.dossier]) .within(self.repository_root)) appraisal = IAppraisal(disposition) self.assertFalse(appraisal.is_complete()) appraisal.update(dossier=self.dossier, archive=True) self.assertTrue(appraisal.is_complete())
def test_appraising_is_not_possible_if_the_appraisal_is_incomplete( self, browser): self.login(self.archivist, browser) appraisal = IAppraisal(self.disposition) appraisal.update(dossier=self.offered_dossier_to_archive, archive=None) browser.open(self.disposition) browser.click_on('disposition-transition-appraise') self.assertEquals( ['The appraisal is incomplete, appraisal could not be finalized.'], error_messages()) self.assertEquals('disposition-state-in-progress', api.content.get_state(self.disposition)) appraisal.update(dossier=self.offered_dossier_to_archive, archive=True) browser.open(self.disposition) browser.click_on('disposition-transition-appraise') self.assertEquals('disposition-state-appraised', api.content.get_state(self.disposition))
def test_appraising_is_not_possible_if_the_appraisal_is_incomplete( self, browser): self.grant('Archivist') browser.login().open(self.disposition) browser.click_on('disposition-transition-appraise') self.assertEquals( ['The appraisal is incomplete, appraisal could not be finalized.'], error_messages()) self.assertEquals('disposition-state-in-progress', api.content.get_state(self.disposition)) appraisal = IAppraisal(self.disposition) appraisal.update(dossier=self.dossier1, archive=False) appraisal.update(dossier=self.dossier2, archive=True) transaction.commit() browser.login().open(self.disposition) browser.click_on('disposition-transition-appraise') self.assertEquals('disposition-state-appraised', api.content.get_state(self.disposition))
def test_when_appraising_final_archival_value_is_stored_on_dossier(self): self.login(self.archivist) appraisal = IAppraisal(self.disposition) self.assertEquals( ARCHIVAL_VALUE_WORTHY, ILifeCycle(self.offered_dossier_to_archive).archival_value) self.assertEquals( ARCHIVAL_VALUE_UNWORTHY, ILifeCycle(self.offered_dossier_to_destroy).archival_value) appraisal.update(dossier=self.offered_dossier_to_archive, archive=False) appraisal.update(dossier=self.offered_dossier_to_destroy, archive=True) api.content.transition(self.disposition, transition='disposition-transition-appraise') self.assertEquals( ARCHIVAL_VALUE_UNWORTHY, ILifeCycle(self.offered_dossier_to_archive).archival_value) self.assertEquals( ARCHIVAL_VALUE_WORTHY, ILifeCycle(self.offered_dossier_to_destroy).archival_value)