summaryrefslogtreecommitdiffhomepage
path: root/test/unit/status.py
diff options
context:
space:
mode:
authorKonstantin Pavlov <thresh@nginx.com>2022-09-13 13:17:16 +0400
committerKonstantin Pavlov <thresh@nginx.com>2022-09-13 13:17:16 +0400
commitce964aa30b163e2b3263c5af57c1a6dae7d0cebb (patch)
tree26bf70c1a5991f6471fc4caed8628e068fdc0b7b /test/unit/status.py
parenteba4c3c98fa1bf275d94df8c727f70692ae7eae1 (diff)
parent38bd7e76a134084ab95a4ee3125af1ccd7b35864 (diff)
downloadunit-1.28.0-1.tar.gz
unit-1.28.0-1.tar.bz2
Merged with the default branch.1.28.0-1
Diffstat (limited to 'test/unit/status.py')
-rw-r--r--test/unit/status.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/unit/status.py b/test/unit/status.py
new file mode 100644
index 00000000..17416f17
--- /dev/null
+++ b/test/unit/status.py
@@ -0,0 +1,45 @@
+from unit.control import TestControl
+
+
+class Status:
+ _status = None
+ control = TestControl()
+
+ def _check_zeros():
+ assert Status.control.conf_get('/status') == {
+ 'connections': {
+ 'accepted': 0,
+ 'active': 0,
+ 'idle': 0,
+ 'closed': 0,
+ },
+ 'requests': {'total': 0},
+ 'applications': {},
+ }
+
+ def init(status=None):
+ Status._status = (
+ status if status is not None else Status.control.conf_get('/status')
+ )
+
+ def diff():
+ def find_diffs(d1, d2):
+ if isinstance(d1, dict) and isinstance(d2, dict):
+ return {
+ k: find_diffs(d1.get(k, 0), d2.get(k, 0))
+ for k in d1
+ if k in d2
+ }
+ else:
+ return d1 - d2
+
+ return find_diffs(Status.control.conf_get('/status'), Status._status)
+
+ def get(path='/'):
+ path = path.split('/')[1:]
+ diff = Status.diff()
+
+ for p in path:
+ diff = diff[p]
+
+ return diff