def test_get_limit_not_int(self): self.assertEqual( app.DEFAULT_LIMIT, app._get_limit({ "limit": "hello" }), )
def test_get_limit_ok(self): self.assertEqual( 100, app._get_limit({ "limit": "100" }), )
def test_get_limit_non_positive(self): for limit in (0, -1): self.assertEqual( app.DEFAULT_LIMIT, app._get_limit({ "limit": "%d" % limit, }), )
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, }), )
def test_get_limit_invalid_types(self): with self.assertRaises(TypeError): app._get_limit({"limit": None}) with self.assertRaises(TypeError): app._get_limit({"limit": []})
def test_get_limit_no_limit_key(self): self.assertEqual( app.DEFAULT_LIMIT, app._get_limit({}), )
def test_get_limit_no_query_params(self): self.assertEqual( app.DEFAULT_LIMIT, app._get_limit(None), )