def test_when_validating_edit_then_calls_common_and_edit_validators(self): common = Mock(Validator) edit = Mock(Validator) model = Mock() validator = ValidationGroup(common=[common], edit=[edit]) validator.validate_edit(model) common.validate.assert_called_once_with(model) edit.validate.assert_called_once_with(model)
def test_when_validating_delete_then_calls_common_and_delete_validators( self): common = Mock(Validator) delete = Mock(Validator) model = Mock() validator = ValidationGroup(common=[common], delete=[delete]) validator.validate_delete(model) common.validate.assert_called_once_with(model) delete.validate.assert_called_once_with(model)
def build_validator(): destination_validators = { 'agent': [GetResource('agent_id', agent_dao.get, 'Agent')], 'bsfilter': [ ResourceExists('filter_member_id', call_filter_dao.member_exists, 'FilterMember') ], 'conference': [GetResource('conference_id', conference_dao.get, 'Conference')], 'custom': [CustomValidator()], 'forward': [ForwardValidator()], 'group': [GetResource('group_id', group_dao.get, 'Group')], 'groupmember': [GetResource('group_id', group_dao.get, 'Group')], 'onlinerec': [], 'paging': [GetResource('paging_id', paging_dao.get, 'Paging')], 'park_position': [ParkPositionValidator(feature_dao)], 'parking': [], 'queue': [GetResource('queue_id', queue_dao.get, 'Queue')], 'service': [], 'transfer': [], 'user': [GetResource('user_id', user_dao.get, 'User')], } funckey_validator = FuncKeyModelValidator(destination_validators) mapping_validator = FuncKeyMappingValidator(funckey_validator) similar_validator = SimilarFuncKeyValidator() private_template_validator = PrivateTemplateValidator() return ValidationGroup( common=[mapping_validator, similar_validator], delete=[private_template_validator], )
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, ], )
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')), ], )
def build_validator(): return ValidationGroup( create=[UniqueField('interface', find_by_interface, 'CustomEndpoint')], edit=[ UniqueFieldChanged('interface', custom_dao.find_by, 'CustomEndpoint') ], )
def build_validator(): return ValidationGroup( create=[ UniqueField('name', lambda name: outcall_dao.find_by(name=name), 'Outcall') ], edit=[UniqueFieldChanged('name', outcall_dao.find_by, 'Outcall')], )
def build_validator(): return ValidationGroup( create=[ UniqueField( 'name', lambda name: call_pickup_dao.find_by(name=name), 'CallPickup' ) ], edit=[ Optional('name', UniqueFieldChanged('name', call_pickup_dao, 'CallPickup')) ], )
def build_validator(): moh_validator = MohModelValidator() return ValidationGroup( create=[ UniqueField('name', lambda name: moh_dao.find_by(name=name), 'MOH'), moh_validator, ], edit=[moh_validator], )
def build_validator(): return ValidationGroup( create=[ UniqueField('name', lambda name: group_dao.find_by(name=name), 'Group'), GroupValidator(), ], edit=[ Optional('name', UniqueFieldChanged('name', group_dao, 'Group')), GroupValidator(), ], )
def build_validator(): return ValidationGroup( create=[ UniqueField( 'name', lambda name, tenant_uuids: skill_dao.find_by( name=name, tenant_uuids=tenant_uuids), 'Skill', ) ], edit=[UniqueFieldChanged('name', skill_dao.find_by, 'Skill')], )
def build_validator(): return ValidationGroup( create=[ UniqueField('name', lambda name: queue_dao.find_by(name=name), 'Queue'), QueueValidator(), ], edit=[ Optional('name', UniqueFieldChanged('name', queue_dao, 'Queue')), QueueValidator(), ], )
def build_validator(): return ValidationGroup( create=[ UniqueField('number', lambda number: agent_dao.find_by(number=number), 'Agent') ], edit=[ Optional('number', UniqueFieldChanged('number', agent_dao, 'Agent')) ], )
def build_validator(): return ValidationGroup( create=[ UniqueField('number', lambda number: paging_dao.find_by(number=number), 'Paging') ], edit=[ Optional( 'number', UniqueFieldChanged('number', paging_dao.find_by, 'Paging')) ], )
def build_validator(): return ValidationGroup( create=[ Optional( 'name', UniqueField('name', lambda value: iax_dao.find_by(name=value), 'IAXEndpoint'), ) ], edit=[ Optional('name', UniqueFieldChanged('name', iax_dao, 'IAXEndpoint')) ], )
def build_validator(registrar_dao): return ValidationGroup( create=[ Optional('provisioning_code', ProvCodeAvailable(line_dao)), Optional('registrar', GetResource('registrar', registrar_dao.get, 'Registrar')), GetResource('context', context_dao.get_by_name, 'Context'), ], edit=[ ProvCodeChanged(line_dao), GetResource('registrar', registrar_dao.get, 'Registrar'), GetResource('context', context_dao.get_by_name, 'Context'), ], )
def build_validator(): return ValidationGroup( create=[ Optional( 'name', UniqueField('name', lambda v: sip_dao.find_by(name=v), 'SIPEndpoint'), ) ], edit=[ Optional('name', UniqueFieldChanged('name', sip_dao, 'SIPEndpoint')) ], )
def build_validator(): return ValidationGroup( common=[ GetResource('context', context_dao.get_by_name, 'Context'), Optional( 'timezone', MemberOfSequence('timezone', static_voicemail.find_all_timezone, 'Timezone'), ), ], create=[NumberContextExists(voicemail_dao)], edit=[NumberContextChanged(voicemail_dao)], delete=[AssociatedToUser()], )
def build_validator(): return ValidationGroup( create=[ UniqueField('name', lambda name: call_filter_dao.find_by(name=name), 'CallFilter') ], edit=[ Optional( 'name', UniqueFieldChanged('name', call_filter_dao.find_by, 'CallFilter'), ) ], )
def build_validator(): return ValidationGroup( create=[ UniqueField('name', lambda name: context_dao.find_by(name=name), 'Context') ], delete=[ ContextDeleteValidator( agent_login_status_dao_module, extension_dao_module, trunk_dao_module, voicemail_dao_module, ) ], )
def build_validator(): return ValidationGroup( create=[ UniqueField( 'name', lambda name, tenant_uuids: call_permission_dao.find_by( name=name, tenant_uuids=tenant_uuids), 'CallPermission', ) ], edit=[ UniqueFieldChanged('name', call_permission_dao.find_by, 'CallPermission'), ], )
def build_validator_forward(): return ValidationGroup(edit=[ Optional( 'busy_enabled', NoEmptyFieldWhenEnabled('busy_destination', 'busy_enabled'), ), Optional( 'noanswer_enabled', NoEmptyFieldWhenEnabled('noanswer_destination', 'noanswer_enabled'), ), Optional( 'unconditional_enabled', NoEmptyFieldWhenEnabled('unconditional_destination', 'unconditional_enabled'), ), ])
def build_validator(): moh_validator = MOHExists('music_on_hold', moh_dao.get_by) return ValidationGroup( create=[ UniqueField('name', lambda name: queue_dao.find_by(name=name), 'Queue'), QueueValidator(), WaitDestinationValidator(), moh_validator, ], edit=[ Optional('name', UniqueFieldChanged('name', queue_dao.find_by, 'Queue')), QueueValidator(), WaitDestinationValidator(), moh_validator, ], )
def build_validator(): return ValidationGroup( create=[ Optional( 'context', GetResource('context', context_dao_module.get_by_name, 'Context'), ), ContextTenantValidator(context_dao_module), ], edit=[ Optional( 'context', GetResource('context', context_dao_module.get_by_name, 'Context'), ), ContextTenantValidator(context_dao_module), ], )
def build_validator(device_dao, line_dao): return ValidationGroup( common=[ Optional( 'plugin', MemberOfSequence('plugin', device_dao.plugins, 'Plugin') ), Optional( 'template_id', MemberOfSequence( 'template_id', device_dao.device_templates, 'DeviceTemplate' ), ), ], create=[ Optional( 'mac', UniqueField('mac', lambda mac: device_dao.find_by(mac=mac), 'Device'), ) ], edit=[Optional('mac', UniqueFieldChanged('mac', device_dao.find_by, 'Device'))], delete=[DeviceNotAssociated(line_dao)], )
def build_validator(): return ValidationGroup( common=[GetResource('context', context_dao_module.get_by_name, 'Context')], create=[ ExtenAvailableOnCreateValidator( extension_dao_module, parking_lot_dao_module ), ExtenRegexValidator(context_dao_module), ], edit=[ ExtenAvailableOnUpdateValidator( extension_dao_module, parking_lot_dao_module ), ContextOnUpdateValidator(context_dao_module), ExtensionRangeValidator(context_dao_module), ExtenRegexValidator(context_dao_module), SameTenantValidator(context_dao_module), ], delete=[ ExtensionAssociationValidator( extension_dao_module, line_extension_dao_module ) ], )
def build_validator(): moh_validator = MOHExists('music_on_hold', moh_dao.get_by) return ValidationGroup( create=[moh_validator], edit=[SlotsAvailableValidator(), moh_validator], )
def build_service_callservice(): return UserCallServiceService(user_dao, ValidationGroup(), build_notifier_service())
def build_validator(): incall_validator = IncallModelValidator(DestinationValidator()) return ValidationGroup(create=[incall_validator], edit=[incall_validator])
def build_validator(): fallbacks_validator = GroupFallbackValidator(DestinationValidator()) return ValidationGroup(edit=[fallbacks_validator])