Пример #1
0
    def test_clean_fail_duplicate_parameter_keys(self):
        parameter = Parameter(key="foo", optional=False)
        command = Command(name="foo", parameters=[parameter, parameter])

        with pytest.raises(ModelValidationError):
            command.clean()
Пример #2
0
 def test_clean_fail_duplicate_parameter_keys(self):
     nested = Parameter(key="foo")
     with pytest.raises(ModelValidationError):
         Parameter(key="foo", optional=False, parameters=[nested,
                                                          nested]).clean()
Пример #3
0
 def test_clean(self):
     Command(name="foo", parameters=[Parameter(key="foo",
                                               optional=False)]).clean()
Пример #4
0
 def test_clean_fail_nullable_optional_but_no_default(self):
     with pytest.raises(ModelValidationError):
         Parameter(key="foo", optional=True, default=None,
                   nullable=False).clean()
Пример #5
0
 def test_clean(self):
     Parameter(key="foo", optional=False).clean()
Пример #6
0
 def test_default_display_name(self):
     p = Parameter(key="foo")
     assert p.display_name == "foo"
Пример #7
0
 def test_repr(self):
     p = Parameter(key="foo",
                   description="bar",
                   type="Boolean",
                   optional=False)
     assert repr(p) == "<Parameter: key=foo, type=Boolean, description=bar>"
Пример #8
0
 def test_str(self):
     p = Parameter(key="foo",
                   description="bar",
                   type="Boolean",
                   optional=False)
     assert str(p) == "foo"