Beispiel #1
0
 def test_filters(self):
     request = bottle.BaseRequest(
         environ={'QUERY_STRING': 'status=A&status=B,C&other=2'})
     expected = {'status': ['A', 'B', 'C'], 'other': '2'}
     results = rest.process_params(request,
                                   filter_fields=['status', 'other'])
     self.assertEqual(results, expected)
Beispiel #2
0
 def test_dfaults(self):
     request = bottle.BaseRequest(
         environ={'QUERY_STRING': 'status=INACTIVE'})
     defaults = {'status': 'ACTIVE', 'size': 1}
     results = rest.process_params(request,
                                   filter_fields=defaults.keys(),
                                   defaults=defaults)
     self.assertEqual(results, {'status': 'INACTIVE', 'size': 1})
Beispiel #3
0
 def test_dfaults(self):
     request = bottle.BaseRequest(environ={
         'QUERY_STRING': 'status=INACTIVE'
     })
     defaults = {'status': 'ACTIVE', 'size': 1}
     results = rest.process_params(request, filter_fields=defaults.keys(),
                                   defaults=defaults)
     self.assertEqual(results, {'status': 'INACTIVE', 'size': 1})
Beispiel #4
0
 def test_filters(self):
     request = bottle.BaseRequest(environ={
         'QUERY_STRING': 'status=A&status=B,C&other=2'
     })
     expected = {'status': ['A', 'B', 'C'], 'other': '2'}
     results = rest.process_params(request,
                                   filter_fields=['status', 'other'])
     self.assertEqual(results, expected)
Beispiel #5
0
 def test_strange(self):
     request = bottle.BaseRequest(environ={'QUERY_STRING': ',,\n??&&'})
     with self.assertRaises(bottle.HTTPError):
         rest.process_params(request)
Beispiel #6
0
 def test_blank(self):
     request = bottle.BaseRequest(environ={'QUERY_STRING': ''})
     results = rest.process_params(request)
     self.assertEqual(results, {})
Beispiel #7
0
 def test_invalid(self):
     request = bottle.BaseRequest(environ={'QUERY_STRING': 'foo=bar'})
     with self.assertRaises(bottle.HTTPError):
         rest.process_params(request)
Beispiel #8
0
 def test_text(self):
     request = bottle.BaseRequest(environ={'QUERY_STRING': 'q=txt'})
     results = rest.process_params(request)
     self.assertEqual(results, {'q': ['txt']})
Beispiel #9
0
 def test_standard(self):
     request = bottle.BaseRequest(
         environ={'QUERY_STRING': 'limit=100&offset=0&facets=status'})
     results = rest.process_params(request)
     self.assertEqual(results, {})
Beispiel #10
0
 def test_sort(self):
     request = bottle.BaseRequest(
         environ={'QUERY_STRING': 'sort=up&sort=-down'})
     expected = {'sort': ['up', '-down']}
     self.assertEqual(rest.process_params(request), expected)
Beispiel #11
0
 def test_strange(self):
     request = bottle.BaseRequest(environ={
         'QUERY_STRING': ',,\n??&&'
     })
     with self.assertRaises(bottle.HTTPError):
         rest.process_params(request)
Beispiel #12
0
 def test_blank(self):
     request = bottle.BaseRequest(environ={
         'QUERY_STRING': ''
     })
     results = rest.process_params(request)
     self.assertEqual(results, {})
Beispiel #13
0
 def test_invalid(self):
     request = bottle.BaseRequest(environ={
         'QUERY_STRING': 'foo=bar'
     })
     with self.assertRaises(bottle.HTTPError):
         rest.process_params(request)
Beispiel #14
0
 def test_standard(self):
     request = bottle.BaseRequest(environ={
         'QUERY_STRING': 'limit=100&offset=0&q=txt&facets=status'
     })
     results = rest.process_params(request)
     self.assertEqual(results, {})
Beispiel #15
0
 def test_sort(self):
     request = bottle.BaseRequest(environ={
         'QUERY_STRING': 'sort=up&sort=-down'
     })
     expected = {'sort': ['up', '-down']}
     self.assertEqual(rest.process_params(request), expected)
Beispiel #16
0
 def test_text(self):
     request = bottle.BaseRequest(environ={
         'QUERY_STRING': 'q=txt'
     })
     results = rest.process_params(request)
     self.assertEqual(results, {'q': ['txt']})