コード例 #1
0
    def test_value_mismatch(self):
        val = va.is_money()
        model = MyModel()
        model.prop = 'sdfads'

        valid, error = val(model, 'prop')

        assert not valid
        assert error == (msg.INVALID_VALUE,)
コード例 #2
0
    def test_none(self):
        val = va.is_money()
        model = MyModel()
        model.prop = None

        valid, error = val(model, 'prop')

        assert valid
        assert error is None
コード例 #3
0
    def test_not_allow_zero(self):
        val = va.is_money(allow_zero=False)
        model = MyModel()
        model.prop = Decimal('0.0')

        valid, error = val(model, 'prop')

        assert not valid
        assert error == (msg.NOT_ZERO,)
コード例 #4
0
    def test_negative(self):
        val = va.is_money()
        model = MyModel()
        model.prop = Decimal('-12.33')

        valid, error = val(model, 'prop')

        assert not valid
        assert error == (msg.POSITIVE_VALUE,)
コード例 #5
0
    def test_is_money(self):
        val = va.is_money()
        model = MyModel()
        model.prop = Decimal('12.33')

        valid, error = val(model, 'prop')

        assert valid
        assert error is None