Commit 0c375a2a authored by Georgios Dagkakis's avatar Georgios Dagkakis

testERP5Base: add a test to check reachability_workflow and coordinate_interaction_workflow

for Coordinates

Test also checks accessors like getDefaultEmailValidationState.
parent 97b65690
...@@ -1460,6 +1460,202 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -1460,6 +1460,202 @@ class TestERP5Base(ERP5TypeTestCase):
], ],
) )
def test_CoordinateReachability(self):
'''
Check the reachability_workflow and coordinate_interaction_workflow
for Coordinates.
Test also checks accessors like getDefaultEmailValidationState.
'''
portal_type = 'Person'
person_module = self.portal.getDefaultModule(portal_type)
person = person_module.newContent(portal_type=portal_type)
# Address
address = person.newContent(portal_type='Address')
self.assertEqual(address.getValidationState(), 'reachable')
address.declareUnreachable()
self.assertEqual(address.getValidationState(), 'unreachable')
address.setStreetAddress('Rue Nationale')
self.assertEqual(address.getValidationState(), 'reachable')
self.tic()
address.declareUnreachable()
self.assertEqual(address.getValidationState(), 'unreachable')
address.setZipCode('59000')
self.assertEqual(address.getValidationState(), 'reachable')
self.tic()
address.declareUnreachable()
self.assertEqual(address.getValidationState(), 'unreachable')
address.setCity('Lille')
self.assertEqual(address.getValidationState(), 'reachable')
self.tic()
address.declareUnreachable()
self.assertEqual(address.getValidationState(), 'unreachable')
address.setRegionValue(self.portal.portal_categories.region.europe.france)
self.assertEqual(address.getValidationState(), 'reachable')
self.tic()
address.declareUnreachable()
self.assertEqual(address.getValidationState(), 'unreachable')
address.edit(zip_code='59160', street_address='Rue Victor Hugo')
self.assertEqual(address.getValidationState(), 'reachable')
# this address is not default coordinate, in deletion id should remain as is
address_id = address.getId()
address.delete()
self.assertEqual(address.getValidationState(), 'deleted')
self.tic()
self.assertEqual(address.getId(), address_id)
# Telephone
person.setMobileTelephoneCoordinateText('+12345')
telephone = person.mobile_telephone
self.assertEqual(person.getMobileTelephoneValidationState(), 'reachable')
self.tic()
telephone.declareUnreachable()
self.assertEqual(person.getMobileTelephoneValidationState(), 'unreachable')
telephone.setTelephoneCountry('33')
self.assertEqual(person.getMobileTelephoneValidationState(), 'reachable')
self.tic()
telephone.declareUnreachable()
self.assertEqual(person.getMobileTelephoneValidationState(), 'unreachable')
telephone.setTelephoneArea('0')
self.assertEqual(person.getMobileTelephoneValidationState(), 'reachable')
self.tic()
telephone.declareUnreachable()
self.assertEqual(person.getMobileTelephoneValidationState(), 'unreachable')
telephone.setTelephoneCity('07')
self.assertEqual(person.getMobileTelephoneValidationState(), 'reachable')
self.tic()
telephone.declareUnreachable()
self.assertEqual(person.getMobileTelephoneValidationState(), 'unreachable')
telephone.setTelephoneNumber('12345678')
self.assertEqual(person.getMobileTelephoneValidationState(), 'reachable')
self.tic()
telephone.declareUnreachable()
self.assertEqual(person.getMobileTelephoneValidationState(), 'unreachable')
telephone.setTelephoneExtension('0')
self.assertEqual(person.getMobileTelephoneValidationState(), 'reachable')
self.tic()
telephone.declareUnreachable()
self.assertEqual(person.getMobileTelephoneValidationState(), 'unreachable')
telephone.edit(telephone_country='30', telephone_number='12345670')
self.assertEqual(person.getMobileTelephoneValidationState(), 'reachable')
self.tic()
telephone.declareUnreachable()
telephone.setCoordinateText('+33-123.456.789')
self.assertEqual(person.getMobileTelephoneValidationState(), 'reachable')
self.tic()
telephone.declareUnreachable()
telephone.setMobileTelephoneCoordinateText('+33-123.456.780')
self.assertEqual(person.getMobileTelephoneValidationState(), 'reachable')
self.tic()
telephone.declareUnreachable()
telephone.edit(coordinate_text='+33-789 456 123 ')
self.assertEqual(person.getMobileTelephoneValidationState(), 'reachable')
# Check also that id we change a non-coordinate nothing happens
self.tic()
telephone.declareUnreachable()
telephone.edit(description="This must be old number", title="telephone")
self.assertEqual(person.getMobileTelephoneValidationState(), 'unreachable')
# this telephone is default coordinate, in deletion id should chenge
telephone.delete()
self.assertEqual(telephone.getValidationState(), 'deleted')
self.assertNotEqual(telephone.getId(), 'mobile_telephone')
# Fax
person.setFaxCoordinateText('+12345')
fax = person.default_fax
self.assertEqual(person.getDefaultFaxValidationState(), 'reachable')
self.tic()
fax.declareUnreachable()
self.assertEqual(person.getDefaultFaxValidationState(), 'unreachable')
fax.setTelephoneCountry('33')
self.assertEqual(person.getDefaultFaxValidationState(), 'reachable')
self.tic()
fax.declareUnreachable()
self.assertEqual(person.getDefaultFaxValidationState(), 'unreachable')
fax.setTelephoneArea('0')
self.assertEqual(person.getDefaultFaxValidationState(), 'reachable')
self.tic()
fax.declareUnreachable()
self.assertEqual(person.getDefaultFaxValidationState(), 'unreachable')
fax.setTelephoneCity('07')
self.assertEqual(person.getDefaultFaxValidationState(), 'reachable')
self.tic()
fax.declareUnreachable()
self.assertEqual(person.getDefaultFaxValidationState(), 'unreachable')
fax.setTelephoneNumber('12345678')
self.assertEqual(person.getDefaultFaxValidationState(), 'reachable')
self.tic()
fax.declareUnreachable()
self.assertEqual(person.getDefaultFaxValidationState(), 'unreachable')
fax.setTelephoneExtension('0')
self.assertEqual(person.getDefaultFaxValidationState(), 'reachable')
self.tic()
fax.declareUnreachable()
self.assertEqual(person.getDefaultFaxValidationState(), 'unreachable')
fax.setDefaultFaxTelephoneExtension('0')
self.assertEqual(person.getDefaultFaxValidationState(), 'reachable')
# this fax is default coordinate, in deletion id should chenge
fax.delete()
self.assertEqual(fax.getValidationState(), 'deleted')
self.assertNotEqual(fax.getId(), 'default_fax')
# Email
person.setDefaultEmailCoordinateText('test@mail1.com')
email = person.default_email
self.assertEqual(person.getDefaultEmailValidationState(), 'reachable')
self.tic()
email.declareUnreachable()
self.assertEqual(person.getDefaultEmailValidationState(), 'unreachable')
email.setCoordinateText('test@mail2.com')
self.assertEqual(person.getDefaultEmailValidationState(), 'reachable')
self.tic()
email.declareUnreachable()
self.assertEqual(person.getDefaultEmailValidationState(), 'unreachable')
person.setDefaultEmailCoordinateText('test@mail3.com')
self.assertEqual(person.getDefaultEmailValidationState(), 'reachable')
# this email is default coordinate, in deletion id should chenge
email.delete()
self.assertEqual(email.getValidationState(), 'deleted')
self.assertNotEqual(email.getId(), 'default_email')
# External Identifier
external_identifier = person.newContent(portal_type='External Identifier')
self.assertEqual(external_identifier.getValidationState(), 'reachable')
self.tic()
external_identifier.declareUnreachable()
self.assertEqual(external_identifier.getValidationState(), 'unreachable')
external_identifier.setCoordinateText('test')
self.assertEqual(external_identifier.getValidationState(), 'reachable')
# this external_identifier is not default coordinate, in deletion id should remain as is
external_identifier_id = external_identifier.getId()
external_identifier.delete()
self.assertEqual(external_identifier.getValidationState(), 'deleted')
self.tic()
self.assertEqual(external_identifier.getId(), external_identifier_id)
# Link
link = person.newContent(portal_type='Link')
self.assertEqual(link.getValidationState(), 'reachable')
self.tic()
link.declareUnreachable()
self.assertEqual(link.getValidationState(), 'unreachable')
link.setUrlString('www.dummy-link.com')
self.assertEqual(link.getValidationState(), 'reachable')
# this link is not default coordinate, in deletion id should remain as is
link_id = link.getId()
link.delete()
self.assertEqual(link.getValidationState(), 'deleted')
self.tic()
self.assertEqual(link.getId(), link_id)
# Chat Address
chat_address = person.newContent(portal_type='Chat Address')
self.assertEqual(chat_address.getValidationState(), 'reachable')
self.tic()
chat_address.declareUnreachable()
self.assertEqual(chat_address.getValidationState(), 'unreachable')
chat_address.setUrlString('www.dummy-chat.com')
self.assertEqual(chat_address.getValidationState(), 'reachable')
# this link is not default coordinate, in deletion id should remain as is
chat_address_id = chat_address.getId()
chat_address.delete()
self.assertEqual(chat_address.getValidationState(), 'deleted')
self.tic()
self.assertEqual(chat_address.getId(), chat_address_id)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Base)) suite.addTest(unittest.makeSuite(TestERP5Base))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment