Ejemplo n.º 1
0
    def test_given_label_with_invalid_characters_when_validating_then_raises_error(
        self, ):
        model = FuncKey(label='hello\n', destination=Mock(type='foobar'))

        assert_that(
            calling(self.validator.validate_with_tenant_uuids).with_args(
                model, self.tenant_uuids),
            raises(InputError),
        )

        model = FuncKey(label='\rhello', destination=Mock(type='foobar'))

        assert_that(
            calling(self.validator.validate_with_tenant_uuids).with_args(
                model, self.tenant_uuids),
            raises(InputError),
        )

        model = FuncKey(label='hel;lo', destination=Mock(type='foobar'))

        assert_that(
            calling(self.validator.validate_with_tenant_uuids).with_args(
                model, self.tenant_uuids),
            raises(InputError),
        )
Ejemplo n.º 2
0
    def test_when_template_has_two_func_keys_with_different_destination_then_validation_passes(
        self, ):
        template = FuncKeyTemplate(
            keys={
                1: FuncKey(destination=FuncKeyDestCustom(exten='1234')),
                2: FuncKey(destination=FuncKeyDestService(
                    service='enablednd')),
            })

        self.validator.validate(template)
Ejemplo n.º 3
0
    def test_when_template_has_two_func_keys_with_same_destination_then_raises_error(
        self, ):
        destination = FuncKeyDestCustom(exten='1234')
        template = FuncKeyTemplate(
            keys={
                1: FuncKey(destination=destination),
                2: FuncKey(destination=destination),
            })

        assert_that(
            calling(self.validator.validate).with_args(template),
            raises(ResourceError))
Ejemplo n.º 4
0
    def test_given_no_validator_for_destination_when_validating_then_raises_error(
            self):
        destination = Mock(type='spam')

        model = FuncKey(destination=destination)

        assert_that(
            calling(self.validator.validate).with_args(model),
            raises(InputError))
Ejemplo n.º 5
0
    def test_given_multiple_validators_for_destination_when_validating_then_calls_each_validator(
        self, ):
        destination = Mock(type='foobar')
        model = FuncKey(destination=destination)

        self.validator.validate(model)

        self.first_dest_validator.validate.assert_called_once_with(destination)
        self.second_dest_validator.validate.assert_called_once_with(
            destination)
Ejemplo n.º 6
0
    def test_when_template_has_a_single_func_key_then_validation_passes(self):
        funckey = FuncKey(destination=FuncKeyDestCustom(exten='1234'))
        template = FuncKeyTemplate(keys={1: funckey})

        self.validator.validate(template)
Ejemplo n.º 7
0
    def test_when_func_key_does_not_have_bsfilter_destination_then_validation_passes(
        self, ):
        funckey = FuncKey(destination=FuncKeyDestCustom(exten='1234'))

        self.validator.validate(self.user, funckey)
Ejemplo n.º 8
0
    def setUp(self):
        self.user = User(id=sentinel.user_id)
        self.funckey = FuncKey(destination=FuncKeyDestBSFilter(
            filter_member_id=sentinel.filter_member_id))

        self.validator = BSFilterValidator()