def __init__(self): self.reqparse = reqparse.RequestParser() self.reqparse.add_argument( 'course', type=inputs.positive(), required=True, help='No course provided', location=['form', 'json'] ) self.reqparse.add_argument( 'rating', input=inputs.int_range(1,5), required=True, help='No rating provided', location=['form', 'json'] ) self.reqparse.add_argument( 'comment', nullable=True, required=False, location=['form', 'json'], default='' ) super().__init__()
def test_positive_negative_input(self): assert_raises(ValueError, lambda: inputs.positive(-1))
def test_positive_zero(self): assert_raises(ValueError, lambda: inputs.positive(0))
def test_positive(self): assert_equal(1, inputs.positive(1)) assert_equal(10000, inputs.positive(10000))
def type_positive(value): return inputs.positive(value)