diff options
Diffstat (limited to 'test/functional/lib')
-rw-r--r-- | test/functional/lib/rspamd.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/functional/lib/rspamd.py b/test/functional/lib/rspamd.py index c40ac588c..4da8712a3 100644 --- a/test/functional/lib/rspamd.py +++ b/test/functional/lib/rspamd.py @@ -1,3 +1,4 @@ +import demjson import grp import os import os.path @@ -17,6 +18,16 @@ try: from urllib.request import urlopen except: from urllib2 import urlopen +try: + import http.client as httplib +except: + import httplib + +def Check_JSON(j): + d = demjson.decode(j, strict=True) + assert len(d) > 0 + assert 'error' not in d + return d def cleanup_temporary_directory(directory): shutil.rmtree(directory) @@ -49,6 +60,15 @@ def get_rspamadm(): dname = get_top_dir() return dname + "/src/rspamadm/rspamadm" +def HTTP(method, host, port, path, data=None, headers={}): + c = httplib.HTTPConnection("%s:%s" % (host, port)) + c.request(method, path, data, headers) + r = c.getresponse() + t = r.read() + s = r.status + c.close() + return [s, t] + def make_temporary_directory(): return tempfile.mkdtemp() |