Пример #1
0
    def test_min_exclusive_max_exclusive(self):
        validator = validate.Range(min=10,
                                   max=20,
                                   min_inclusive=False,
                                   max_inclusive=False)
        validator(11)
        validator(19)

        with pytest.raises(ValidationException) as excinfo:
            validator(10)
        assert "Must be greater than 10 and less than 20." in str(
            excinfo.value)

        with pytest.raises(ValidationException) as excinfo:
            validator(20)
        assert "Must be greater than 10 and less than 20." in str(
            excinfo.value)

        with pytest.raises(ValidationException) as excinfo:
            validator(5)
        assert "Must be greater than 10 and less than 20." in str(
            excinfo.value)

        with pytest.raises(ValidationException) as excinfo:
            validator(25)

        assert "Must be greater than 10 and less than 20." in str(
            excinfo.value)
Пример #2
0
    def test_min_inclusive_max_inclusive(self):
        validator = validate.Range(min=10, max=20)
        validator(10)
        validator(20)
        validator(15)
        with pytest.raises(ValidationException) as excinfo:
            validator(5)
        assert (
            "Must be greater than or equal to 10 and less than or equal to 20."
            in str(excinfo.value))

        with pytest.raises(ValidationException) as excinfo:
            validator(25)

        assert (
            "Must be greater than or equal to 10 and less than or equal to 20."
            in str(excinfo.value))
Пример #3
0
 def test_max_with_inclusive_limit_and_lower_value(self):
     validator = validate.Range(max=10)
     validator(5)
Пример #4
0
 def test_min_with_inclusive_limit_and_higher_value(self):
     validator = validate.Range(min=10)
     validator(15)
Пример #5
0
 def test_min_with_inclusive_limit_and_lower_value(self):
     validator = validate.Range(min=10)
     with pytest.raises(ValidationException) as excinfo:
         validator(5)
     assert "Must be greater than or equal to 10." in str(excinfo.value)
Пример #6
0
 def test_max_with_inclusive_limit_and_higher_value(self):
     with pytest.raises(ValidationException) as excinfo:
         validator = validate.Range(max=10)
         validator(15)
     assert "Must be less than or equal to 10." in str(excinfo.value)