aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional/lib/rspamd.py
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2016-08-03 11:38:45 +0100
committerAndrew Lewis <nerf@judo.za.org>2016-08-03 11:39:10 +0100
commitc1c49ce51d25138a94a41a23452e078a660f1248 (patch)
tree3a48261dd03ecefd2c717d4623caa8332cf0ab75 /test/functional/lib/rspamd.py
parentaa1a1c9c09f33cc1e12a874e3577126579397756 (diff)
downloadrspamd-c1c49ce51d25138a94a41a23452e078a660f1248.tar.gz
rspamd-c1c49ce51d25138a94a41a23452e078a660f1248.zip
[Test] Some basic tests for JSON sanity
Diffstat (limited to 'test/functional/lib/rspamd.py')
-rw-r--r--test/functional/lib/rspamd.py20
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()