summaryrefslogtreecommitdiffhomepage
path: root/test/unit/control.py
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2019-03-28 18:43:13 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2019-03-28 18:43:13 +0300
commit19eba1730a1ca839ed62a37f34c204f580d1b653 (patch)
treee9f54ca64fc7db66e33350826c76ef3814cfa4a0 /test/unit/control.py
parent06b9a11494561e309114266bfe3bb001352b596c (diff)
downloadunit-19eba1730a1ca839ed62a37f34c204f580d1b653.tar.gz
unit-19eba1730a1ca839ed62a37f34c204f580d1b653.tar.bz2
Tests: unit module refactoring.
Diffstat (limited to 'test/unit/control.py')
-rw-r--r--test/unit/control.py48
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']
+ )