def test_selected_contacts_are_listed_and_linked_in_the_references_column(self, browser): peter = create(Builder('person') .having(firstname=u'H\xfcgo', lastname='Boss')) meierag = create(Builder('organization').named(u'Meier AG')) browser.login().open(self.dossier, view='add-journal-entry') browser.fill({ 'Category': u'phone-call', 'Comment': u'Anfrage bez\xfcglich dem Jahr 2016 von Herr Meier'}) form = browser.find_form_by_field('Contacts') form.find_widget('Contacts').fill( [get_contacts_token(peter), get_contacts_token(meierag)]) browser.css('#form-buttons-add').first.click() browser.open(self.dossier, view=u'tabbedview_view-journal') row = browser.css('.listing').first.rows[1] links = row.css('.contacts a') self.assertEquals(u'Contacts Boss H\xfcgo Meier AG', row.dict().get('References')) self.assertEquals( ['http://nohost/plone/opengever-contact-contactfolder/contact-1', 'http://nohost/plone/opengever-contact-contactfolder/contact-2'], [link.get('href') for link in links]) self.assertEquals([u'Boss H\xfcgo', 'Meier AG'], links.text)
def test_selected_contacts_are_listed_and_linked_in_the_references_column( self, browser): peter = create( Builder('person').having(firstname=u'H\xfcgo', lastname='Boss')) meierag = create(Builder('organization').named(u'Meier AG')) browser.login().open(self.dossier, view='add-journal-entry') browser.fill({ 'Category': u'phone-call', 'Comment': u'Anfrage bez\xfcglich dem Jahr 2016 von Herr Meier' }) form = browser.find_form_by_field('Contacts') form.find_widget('Contacts').fill( [get_contacts_token(peter), get_contacts_token(meierag)]) browser.css('#form-buttons-add').first.click() browser.open(self.dossier, view=u'tabbedview_view-journal') row = browser.css('.listing').first.rows[1] links = row.css('.contacts a') self.assertEquals(u'Contacts Boss H\xfcgo Meier AG', row.dict().get('References')) self.assertEquals([ 'http://nohost/plone/opengever-contact-contactfolder/contact-1', 'http://nohost/plone/opengever-contact-contactfolder/contact-2' ], [link.get('href') for link in links]) self.assertEquals([u'Boss H\xfcgo', 'Meier AG'], links.text)
def test_adding_a_entry_with_a_user_as_contact(self, browser): peter = create( Builder('ogds_user').having(userid=u'peter.mueller', firstname=u'Peter', lastname=u'M\xfcller')) browser.login().open(self.dossier, view='add-journal-entry') browser.fill({ 'Category': u'phone-call', 'Comment': u'Anfrage bez\xfcglich dem Jahr 2016 von Herr Meier' }) form = browser.find_form_by_field('Contacts') form.find_widget('Contacts').fill( [get_contacts_token(OgdsUserToContactAdapter(peter))]) browser.css('#form-buttons-add').first.click() browser.open(self.dossier, view=u'tabbedview_view-journal') row = browser.css('.listing').first.rows[1] links = row.css('.contacts a') self.assertEquals(u'Contacts M\xfcller Peter (peter.mueller)', row.dict().get('References')) self.assertEquals(['http://nohost/plone/@@user-details/peter.mueller'], [link.get('href') for link in links]) self.assertEquals([u'M\xfcller Peter (peter.mueller)'], links.text)
def test_adding_a_entry_with_a_user_as_contact(self, browser): peter = create(Builder('ogds_user').having(userid=u'peter.mueller', firstname=u'Peter', lastname=u'M\xfcller')) browser.login().open(self.dossier, view='add-journal-entry') browser.fill({ 'Category': u'phone-call', 'Comment': u'Anfrage bez\xfcglich dem Jahr 2016 von Herr Meier'}) form = browser.find_form_by_field('Contacts') form.find_widget('Contacts').fill( [get_contacts_token(OgdsUserToContactAdapter(peter))]) browser.css('#form-buttons-add').first.click() browser.open(self.dossier, view=u'tabbedview_view-journal') row = browser.css('.listing').first.rows[1] links = row.css('.contacts a') self.assertEquals(u'Contacts M\xfcller Peter (peter.mueller)', row.dict().get('References')) self.assertEquals( ['http://nohost/plone/@@user-details/peter.mueller'], [link.get('href') for link in links]) self.assertEquals([u'M\xfcller Peter (peter.mueller)'], links.text)
def test_ogds_user_recipient_properties_are_added(self, browser): api.portal.set_registry_record('is_feature_enabled', True, interface=IContactSettings) template_word = create( Builder('document').titled('Word Docx template').within( self.templatefolder).with_asset_file( 'without_custom_properties.docx')) ogds_user = create( Builder('ogds_user').id('peter').having( **OGDS_USER_ATTRIBUTES).as_contact_adapter()) with freeze(self.document_date): # submit first wizard step browser.login().open(self.dossier, view='document_with_template') browser.fill({ 'form.widgets.template': _make_token(template_word), 'Title': 'Test Docx' }) form = browser.find_form_by_field('Recipient') form.find_widget('Recipient').fill(get_contacts_token(ogds_user)) form.save() # submit second wizard step browser.fill({ 'form.widgets.address': '{}_1'.format(ogds_user.id), 'form.widgets.mail_address': '{}_2'.format(ogds_user.id), 'form.widgets.phonenumber': '{}_3'.format(ogds_user.id), 'form.widgets.url': '{}_1'.format(ogds_user.id) }).save() document = self.dossier.listFolderContents()[0] self.assertEquals(u'test-docx.docx', document.file.filename) expected_org_role_properties = { 'ogg.recipient.contact.title': u'M\xfcller Peter', 'ogg.recipient.contact.description': u'nix', 'ogg.recipient.person.salutation': 'Prof. Dr.', 'ogg.recipient.person.firstname': 'Peter', 'ogg.recipient.person.lastname': u'M\xfcller', 'ogg.recipient.address.street': u'Kappelenweg 13, Postfach 1234', 'ogg.recipient.address.zip_code': '1234', 'ogg.recipient.address.city': u'Vorkappelen', 'ogg.recipient.address.country': u'Schweiz', 'ogg.recipient.email.address': u'*****@*****.**', 'ogg.recipient.phone.number': u'012 34 56 76', 'ogg.recipient.url.url': u'http://www.example.com', } expected_org_role_properties.update(self.expected_doc_properties) with TemporaryDocFile(document.file) as tmpfile: self.assertItemsEqual(expected_org_role_properties.items(), read_properties(tmpfile.path)) self.assert_doc_properties_updated_journal_entry_generated(document)
def test_add_participation_for_ogds_user(self, browser): browser.login().open(self.dossier, view='add-sql-participation') browser.fill({'Contact': get_contacts_token(self.hans), 'Roles': ['Regard']}) browser.click_on('Save') participation = Participation.query.first() self.assertEquals(self.hans.id, participation.ogds_user.id) self.assertEquals(self.dossier, participation.resolve_dossier()) self.assertEquals(['regard'], [role.role for role in participation.roles])
def test_add_participation_for_organization(self, browser): browser.login().open(self.dossier, view='add-sql-participation') browser.fill({'Contact': get_contacts_token(self.meier_ag), 'Roles': ['Final drawing', 'Regard']}) browser.click_on('Save') participation = Participation.query.first() self.assertEquals(self.meier_ag.organization_id, participation.contact.organization_id) self.assertEquals(self.dossier, participation.resolve_dossier()) self.assertEquals([u'final-drawing', u'regard'], [role.role for role in participation.roles])
def test_ogds_user_recipient_properties_are_added(self, browser): api.portal.set_registry_record( 'is_feature_enabled', True, interface=IContactSettings) template_word = create(Builder('document') .titled('Word Docx template') .within(self.templatedossier) .with_asset_file('without_custom_properties.docx')) ogds_user = create(Builder('ogds_user') .id('peter') .having(**OGDS_USER_ATTRIBUTES) .as_contact_adapter()) with freeze(self.document_date): # submit first wizard step browser.login().open(self.dossier, view='document_with_template') browser.fill({'form.widgets.template': _make_token(template_word), 'Recipient': get_contacts_token(ogds_user), 'Title': 'Test Docx'}).save() # submit second wizard step browser.fill( {'form.widgets.address': '{}_1'.format(ogds_user.id), 'form.widgets.mail_address': '{}_2'.format(ogds_user.id), 'form.widgets.phonenumber': '{}_3'.format(ogds_user.id), 'form.widgets.url': '{}_1'.format(ogds_user.id)} ).save() document = self.dossier.listFolderContents()[0] self.assertEquals(u'test-docx.docx', document.file.filename) expected_org_role_properties = { 'ogg.recipient.contact.title': u'M\xfcller Peter', 'ogg.recipient.contact.description': u'nix', 'ogg.recipient.person.salutation': 'Prof. Dr.', 'ogg.recipient.person.firstname': 'Peter', 'ogg.recipient.person.lastname': u'M\xfcller', 'ogg.recipient.address.street': u'Kappelenweg 13, Postfach 1234', 'ogg.recipient.address.zip_code': '1234', 'ogg.recipient.address.city': u'Vorkappelen', 'ogg.recipient.address.country': u'Schweiz', 'ogg.recipient.email.address': u'*****@*****.**', 'ogg.recipient.phone.number': u'012 34 56 76', 'ogg.recipient.url.url': u'http://www.example.com', } expected_org_role_properties.update(self.expected_doc_properties) with TemporaryDocFile(document.file) as tmpfile: self.assertItemsEqual( expected_org_role_properties.items(), read_properties(tmpfile.path)) self.assert_doc_properties_updated_journal_entry_generated(document)
def test_add_participation_for_ogds_user(self, browser): browser.login().open(self.dossier, view='add-sql-participation') browser.fill({'Roles': ['Regard']}) form = browser.find_form_by_field('Contact') form.find_widget('Contact').fill(get_contacts_token(self.hans)) browser.click_on('Save') participation = Participation.query.first() self.assertEquals(self.hans.id, participation.ogds_user.id) self.assertEquals(self.dossier, participation.resolve_dossier()) self.assertEquals(['regard'], [role.role for role in participation.roles])
def test_add_participation_for_organization(self, browser): browser.login().open(self.dossier, view='add-sql-participation') browser.fill({'Roles': ['Final drawing', 'Regard']}) form = browser.find_form_by_field('Contact') form.find_widget('Contact').fill(get_contacts_token(self.meier_ag)) browser.click_on('Save') participation = Participation.query.first() self.assertEquals(self.meier_ag.organization_id, participation.contact.organization_id) self.assertEquals(self.dossier, participation.resolve_dossier()) self.assertEquals([u'final-drawing', u'regard'], [role.role for role in participation.roles])
def test_add_participation_for_person(self, browser): browser.login().open(self.dossier, view='add-sql-participation') browser.fill({'Roles': ['Regard']}) form = browser.find_form_by_field('Contact') form.find_widget('Contact').fill(get_contacts_token(self.peter)) browser.click_on('Save') participation = Participation.query.first() self.assertEquals(self.peter.person_id, participation.contact.person_id) self.assertEquals(self.dossier, participation.resolve_dossier()) self.assertEquals(['regard'], [role.role for role in participation.roles])
def test_add_participation_for_org_role(self, browser): org_role = create(Builder('org_role').having( person=self.peter, organization=self.meier_ag, function=u'cheffe')) browser.login().open(self.dossier, view='add-sql-participation') browser.fill({'Contact': get_contacts_token(org_role), 'Roles': ['Final drawing']}) browser.click_on('Save') participation = Participation.query.first() self.assertEqual(org_role.org_role_id, participation.org_role.org_role_id) self.assertEquals(self.dossier, participation.resolve_dossier()) self.assertEquals([u'final-drawing'], [role.role for role in participation.roles])
def test_add_already_existing_participation_raise_validation_error(self, browser): create(Builder('contact_participation') .having(contact=self.peter, dossier_oguid=Oguid.for_object(self.dossier))) browser.login().open(self.dossier, view='add-sql-participation') browser.fill({'Contact': get_contacts_token(self.peter), 'Roles': ['Final drawing', 'Regard']}) browser.click_on('Save') self.assertEquals(['There were some errors.'], error_messages()) self.assertEquals( ['There already exists a participation for this contact.'], browser.css('div.error').text),
def test_supports_adding_an_entry_without_a_comment(self, browser): peter = create( Builder('person').having(firstname=u'H\xfcgo', lastname='Boss')) browser.login().open(self.dossier, view='add-journal-entry') browser.fill({'Category': u'phone-call'}) form = browser.find_form_by_field('Contacts') form.find_widget('Contacts').fill([get_contacts_token(peter)]) browser.css('#form-buttons-add').first.click() browser.open(self.dossier, view=u'tabbedview_view-journal') row = browser.css('.listing').first.rows[1] self.assertEquals('Manual entry: Phone call', row.dict().get('Title')) self.assertEquals('', row.dict().get('Comments'))
def test_add_already_existing_participation_raise_validation_error(self, browser): create(Builder('contact_participation') .having(contact=self.peter, dossier_oguid=Oguid.for_object(self.dossier))) browser.login().open(self.dossier, view='add-sql-participation') browser.fill({'Roles': ['Final drawing', 'Regard']}) form = browser.find_form_by_field('Contact') form.find_widget('Contact').fill(get_contacts_token(self.peter)) browser.click_on('Save') self.assertEquals(['There were some errors.'], error_messages()) self.assertEquals( ['There already exists a participation for this contact.'], browser.css('div.error').text),
def test_supports_adding_an_entry_without_a_comment(self, browser): peter = create(Builder('person') .having(firstname=u'H\xfcgo', lastname='Boss')) browser.login().open(self.dossier, view='add-journal-entry') browser.fill({'Category': u'phone-call'}) form = browser.find_form_by_field('Contacts') form.find_widget('Contacts').fill([get_contacts_token(peter)]) browser.css('#form-buttons-add').first.click() browser.open(self.dossier, view=u'tabbedview_view-journal') row = browser.css('.listing').first.rows[1] self.assertEquals('Manual entry: Phone call', row.dict().get('Title')) self.assertEquals('', row.dict().get('Comments'))
def test_add_participation_for_org_role(self, browser): org_role = create(Builder('org_role').having( person=self.peter, organization=self.meier_ag, function=u'cheffe')) browser.login().open(self.dossier, view='add-sql-participation') browser.fill({'Roles': ['Final drawing']}) form = browser.find_form_by_field('Contact') form.find_widget('Contact').fill(get_contacts_token(org_role)) browser.click_on('Save') participation = Participation.query.first() self.assertEqual(org_role.org_role_id, participation.org_role.org_role_id) self.assertEquals(self.dossier, participation.resolve_dossier()) self.assertEquals([u'final-drawing'], [role.role for role in participation.roles])
def test_org_role_recipient_properties_are_added(self, browser): organization = create( Builder('organization') .having(name=u'Meier AG'), ) org_role = create( Builder('org_role') .having( person=self.peter, organization=organization, function=u'cheffe', ), ) create( Builder('address') .for_contact(organization) .labeled(u'Home') .having( street=u'Musterstrasse 283', zip_code=u'1234', city=u'Hinterkappelen', country=u'Schweiz', ), ) mailaddress = create( Builder('mailaddress') .for_contact(organization) .having(address=u'*****@*****.**'), ) phonenumber = create( Builder('phonenumber') .for_contact(self.peter) .having(phone_number=u'1234 123 123'), ) url = create( Builder('url') .for_contact(organization) .having(url=u'http://www.example.com'), ) address_id = org_role.addresses[0].address_id with freeze(self.document_date): # submit first wizard step browser.login().open(self.dossier, view='document_with_template') browser.fill({ 'form.widgets.template': self._make_token(self.template_word), 'Title': 'Test Docx', }) form = browser.find_form_by_field('Recipient') form.find_widget('Recipient').fill(get_contacts_token(org_role)) form.save() # submit second wizard step browser.fill({ 'form.widgets.address': address_id, 'form.widgets.mail_address': str(mailaddress.mailaddress_id), 'form.widgets.phonenumber': str(phonenumber.phone_number_id), 'form.widgets.url': str(url.url_id), }).save() document = self.dossier.listFolderContents()[0] self.assertEquals(u'test-docx.docx', document.file.filename) expected_org_role_properties = { 'ogg.recipient.contact.title': u'M\xfcller Peter', 'ogg.recipient.person.firstname': 'Peter', 'ogg.recipient.person.lastname': u'M\xfcller', 'ogg.recipient.orgrole.function': u'cheffe', 'ogg.recipient.organization.name': u'Meier AG', 'ogg.recipient.address.street': u'Musterstrasse 283', 'ogg.recipient.address.zip_code': '1234', 'ogg.recipient.address.city': 'Hinterkappelen', 'ogg.recipient.address.country': 'Schweiz', 'ogg.recipient.email.address': u'*****@*****.**', 'ogg.recipient.phone.number': u'1234 123 123', 'ogg.recipient.url.url': u'http://www.example.com', } expected_org_role_properties.update(self.expected_doc_properties) with TemporaryDocFile(document.file) as tmpfile: self.assertItemsEqual(expected_org_role_properties.items(), read_properties(tmpfile.path)) self.assert_doc_properties_updated_journal_entry_generated(document)
def test_contact_recipient_properties_are_added(self, browser): address1 = create( Builder('address') .for_contact(self.peter) .labeled(u'Home') .having( street=u'Musterstrasse 283', zip_code=u'1234', city=u'Hinterkappelen', country=u'Schweiz', ), ) create( Builder('address') .for_contact(self.peter) .labeled(u'Home') .having( street=u'Hauptstrasse 1', city=u'Vorkappelen', ), ) mailaddress = create( Builder('mailaddress') .for_contact(self.peter) .having(address=u'*****@*****.**'), ) phonenumber = create( Builder('phonenumber') .for_contact(self.peter) .having(phone_number=u'1234 123 123'), ) url = create( Builder('url') .for_contact(self.peter) .having(url=u'http://www.example.com'), ) with freeze(self.document_date): # submit first wizard step browser.login().open(self.dossier, view='document_with_template') browser.fill({ 'form.widgets.template': self._make_token(self.template_word), 'Title': 'Test Docx', }) form = browser.find_form_by_field('Recipient') form.find_widget('Recipient').fill(get_contacts_token(self.peter)) form.save() # submit second wizard step browser.fill({ 'form.widgets.address': str(address1.address_id), 'form.widgets.mail_address': str(mailaddress.mailaddress_id), 'form.widgets.phonenumber': str(phonenumber.phone_number_id), 'form.widgets.url': str(url.url_id), }).save() document = self.dossier.listFolderContents()[0] self.assertEquals(u'test-docx.docx', document.file.filename) expected_person_properties = { 'ogg.recipient.contact.title': u'M\xfcller Peter', 'ogg.recipient.person.firstname': 'Peter', 'ogg.recipient.person.lastname': u'M\xfcller', 'ogg.recipient.address.street': u'Musterstrasse 283', 'ogg.recipient.address.zip_code': '1234', 'ogg.recipient.address.city': 'Hinterkappelen', 'ogg.recipient.address.country': 'Schweiz', 'ogg.recipient.email.address': u'*****@*****.**', 'ogg.recipient.phone.number': u'1234 123 123', 'ogg.recipient.url.url': u'http://www.example.com', } expected_person_properties.update(self.expected_doc_properties) with TemporaryDocFile(document.file) as tmpfile: self.assertItemsEqual(expected_person_properties.items(), read_properties(tmpfile.path)) self.assert_doc_properties_updated_journal_entry_generated(document)
def test_contact_recipient_properties_are_added(self, browser): api.portal.set_registry_record('is_feature_enabled', True, interface=IContactSettings) template_word = create( Builder('document').titled('Word Docx template').within( self.templatefolder).with_asset_file( 'without_custom_properties.docx')) peter = create( Builder('person').having(firstname=u'Peter', lastname=u'M\xfcller')) address1 = create( Builder('address').for_contact(peter).labeled(u'Home').having( street=u'Musterstrasse 283', zip_code=u'1234', city=u'Hinterkappelen', country=u'Schweiz')) create( Builder('address').for_contact(peter).labeled(u'Home').having( street=u'Hauptstrasse 1', city=u'Vorkappelen')) mailaddress = create( Builder('mailaddress').for_contact(peter).having( address=u'*****@*****.**')) phonenumber = create( Builder('phonenumber').for_contact(peter).having( phone_number=u'1234 123 123')) url = create( Builder('url').for_contact(peter).having( url=u'http://www.example.com')) with freeze(self.document_date): # submit first wizard step browser.login().open(self.dossier, view='document_with_template') browser.fill({ 'form.widgets.template': _make_token(template_word), 'Title': 'Test Docx' }) form = browser.find_form_by_field('Recipient') form.find_widget('Recipient').fill(get_contacts_token(peter)) form.save() # submit second wizard step browser.fill({ 'form.widgets.address': str(address1.address_id), 'form.widgets.mail_address': str(mailaddress.mailaddress_id), 'form.widgets.phonenumber': str(phonenumber.phone_number_id), 'form.widgets.url': str(url.url_id) }).save() document = self.dossier.listFolderContents()[0] self.assertEquals(u'test-docx.docx', document.file.filename) expected_person_properties = { 'ogg.recipient.contact.title': u'M\xfcller Peter', 'ogg.recipient.person.firstname': 'Peter', 'ogg.recipient.person.lastname': u'M\xfcller', 'ogg.recipient.address.street': u'Musterstrasse 283', 'ogg.recipient.address.zip_code': '1234', 'ogg.recipient.address.city': 'Hinterkappelen', 'ogg.recipient.address.country': 'Schweiz', 'ogg.recipient.email.address': u'*****@*****.**', 'ogg.recipient.phone.number': u'1234 123 123', 'ogg.recipient.url.url': u'http://www.example.com', } expected_person_properties.update(self.expected_doc_properties) with TemporaryDocFile(document.file) as tmpfile: self.assertItemsEqual(expected_person_properties.items(), read_properties(tmpfile.path)) self.assert_doc_properties_updated_journal_entry_generated(document)
def test_org_role_recipient_properties_are_added(self, browser): api.portal.set_registry_record( 'is_feature_enabled', True, interface=IContactSettings) template_word = create(Builder('document') .titled('Word Docx template') .within(self.templatedossier) .with_asset_file('without_custom_properties.docx')) peter = create(Builder('person') .having(firstname=u'Peter', lastname=u'M\xfcller')) organization = create(Builder('organization') .having(name=u'Meier AG')) org_role = create(Builder('org_role').having( person=peter, organization=organization, function=u'cheffe')) address1 = create(Builder('address') .for_contact(organization) .labeled(u'Home') .having(street=u'Musterstrasse 283', zip_code=u'1234', city=u'Hinterkappelen', country=u'Schweiz')) mailaddress = create(Builder('mailaddress') .for_contact(organization) .having(address=u'*****@*****.**')) phonenumber = create(Builder('phonenumber') .for_contact(peter) .having(phone_number=u'1234 123 123')) url = create(Builder('url') .for_contact(organization) .having(url=u'http://www.example.com')) address_id = org_role.addresses[0].address_id with freeze(self.document_date): # submit first wizard step browser.login().open(self.dossier, view='document_with_template') browser.fill({'form.widgets.template': _make_token(template_word), 'Recipient': get_contacts_token(org_role), 'Title': 'Test Docx'}).save() # submit second wizard step browser.fill( {'form.widgets.address': address_id, 'form.widgets.mail_address': str(mailaddress.mailaddress_id), 'form.widgets.phonenumber': str(phonenumber.phone_number_id), 'form.widgets.url': str(url.url_id)} ).save() document = self.dossier.listFolderContents()[0] self.assertEquals(u'test-docx.docx', document.file.filename) expected_org_role_properties = { 'ogg.recipient.contact.title': u'M\xfcller Peter', 'ogg.recipient.person.firstname': 'Peter', 'ogg.recipient.person.lastname': u'M\xfcller', 'ogg.recipient.orgrole.function': u'cheffe', 'ogg.recipient.organization.name': u'Meier AG', 'ogg.recipient.address.street': u'Musterstrasse 283', 'ogg.recipient.address.zip_code': '1234', 'ogg.recipient.address.city': 'Hinterkappelen', 'ogg.recipient.address.country': 'Schweiz', 'ogg.recipient.email.address': u'*****@*****.**', 'ogg.recipient.phone.number': u'1234 123 123', 'ogg.recipient.url.url': u'http://www.example.com', } expected_org_role_properties.update(self.expected_doc_properties) with TemporaryDocFile(document.file) as tmpfile: self.assertItemsEqual( expected_org_role_properties.items(), read_properties(tmpfile.path)) self.assert_doc_properties_updated_journal_entry_generated(document)