diff options
Diffstat (limited to 'test/unit/control.py')
-rw-r--r-- | test/unit/control.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/unit/control.py b/test/unit/control.py new file mode 100644 index 00000000..c4cfc4ce --- /dev/null +++ b/test/unit/control.py @@ -0,0 +1,48 @@ +import json +from unit.http import TestHTTP + + +class TestControl(TestHTTP): + + # TODO socket reuse + # TODO http client + + def conf(self, conf, path='/config'): + if isinstance(conf, dict) or isinstance(conf, list): + conf = json.dumps(conf) + + if path[:1] != '/': + path = '/config/' + path + + return json.loads( + self.put( + url=path, + body=conf, + sock_type='unix', + addr=self.testdir + '/control.unit.sock', + )['body'] + ) + + def conf_get(self, path='/config'): + if path[:1] != '/': + path = '/config/' + path + + return json.loads( + self.get( + url=path, + sock_type='unix', + addr=self.testdir + '/control.unit.sock', + )['body'] + ) + + def conf_delete(self, path='/config'): + if path[:1] != '/': + path = '/config/' + path + + return json.loads( + self.delete( + url=path, + sock_type='unix', + addr=self.testdir + '/control.unit.sock', + )['body'] + ) |