예제 #1
0
def build_validator():
    moh_validator = MOHExists('music_on_hold', moh_dao.get_by)
    return ValidationGroup(
        delete=[NoVoicemailAssociated(),
                NoLineAssociated(user_line_dao)],
        create=[
            Optional(
                'email',
                UniqueField('email',
                            lambda email: user_dao.find_by(email=email),
                            'User'),
            ),
            Optional(
                'username',
                UniqueField(
                    'username',
                    lambda username: user_dao.find_by(username=username),
                    'User',
                ),
            ),
            moh_validator,
        ],
        edit=[
            Optional('email',
                     UniqueFieldChanged('email', user_dao.find_by, 'User')),
            Optional('username',
                     UniqueFieldChanged('username', user_dao.find_by, 'User')),
            moh_validator,
        ],
    )
예제 #2
0
def build_validator():
    return ValidationGroup(
        delete=[NoVoicemailAssociated(),
                NoLineAssociated(user_line_dao)],
        create=[
            Optional(
                'email',
                UniqueField('email',
                            lambda email: user_dao.find_by(email=email),
                            'User'),
            ),
            Optional(
                'username',
                UniqueField(
                    'username',
                    lambda username: user_dao.find_by(username=username),
                    'User',
                ),
            ),
        ],
        edit=[
            Optional('email', UniqueFieldChanged('email', user_dao, 'User')),
            Optional('username',
                     UniqueFieldChanged('username', user_dao, 'User')),
        ],
    )
예제 #3
0
    def test_find_by_private_template_id(self):
        user_row = self.add_user()

        user = user_dao.find_by(private_template_id=user_row.func_key_private_template_id)

        assert_that(user.id, equal_to(user_row.id))
        assert_that(user.func_key_private_template_id, equal_to(user_row.func_key_private_template_id))
예제 #4
0
 def _get_xivo_user_uuid_by_ldap_attribute(self, user_email):
     with session_scope():
         xivo_user = find_by(email=user_email)
         if not xivo_user:
             logger.warning('%s does not have an email associated with a XiVO user', user_email)
             return xivo_user
         return xivo_user.uuid
예제 #5
0
    def test_find_by_fullname(self):
        user_row = self.add_user(firstname='Jôhn', lastname='Smîth')

        user = user_dao.find_by(fullname='Jôhn Smîth')

        assert_that(user.id, equal_to(user_row.id))
        assert_that(user.firstname, equal_to('Jôhn'))
        assert_that(user.lastname, equal_to('Smîth'))
예제 #6
0
    def test_find_by_uuid(self):
        user_uuid = str(uuid.uuid4())
        user_row = self.add_user(uuid=user_uuid)

        user = user_dao.find_by(uuid=user_uuid)

        assert_that(user.id, equal_to(user_row.id))
        assert_that(user.uuid, equal_to(user_uuid))
예제 #7
0
def build_validator():
    return ValidationGroup(
        common=[
            RequiredFields('firstname'),
            Optional(
                'mobile_phone_number',
                RegexField.compile('mobile_phone_number',
                                   MOBILE_PHONE_NUMBER_REGEX)),
            Optional('caller_id',
                     RegexField.compile('caller_id', CALLER_ID_REGEX)),
            Optional('username',
                     RegexField.compile('username', USERNAME_PASSWORD_REGEX)),
            Optional('password',
                     RegexField.compile('password', USERNAME_PASSWORD_REGEX)),
            Optional(
                'call_permission_password',
                RegexField.compile('call_permission_password',
                                   CALL_PERMISSION_PASSWORD_REGEX)),
            Optional(
                'ring_seconds',
                NumberRange('ring_seconds', minimum=0, maximum=60, step=5)),
            Optional('simultaneous_calls',
                     NumberRange('simultaneous_calls', minimum=1, maximum=20)),
            Optional('language', RegexField.compile('language',
                                                    LANGUAGE_REGEX)),
            Optional(
                'entity_id',
                ResourceExists('entity_id', entity_db.entity_id_exists,
                               'Entity'))
        ],
        delete=[
            NoVoicemailAssociated(user_voicemail_dao),
            NoLineAssociated(user_line_dao)
        ],
        create=[
            Optional(
                'email',
                UniqueField('email',
                            lambda email: user_dao.find_by(email=email),
                            'User'))
        ],
        edit=[
            RequiredFields('call_transfer_enabled', 'call_record_enabled',
                           'online_call_record_enabled', 'supervision_enabled',
                           'ring_seconds', 'simultaneous_calls', 'caller_id',
                           'enabled'),
            Optional('email', UniqueFieldChanged('email', user_dao, 'User')),
        ])
예제 #8
0
    def test_that_email_address_is_case_insensitive_when_comparing(self):
        user_row = self.add_user(firstname='Pâul',
                                 lastname='Rôgers',
                                 callerid='"Côol dude"',
                                 outcallerid='"Côol dude going out"',
                                 loginclient='paulrogers',
                                 passwdclient='paulrogers',
                                 musiconhold='mymusic',
                                 mobilephonenumber='4185551234',
                                 commented=1,
                                 email='*****@*****.**',
                                 rightcallcode='1234',
                                 userfield='userfield',
                                 timezone='America/Montreal',
                                 language='fr_FR',
                                 description='Really cool dude',
                                 preprocess_subroutine='preprocess_subroutine')

        user = user_dao.find_by(email='*****@*****.**')

        assert_that(user_row.id, equal_to(user.id))
예제 #9
0
    def test_given_user_does_not_exist_then_returns_null(self):
        user = user_dao.find_by(firstname='42')

        assert_that(user, none())