1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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']
)
|