Exemple #1
0
 def test_valid_number_passed_in_request(self):
     bottle.request.environ = {'QUERY_STRING': 'offset=2'}
     kwargs = {}
     rest.validate_range_values(bottle.request, 'offset', kwargs)
     self.assertEqual(2, kwargs['offset'])
     self.assertEqual(200, bottle.response.status_code)
Exemple #2
0
 def test_nothing_provided_is_valid_but_none(self):
     bottle.request.environ = {'QUERY_STRING': ''}
     kwargs = {}
     rest.validate_range_values(bottle.request, 'offset', kwargs)
     self.assertEqual(None, kwargs.get('offset'))
     self.assertEqual(200, bottle.response.status_code)
Exemple #3
0
 def test_valid_number_passed_in_param(self):
     bottle.request.environ = {'QUERY_STRING': ''}
     kwargs = {'limit': '4236'}
     rest.validate_range_values(bottle.request, 'limit', kwargs)
     self.assertEqual(4236, kwargs['limit'])
     self.assertEqual(200, bottle.response.status_code)
Exemple #4
0
 def test_non_numeric_is_invalid(self):
     bottle.request.environ = {'QUERY_STRING': 'limit=blah'}
     kwargs = {}
     with self.assertRaises(ValueError):
         rest.validate_range_values(bottle.request, 'limit', kwargs)
Exemple #5
0
 def test_value_too_large(self):
     bottle.request.environ = {'QUERY_STRING': 'offset=20000000'}
     kwargs = {}
     with self.assertRaises(ValueError):
         rest.validate_range_values(bottle.request, 'offset', kwargs)
Exemple #6
0
 def test_value_too_large(self):
     bottle.request.environ = {'QUERY_STRING': 'offset=20000000'}
     kwargs = {}
     with self.assertRaises(ValueError):
         rest.validate_range_values(bottle.request, 'offset', kwargs)
Exemple #7
0
 def test_negative_is_invalid(self):
     bottle.request.environ = {'QUERY_STRING': 'offset=-2'}
     kwargs = {}
     with self.assertRaises(ValueError):
         rest.validate_range_values(bottle.request, 'offset', kwargs)
Exemple #8
0
 def test_non_numeric_is_invalid(self):
     bottle.request.environ = {'QUERY_STRING': 'limit=blah'}
     kwargs = {}
     with self.assertRaises(ValueError):
         rest.validate_range_values(bottle.request, 'limit', kwargs)
Exemple #9
0
 def test_negative_is_invalid(self):
     bottle.request.environ = {'QUERY_STRING': 'offset=-2'}
     kwargs = {}
     with self.assertRaises(ValueError):
         rest.validate_range_values(bottle.request, 'offset', kwargs)
Exemple #10
0
 def test_valid_number_passed_in_request(self):
     bottle.request.environ = {'QUERY_STRING': 'offset=2'}
     kwargs = {}
     rest.validate_range_values(bottle.request, 'offset', kwargs)
     self.assertEqual(2, kwargs['offset'])
     self.assertEqual(200, bottle.response.status_code)
Exemple #11
0
 def test_valid_number_passed_in_param(self):
     bottle.request.environ = {'QUERY_STRING': ''}
     kwargs = {'limit': '4236'}
     rest.validate_range_values(bottle.request, 'limit', kwargs)
     self.assertEqual(4236, kwargs['limit'])
     self.assertEqual(200, bottle.response.status_code)
Exemple #12
0
 def test_nothing_provided_is_valid_but_none(self):
     bottle.request.environ = {'QUERY_STRING': ''}
     kwargs = {}
     rest.validate_range_values(bottle.request, 'offset', kwargs)
     self.assertEqual(None, kwargs.get('offset'))
     self.assertEqual(200, bottle.response.status_code)