diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2018-01-30 16:16:52 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2018-01-30 16:16:52 +0300 |
commit | 9f48f2b3e78d268c39dbd772a0a0f9ef07530846 (patch) | |
tree | 31192ccbf0d89b9b31e473a39195cb7477a780e5 /test/unit.py | |
parent | f115cb7032dc0a2a2fa5ef6f66167efdd6b93544 (diff) | |
download | unit-9f48f2b3e78d268c39dbd772a0a0f9ef07530846.tar.gz unit-9f48f2b3e78d268c39dbd772a0a0f9ef07530846.tar.bz2 |
Tests: added methods to manage unit configuration.
Diffstat (limited to 'test/unit.py')
-rw-r--r-- | test/unit.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/test/unit.py b/test/unit.py index 38c001ba..c17038eb 100644 --- a/test/unit.py +++ b/test/unit.py @@ -149,6 +149,18 @@ class TestUnitControl(TestUnit): # TODO socket reuse # TODO http client + def conf(self, conf, path='/'): + if isinstance(conf, dict): + conf = json.dumps(conf) + + return self._body_json(self.put(path, conf)) + + def conf_get(self, path='/'): + return self._body_json(self.get(path)) + + def conf_delete(self, path='/'): + return self._body_json(self.delete(path)) + def http(self, req): with self._control_sock() as sock: sock.sendall(req) @@ -167,13 +179,13 @@ class TestUnitControl(TestUnit): resp = self.http(('GET ' + path + ' HTTP/1.1\r\nHost: localhost\r\n\r\n').encode()) - return self._body_json(resp) + return resp def delete(self, path='/'): resp = self.http(('DELETE ' + path + ' HTTP/1.1\r\nHost: localhost\r\n\r\n').encode()) - return self._body_json(resp) + return resp def put(self, path='/', data=''): if isinstance(data, str): @@ -183,7 +195,7 @@ class TestUnitControl(TestUnit): + 'Content-Length: ' + str(len(data)) + '\r\n\r\n').encode() + data) - return self._body_json(resp) + return resp def _control_sock(self): sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) |