예제 #1
0
    def test_enum_string_parameter(self):
        p = params.EnumStringParameter(name='test1',
                                       description='test1_description',
                                       is_required=False,
                                       enum_values=['value1', 'value2'])

        test_matrix = [('value1', 'value1'), ('value2', 'value2'),
                       ('value3', False), ('value1,value2', False),
                       (' ', False), ('', False)]

        self.run_matrix_test(test_matrix, p)
예제 #2
0
    def test_linked(self):
        p1 = params.EnumStringParameter(
            name="attribute",
            description="Testing123",
            enum_values=["a", "b"],
            is_required=True,
        )
        p2 = params.SimpleStringParameter(
            name="downstream",
            validator=LinkedValidator(
                discriminator_parameter="attribute",
                default_validator=TypeValidator("string"),
                value_map={
                    "a": BooleanStringValidator(),
                    "b": IntegerValidator()
                },
            ),
            description="test123",
        )

        print(p2.validator.validation_criteria())

        # p1.set_value('a')
        p2.validator.inject_discriminator(None)
        test_matrix = [
            ("true", "true"),
            ("blah", "blah"),  # p1 not set, so uses default
        ]
        self.run_matrix_test(test_matrix, p2)

        p1._param_value = None
        p2._param_value = None
        p2.validator.inject_discriminator("a")
        p1.set_value("a")
        test_matrix = [
            ("true", "true"),
            ("blah", False),  # should fail now that p1 has a value
        ]

        self.run_matrix_test(test_matrix, p2)

        p1._param_value = None
        p2._param_value = None
        p1.set_value("b")
        p2.validator.inject_discriminator("b")
        test_matrix = [("true", False), ("blah", False), ("123", "123")]

        self.run_matrix_test(test_matrix, p2)
예제 #3
0
    def test_enum_string_parameter(self):
        p = params.EnumStringParameter(
            name="test1",
            description="test1_description",
            is_required=False,
            enum_values=["value1", "value2"],
        )

        test_matrix = [
            ("value1", "value1"),
            ("value2", "value2"),
            ("value3", False),
            ("value1,value2", False),
            (" ", False),
            ("", False),
        ]

        self.run_matrix_test(test_matrix, p)