def test_dossier_from_template(self, browser): toggle_feature(IDossierTemplateSettings, enabled=True) root = create(Builder('repository_root')) leaf_node = create(Builder('repository').within(root)) create(Builder("dossiertemplate") .titled(DOSSIER_REQUIREDS['title'])) with freeze(FROZEN_NOW): browser.login().open(leaf_node) factoriesmenu.add(u'Dossier with template') token = browser.css( 'input[name="form.widgets.template"]').first.attrib.get('value') browser.fill({'form.widgets.template': token}).submit() browser.click_on('Save') dossier = browser.context persisted_values = get_persisted_values_for_obj(dossier) expected = self.get_z3c_form_defaults() # XXX: Don't know why this happens expected['public_trial_statement'] = None self.assertDictEqual(expected, persisted_values)
def test_contact_field_is_hidden_when_contact_feature_is_disabled( self, browser): toggle_feature(IContactSettings, enabled=False) browser.login().open(self.dossier, view='add-journal-entry') self.assertIsNone(browser.find_field_by_text('Contacts'))
def test_subdossier_from_template(self, browser): toggle_feature(IDossierTemplateSettings, enabled=True) root = create(Builder('repository_root')) leaf_node = create(Builder('repository').within(root)) template = create(Builder("dossiertemplate") .titled(u'Main template')) subdossier_template = create(Builder("dossiertemplate") .within(template) .titled(DOSSIER_REQUIREDS['title'])) with freeze(FROZEN_NOW): browser.login().open(leaf_node) factoriesmenu.add(u'Dossier with template') token = browser.css( 'input[name="form.widgets.template"]').first.attrib.get('value') browser.fill({'form.widgets.template': token}).submit() browser.click_on('Save') subdossier = browser.context.listFolderContents()[0] persisted_values = get_persisted_values_for_obj(subdossier) expected = self.get_type_defaults() # Because the main-dossier is made through the ++add++-form and the # subdossier is created trough the object-creator with some attribute # inheritance, we get a mix of z3c_form_defaults and the type_defaults. # A subdossier has the type_defaults with addiional form_defaults expected.update(self.form_defaults) self.assertDictEqual(expected, persisted_values)
def test_document_from_dossiertemplate(self, browser): toggle_feature(IDossierTemplateSettings, enabled=True) root = create(Builder('repository_root')) leaf_node = create(Builder('repository').within(root)) template = create(Builder("dossiertemplate") .titled(DOSSIER_REQUIREDS['title'])) create(Builder('document') .titled(DOCUMENT_REQUIREDS['title']) .within(template) .with_dummy_content()) with freeze(FROZEN_NOW): browser.login().open(leaf_node) factoriesmenu.add(u'Dossier with template') token = browser.css( 'input[name="form.widgets.template"]').first.attrib.get('value') browser.fill({'form.widgets.template': token}).submit() browser.click_on('Save') doc = browser.context.listFolderContents()[0] persisted_values = get_persisted_values_for_obj(doc) expected = self.get_type_defaults() expected['digitally_available'] = True expected['file'] = doc.file self.assertDictEqual(expected, persisted_values)
def test_document_from_dossiertemplate(self, browser): toggle_feature(IDossierTemplateSettings, enabled=True) root = create(Builder('repository_root')) leaf_node = create(Builder('repository').within(root)) template = create( Builder("dossiertemplate").titled(DOSSIER_REQUIREDS['title'])) create( Builder('document').titled(DOCUMENT_REQUIREDS['title']).within( template).with_dummy_content()) with freeze(FROZEN_NOW): browser.login().open(leaf_node) factoriesmenu.add(u'Dossier with template') token = browser.css( 'input[name="form.widgets.template"]').first.attrib.get( 'value') # noqa browser.fill({'form.widgets.template': token}).submit() browser.click_on('Save') doc = browser.context.listFolderContents()[0] persisted_values = get_persisted_values_for_obj(doc) expected = self.get_type_defaults() expected['digitally_available'] = True expected['file'] = doc.file self.assertDictEqual(expected, persisted_values)
def test_redirects_to_plone_implementation_add_form_when_contact_feature_is_enabled( self, browser): toggle_feature(IContactSettings, enabled=True) browser.login().open(self.dossier) factoriesmenu.add('Participant') self.assertEqual('http://nohost/plone/dossier-1/add-sql-participation', browser.url)
def test_shows_person_organization_and_user_tab_when_contact_feature_is_enabled(self, browser): toggle_feature(IContactSettings, enabled=True) browser.login().open(self.contactfolder, view='tabbed_view') self.assertEquals( ['Persons', 'Organizations', 'Users', 'Teams'], browser.css('.formTab').text)
def test_dossier_from_template(self, browser): toggle_feature(IDossierTemplateSettings, enabled=True) root = create(Builder('repository_root')) leaf_node = create(Builder('repository').within(root)) create(Builder("dossiertemplate").titled(DOSSIER_REQUIREDS['title'])) with freeze(FROZEN_NOW): browser.login().open(leaf_node) factoriesmenu.add(u'Dossier with template') token = browser.css( 'input[name="form.widgets.template"]').first.attrib.get( 'value') # noqa browser.fill({'form.widgets.template': token}).submit() browser.click_on('Save') dossier = browser.context persisted_values = get_persisted_values_for_obj(dossier) expected = self.get_z3c_form_defaults() # XXX: Don't know why this happens expected['public_trial_statement'] = None self.assertDictEqual(expected, persisted_values)
def test_shows_person_organization_and_user_tab_when_contact_feature_is_enabled( self, browser): toggle_feature(IContactSettings, enabled=True) browser.login().open(self.contactfolder, view='tabbed_view') self.assertEquals(['Persons', 'Organizations', 'Users'], browser.css('.formTab').text)
def test_subdossier_from_template(self, browser): toggle_feature(IDossierTemplateSettings, enabled=True) root = create(Builder('repository_root')) leaf_node = create(Builder('repository').within(root)) template = create(Builder("dossiertemplate").titled(u'Main template')) create( Builder("dossiertemplate").within(template).titled( DOSSIER_REQUIREDS['title'])) with freeze(FROZEN_NOW): browser.login().open(leaf_node) factoriesmenu.add(u'Dossier with template') token = browser.css( 'input[name="form.widgets.template"]').first.attrib.get( 'value') # noqa browser.fill({'form.widgets.template': token}).submit() browser.click_on('Save') subdossier = browser.context.listFolderContents()[0] persisted_values = get_persisted_values_for_obj(subdossier) expected = self.get_type_defaults() # Because the main-dossier is made through the ++add++-form and the # subdossier is created trough the object-creator with some attribute # inheritance, we get a mix of z3c_form_defaults and the type_defaults. # A subdossier has the type_defaults with addiional form_defaults expected.update(self.form_defaults) self.assertDictEqual(expected, persisted_values)
def test_is_not_available_if_dossiertempalte_feature_is_disabled(self): self.login(self.regular_user) toggle_feature(IDossierTemplateSettings, enabled=False) self.assertFalse( self.leaf_repofolder.restrictedTraverse( '@@dossier_with_template/is_available')())
def test_raise_not_found_if_access_on_wizard_if_feature_is_not_available(self): toggle_feature(IDossierTemplateSettings, enabled=False) with self.assertRaises(Unauthorized): self.leaf_node.restrictedTraverse('@@dossier_with_template')() with self.assertRaises(Unauthorized): self.leaf_node.restrictedTraverse('@@add-dossier-from-template')()
def test_raise_not_found_if_access_on_wizard_if_feature_is_not_available( self): toggle_feature(IDossierTemplateSettings, enabled=False) with self.assertRaises(Unauthorized): self.leaf_node.restrictedTraverse('@@dossier_with_template')() with self.assertRaises(Unauthorized): self.leaf_node.restrictedTraverse('@@add-dossier-from-template')()
def test_contact_participations_are_listed_when_contact_feature_is_enabled( self, browser): toggle_feature(IContactSettings, enabled=True) self.login(self.regular_user, browser=browser) browser.open(self.dossier, view='tabbedview_view-overview') self.assertEqual( [u'B\xfchler Josef', 'Meier AG'], browser.css('#participationsBox li:not(.moreLink) a').text)
def test_contact_participations_are_listed_when_contact_feature_is_enabled(self, browser): toggle_feature(IContactSettings, enabled=True) self.login(self.regular_user, browser=browser) browser.open(self.tested_dossier, view='tabbedview_view-overview') self.assertEqual( [u'B\xfchler Josef', 'Meier AG'], browser.css('#participationsBox li:not(.moreLink) a').text)
def test_contact_participations_are_listed_when_contact_feature_is_enabled( self, browser): create(Builder('contactfolder')) toggle_feature(IContactSettings, enabled=True) hans = create( Builder('person').having(firstname=u'Hans', lastname=u'M\xfcller')) peter_ag = create(Builder('organization').having(name=u'Peter AG')) create( Builder('contact_participation').for_contact(hans).for_dossier( self.dossier).with_roles(['participation'])) create( Builder('contact_participation').for_contact(peter_ag).for_dossier( self.dossier).with_roles(['final-drawing'])) browser.login().open(self.dossier, view='tabbedview_view-overview') self.assertEqual( [u'M\xfcller Hans', 'Peter AG'], browser.css('#participationsBox li:not(.moreLink) a').text)
def test_contact_participations_are_listed_when_contact_feature_is_enabled(self, browser): create(Builder('contactfolder')) toggle_feature(IContactSettings, enabled=True) hans = create(Builder('person') .having(firstname=u'Hans', lastname=u'M\xfcller')) peter_ag = create(Builder('organization').having(name=u'Peter AG')) create(Builder('contact_participation') .for_contact(hans) .for_dossier(self.dossier) .with_roles(['participation'])) create(Builder('contact_participation') .for_contact(peter_ag) .for_dossier(self.dossier) .with_roles(['final-drawing'])) browser.login().open(self.dossier, view='tabbedview_view-overview') self.assertEqual( [u'M\xfcller Hans', 'Peter AG'], browser.css('#participationsBox li:not(.moreLink) a').text)
def test_contact_field_is_hidden_when_contact_feature_is_disabled(self, browser): toggle_feature(IContactSettings, enabled=False) browser.login().open(self.dossier, view='add-journal-entry') self.assertIsNone(browser.find_field_by_text('Contacts'))
def test_is_not_available_if_dossiertempalte_feature_is_disabled(self): toggle_feature(IDossierTemplateSettings, enabled=False) self.assertFalse( self.leaf_node.restrictedTraverse('@@dossier_with_template/is_available')())
def setUp(self): super(TestManualJournalEntry, self).setUp() self.dossier = create(Builder('dossier')) self.contactfolder = create(Builder('contactfolder')) toggle_feature(IContactSettings, enabled=True)
def test_redirects_to_plone_implementation_add_form_when_contact_feature_is_enabled(self, browser): toggle_feature(IContactSettings, enabled=True) browser.login().open(self.dossier) factoriesmenu.add('Participant') self.assertEqual( 'http://nohost/plone/dossier-1/add-sql-participation', browser.url)
def test_is_not_available_if_dossiertempalte_feature_is_disabled(self): toggle_feature(IDossierTemplateSettings, enabled=False) self.assertFalse( self.leaf_node.restrictedTraverse( '@@dossier_with_template/is_available')())