diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_pathod.py | 9 | ||||
-rw-r--r-- | test/test_utils.py | 6 |
2 files changed, 14 insertions, 1 deletions
diff --git a/test/test_pathod.py b/test/test_pathod.py index d917e25c..8e1e7490 100644 --- a/test/test_pathod.py +++ b/test/test_pathod.py @@ -46,7 +46,8 @@ class _DaemonTests: self.d = test.Daemon( staticdir=tutils.test_data.path("data"), anchors=[("/anchor/.*", "202")], - ssl = self.SSL + ssl = self.SSL, + sizelimit=1*1024*1024 ) @classmethod @@ -73,6 +74,12 @@ class _DaemonTests: c.settimeout(timeout) return c.request(spec) + def test_sizelimit(self): + r = self.get("200:b@1g") + assert r.status_code == 800 + l = self.d.log()[0] + assert "too large" in l["response"]["error"] + def test_preline(self): v = self.pathoc(r"get:'/p/200':i0,'\r\n'") assert v[1] == 200 diff --git a/test/test_utils.py b/test/test_utils.py index 72c892f0..8ca2da49 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1,6 +1,12 @@ from libpathod import utils import tutils +def test_parse_size(): + assert utils.parse_size("100") == 100 + assert utils.parse_size("100k") == 100 * 1024 + tutils.raises("invalid size spec", utils.parse_size, "foo") + tutils.raises("invalid size spec", utils.parse_size, "100kk") + def test_parse_anchor_spec(): assert utils.parse_anchor_spec("foo=200") == ("foo", "200") |