예제 #1
0
 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__()
예제 #2
0
 def test_positive_negative_input(self):
     assert_raises(ValueError, lambda: inputs.positive(-1))
예제 #3
0
 def test_positive_zero(self):
     assert_raises(ValueError, lambda: inputs.positive(0))
예제 #4
0
 def test_positive(self):
     assert_equal(1, inputs.positive(1))
     assert_equal(10000, inputs.positive(10000))
예제 #5
0
 def test_positive_negative_input(self):
     assert_raises(ValueError, lambda: inputs.positive(-1))
예제 #6
0
 def test_positive_zero(self):
     assert_raises(ValueError, lambda: inputs.positive(0))
예제 #7
0
 def test_positive(self):
     assert_equal(1, inputs.positive(1))
     assert_equal(10000, inputs.positive(10000))
예제 #8
0
def type_positive(value):
    return inputs.positive(value)