'Test phone number validation with international notation requirement'

def testInternationalFormat(self):

    settings = current.deployment_settings
    current_setting = settings.get_msg_require_international_phone_numbers()
    assertEqual = self.assertEqual
    assertNotEqual = self.assertNotEqual
    validate = IS_PHONE_NUMBER(international=True)
    settings.msg.require_international_phone_numbers = True
    number = '+46-73-3847589'
    (value, error) = validate(number)
    assertEqual(error, None)
    assertEqual(value, '+46733847589')
    number = '+49.681.5049321'
    (value, error) = validate(number)
    assertEqual(error, None)
    assertEqual(value, '+496815049321')
    number = '+1992883742'
    (value, error) = validate(number)
    assertEqual(error, None)
    assertEqual(value, '+1992883742')
    number = '(021)    36374589'
    (value, error) = validate(number)
    assertNotEqual(error, None)
    number = 'Test'
    (value, error) = validate(number)
    assertNotEqual(error, None)
    number = '1-364-283745'
    (value, error) = validate(number)
    assertNotEqual(error, None)
    number = None
    (value, error) = validate(number)
    assertNotEqual(error, None)
    number = ''
    (value, error) = validate(number)
    assertNotEqual(error, None)
    settings.msg.require_international_phone_numbers = False
    number = '1-364-283745'
    (value, error) = validate(number)
    assertEqual(error, None)
    assertEqual(value, '1-364-283745')
    settings.msg.require_international_phone_numbers = current_setting
