示例#1
0
 def test_get_limit_not_int(self):
     self.assertEqual(
         app.DEFAULT_LIMIT,
         app._get_limit({
             "limit": "hello"
         }),
     )
示例#2
0
 def test_get_limit_ok(self):
     self.assertEqual(
         100,
         app._get_limit({
             "limit": "100"
         }),
     )
示例#3
0
 def test_get_limit_non_positive(self):
     for limit in (0, -1):
         self.assertEqual(
             app.DEFAULT_LIMIT,
             app._get_limit({
                 "limit": "%d" % limit,
             }),
         )
示例#4
0
 def test_get_limit_max(self):
     for limit in (app.MAX_LIMIT, app.MAX_LIMIT + 1):
         self.assertEqual(
             app.MAX_LIMIT,
             app._get_limit({
                 "limit": "%d" % limit,
             }),
         )
示例#5
0
    def test_get_limit_invalid_types(self):
        with self.assertRaises(TypeError):
            app._get_limit({"limit": None})

        with self.assertRaises(TypeError):
            app._get_limit({"limit": []})
示例#6
0
 def test_get_limit_no_limit_key(self):
     self.assertEqual(
         app.DEFAULT_LIMIT,
         app._get_limit({}),
     )
示例#7
0
 def test_get_limit_no_query_params(self):
     self.assertEqual(
         app.DEFAULT_LIMIT,
         app._get_limit(None),
     )