Skip to content

Commit f6fa83f

Browse files
committed
Add test for dblog crashed process
1 parent f6d43de commit f6fa83f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_dblog.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,32 @@ def test_status(self):
9191
assert s.uuid == "fbf3cd00-0102-11ed-8421-e4b97ac7e02e"
9292
assert s.data == "somedata"
9393

94+
def test_crashed_process(self):
95+
fake_process_status_data = {
96+
"process": {"uuid": "0cf3cd00-0102-11ed-8421-e4b97ac7e02e"},
97+
"status": {
98+
"status": "started",
99+
"time": "2022-07-11T17:07:18Z",
100+
"percent_done": "10",
101+
"message": "PyWPS Process Started"
102+
}
103+
}
104+
105+
dblog.log_request(fake_process_status_data["process"]["uuid"], fake_request)
106+
dblog.store_status(fake_process_status_data["process"]["uuid"], dblog.WPS_STATUS.STARTED, "accepted", 10)
107+
dblog.update_pid(fake_process_status_data["process"]["uuid"], -1) # some invalid pid
108+
dblog.update_status_record(fake_process_status_data["process"]["uuid"], fake_process_status_data)
109+
110+
s = dblog.get_status_record(fake_process_status_data["process"]["uuid"])
111+
assert s.uuid == fake_process_status_data["process"]["uuid"]
112+
assert s.data['status']['status'] == 'started'
113+
114+
dblog.cleanup_crashed_process()
115+
116+
s = dblog.get_status_record(fake_process_status_data["process"]["uuid"])
117+
assert s.uuid == fake_process_status_data["process"]["uuid"]
118+
assert s.data['status']['status'] == 'failed'
119+
94120

95121
def load_tests(loader=None, tests=None, pattern=None):
96122
"""Load local tests

0 commit comments

Comments
 (0)