def test_dossier_tasks_history(self, browser): repository = create(Builder('repository_root') .titled(u'Repository')) dossier = create(Builder('dossier') .titled(u'Anfr\xf6gen 2015') .within(repository) .having(responsible=self.user.userid)) browser.login().visit(dossier) factoriesmenu.add('Task') browser.fill({'Title': 'Task title', 'Task Type': 'To comment'}) form = browser.find_form_by_field('Responsible') form.find_widget('Responsible').fill(TEST_USER_ID) browser.find('Save').click() browser.open('http://nohost/plone/repository/dossier-1/task-1') browser.click_on("task-transition-open-resolved") browser.fill({'Response': 'response text'}) browser.click_on("Save") with provide_dossier_task_layer(dossier.REQUEST): layout = DefaultLayout(dossier, dossier.REQUEST, PDFBuilder()) dossiertasks = getMultiAdapter((dossier, dossier.REQUEST, layout), ILaTeXView) tasks_data = dossiertasks.get_render_arguments()['task_data_list'] self.assertEqual(1, len(tasks_data)) self.assertIn("response text", tasks_data[0]['history'])
def setUp(self): super(TestDossierCoverRenderArguments, self).setUp() create( Builder('admin_unit').having( unit_id=u'OG', title=u'Department of forest & hunt', abbreviation=u'DoFH').as_current_admin_unit()) self.user = create_ogds_user('hugo.boss') self.repository = create( Builder('repository_root').having( version='Repository 2013 & 2014')) repofolder = create(Builder('repository').within(self.repository)) dossier = create( Builder('dossier').having(title=u'Foo & bar', responsible='hugo.boss', start=date(2013, 11, 1), end=date(2013, 12, 31)).within(repofolder)) provide_request_layer(dossier.REQUEST, IDossierCoverLayer) layout = DefaultLayout(dossier, dossier.REQUEST, PDFBuilder()) self.dossiercover = getMultiAdapter((dossier, dossier.REQUEST, layout), ILaTeXView)
def setUp(self): super(TestOpenTaskReport, self).setUp() self.user, self.org_unit, self.admin_unit = create( Builder('fixture').with_all_unit_setup()) self.hans = create( Builder('ogds_user').having(userid='hans.meier', firstname='Hans', lastname='Meier').assign_to_org_units( [self.org_unit])) create(Builder('user').with_userid('hans.meier')) self.peter = create( Builder('ogds_user').having(userid='peter.peter', firstname='Peter', lastname='Peter')) self.task = create( Builder("task").titled(u'Task 1').having( task_type='comment', issuer='peter.peter', responsible='hans.meier', responsible_client='org-unit-1', deadline=date(2014, 07, 01))) provide_request_layer(self.task.REQUEST, IOpenTaskReportLayer) layout = DefaultLayout(self.task, self.task.REQUEST, PDFBuilder()) self.opentaskreport = getMultiAdapter( (self.task, self.task.REQUEST, layout), ILaTeXView)
def test_journal_label(self, browser): dossier = create(Builder('dossier').titled(u'Anfr\xf6gen 2015')) provide_request_layer(dossier.REQUEST, IDossierJournalLayer) layout = DefaultLayout(dossier, dossier.REQUEST, PDFBuilder()) dossier_journal = getMultiAdapter((dossier, dossier.REQUEST, layout), ILaTeXView) self.assertEquals(u'Journal of dossier Anfr\xf6gen 2015 (Client1 / 1)', dossier_journal.get_render_arguments().get('label'))
def test_journal_label(self): self.login(self.regular_user) layout = DefaultLayout(self.dossier, self.request, PDFBuilder()) dossier_journal = getMultiAdapter((self.dossier, self.request, layout), ILaTeXView) self.assertEqual( 'Journal of dossier "`Vertr\xc3\xa4ge mit der kantonalen' ' Finanzverwaltung (Client1 1.1 / 1)"\'', dossier_journal.get_render_arguments().get('label'), )
def test_dossier_tasks_label(self, browser): dossier = create(Builder('dossier').titled(u'Anfr\xf6gen 2015')) with provide_dossier_task_layer(dossier.REQUEST): layout = DefaultLayout(dossier, dossier.REQUEST, PDFBuilder()) dossier_tasks = getMultiAdapter( (dossier, dossier.REQUEST, layout), ILaTeXView) self.assertEquals( 'Task list for dossier "`Anfr\xc3\xb6gen 2015 (Client1 / 1)"\'', dossier_tasks.get_render_arguments().get('label'))
def test_handle_special_white_space_characters(self): self.login(self.regular_user) self.dossier.title = u' '.join( (u'vertical\x0btab', self.dossier.title)) layout = DefaultLayout(self.dossier, self.request, PDFBuilder()) dossier_journal = getMultiAdapter((self.dossier, self.request, layout), ILaTeXView) self.assertEqual( 'Journal of dossier "`vertical tab Vertr\xc3\xa4ge mit der' ' kantonalen Finanzverwaltung (Client1 1.1 / 1)"\'', dossier_journal.get_render_arguments().get('label'), )
def test_journal_listing(self, browser): repo = create(Builder('repository')) with freeze(datetime(2016, 4, 12, 10, 35)): browser.login().open(repo) factoriesmenu.add('Business Case Dossier') browser.fill({'Title': u'Dossier A'}) browser.find('Save').click() dossier = browser.context factoriesmenu.add('Document') browser.fill({'Title': u'Document A'}) browser.find('Save').click() expected_date = DateTime() provide_request_layer(dossier.REQUEST, IDossierJournalLayer) layout = DefaultLayout(dossier, dossier.REQUEST, PDFBuilder()) dossierjournal = getMultiAdapter((dossier, dossier.REQUEST, layout), ILaTeXView) expected = [{ 'action': { 'visible': True, 'type': 'Dossier added', 'title': u'label_dossier_added' }, 'comments': '', 'actor': 'test_user_1_', 'time': expected_date }, { 'action': { 'visible': True, 'type': 'Document added', 'title': u'label_document_added' }, 'comments': '', 'actor': 'test_user_1_', 'time': expected_date }, { 'action': { 'visible': False, 'type': 'Dossier modified', 'title': u'label_dossier_modified' }, 'comments': '', 'actor': 'test_user_1_', 'time': expected_date }] self.assertEquals(expected, dossierjournal.get_journal_data())
def test_handle_complex_urls(self): self.login(self.regular_user) self.dossier.title = (u'https://example.com/some.php?get1=1234' '&weird_get_%5Bbracketed%5D=5678&somemore=blah' ) # Do not add commas above, this is a string! layout = DefaultLayout(self.dossier, self.request, PDFBuilder()) dossier_journal = getMultiAdapter((self.dossier, self.request, layout), ILaTeXView) self.assertEqual( 'Journal of dossier "`https://example.com""/some.php?get1=1234' '""\\&weird\\_get\\_\\%5Bbracketed\\%5D=5678' '""\\&somemore=blah (Client1 1.1 / 1)"\'', dossier_journal.get_render_arguments().get('label'), )
def setUp(self): super(TestDossierCoverRenderArguments, self).setUp() registry = getUtility(IRegistry) proxy = registry.forInterface(IBaseClientID) proxy.client_title = u'Department of forest & hunt' create_ogds_user('hugo.boss') self.repository = create( Builder('repository_root').having( version='Repository 2013 & 2014')) repofolder = create(Builder('repository').within(self.repository)) dossier = create( Builder('dossier').having(title=u'Foo & bar', responsible='hugo.boss', start=date(2013, 11, 1), end=date(2013, 12, 31)).within(repofolder)) provide_request_layer(dossier.REQUEST, IDossierCoverLayer) layout = DefaultLayout(dossier, dossier.REQUEST, PDFBuilder()) self.dossiercover = getMultiAdapter((dossier, dossier.REQUEST, layout), ILaTeXView)
def get_view(self, disposition): provide_request_layer(disposition.REQUEST, IRemovalProtocolLayer) layout = DefaultLayout(disposition, disposition.REQUEST, PDFBuilder()) return getMultiAdapter((disposition, disposition.REQUEST, layout), ILaTeXView)
def test_dossier_tasks_data(self, browser): repository = create(Builder('repository_root') .titled(u'Repository')) dossier = create(Builder('dossier') .titled(u'Anfr\xf6gen 2015') .within(repository) .having(responsible=self.user.userid)) subdossier = create(Builder('dossier') .within(dossier) .titled(u'Subdossier')) with freeze(datetime(2016, 4, 12, 10, 35)): task1 = create(Builder('task') .within(dossier) .having(responsible=self.user.userid, issuer=SITE_OWNER_NAME, title="task 1")) task2 = create(Builder('task') .within(subdossier) .having(responsible=self.user.userid, issuer=self.user.userid, title="task 2")) expected_deadline = datetime(2016, 4, 17, 0, 0) with freeze(datetime(2016, 10, 12, 13, 20)): api.content.transition(task1, to_state='task-state-resolved') completion_date = date.today() with provide_dossier_task_layer(dossier.REQUEST): layout = DefaultLayout(dossier, dossier.REQUEST, PDFBuilder()) dossiertasks = getMultiAdapter((dossier, dossier.REQUEST, layout), ILaTeXView) self.assertEquals([task1, task2], dossiertasks.get_tasks()) expected = {'label': 'Task list for dossier "`Anfr\xc3\xb6gen 2015 (Client1 / 1)"\'', 'task_data_list': [{'completion_date': completion_date.strftime('%d.%m.%Y'), 'deadline': expected_deadline.strftime('%d.%m.%Y'), 'description': '', 'responsible': 'Test User (test\\_user\\_1\\_)', 'issuer': 'admin (admin)', 'sequence_number': 1, 'title': 'task 1', 'type': ''}, {'completion_date': None, 'deadline': expected_deadline.strftime('%d.%m.%Y'), 'description': '', 'responsible': 'Test User (test\\_user\\_1\\_)', 'issuer': 'Test User (test\\_user\\_1\\_)', 'sequence_number': 2, 'title': 'task 2', 'type': ''}]} values = dossiertasks.get_render_arguments() # remove history attribute from the dicts, history is tested in # a separate test [item.pop('history') for item in values['task_data_list']] self.assertEquals(expected['label'], values['label']) self.assertEquals(expected['task_data_list'], values['task_data_list'])
def test_journal_listing(self): self.login(self.regular_user) layout = DefaultLayout(self.dossier, self.request, PDFBuilder()) dossier_journal = getMultiAdapter((self.dossier, self.request, layout), ILaTeXView) expected_journal = [ { 'action': { 'visible': True, 'type': 'Dossier added', 'title': u'label_dossier_added', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Document added', 'title': u'label_document_added', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Document added', 'title': u'label_document_added', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Document added', 'title': u'label_document_added', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Document added', 'title': u'label_document_added', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Document added', 'title': u'label_document_added', }, 'comments': '', 'actor': 'franzi.muller', }, { 'action': { 'visible': True, 'type': 'Task added', 'title': u'label_task_added', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Task modified', 'title': u'label_task_modified', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Task modified', 'title': u'label_task_modified', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Task added', 'title': u'label_task_added', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Task modified', 'title': u'label_task_modified', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Task modified', 'title': u'label_task_modified', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Task modified', 'title': u'label_task_modified', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Task added', 'title': u'label_task_added', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Task added', 'title': u'label_task_added', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Task added', 'title': u'label_task_added', }, 'comments': '', 'actor': 'robert.ziegler', }, { 'action': { 'visible': True, 'type': 'Document added', 'title': u'label_document_added', }, 'comments': '', 'actor': 'robert.ziegler', }, ] self.assertEqual(expected_journal, strip_timestamps(dossier_journal.get_journal_data()))
def get_dossierdetails_view(self, dossier): provide_request_layer(dossier.REQUEST, IDossierDetailsLayer) layout = DefaultLayout(dossier, dossier.REQUEST, PDFBuilder()) return getMultiAdapter((dossier, dossier.REQUEST, layout), ILaTeXView)