예제 #1
0
class TestSimilarFuncKeyValidator(unittest.TestCase):

    def setUp(self):
        self.validator = SimilarFuncKeyValidator()

    def test_when_template_empty_then_validation_passes(self):
        template = FuncKeyTemplate()

        self.validator.validate(template)

    def test_when_template_has_a_single_func_key_then_validation_passes(self):
        funckey = FuncKey(destination=CustomDestination(exten='1234'))
        template = FuncKeyTemplate(keys={1: funckey})

        self.validator.validate(template)

    def test_when_template_has_two_func_keys_with_different_destination_then_validation_passes(self):
        template = FuncKeyTemplate(keys={1: FuncKey(destination=CustomDestination(exten='1234')),
                                         2: FuncKey(destination=ServiceDestination(service='enablednd'))})

        self.validator.validate(template)

    def test_when_template_has_two_func_keys_with_same_destination_then_raises_error(self):
        destination = CustomDestination(exten='1234')
        template = FuncKeyTemplate(keys={1: FuncKey(destination=destination),
                                         2: FuncKey(destination=destination)})

        assert_that(calling(self.validator.validate).with_args(template),
                    raises(ResourceError))
예제 #2
0
 def setUp(self):
     self.validator = SimilarFuncKeyValidator()