From 254614e9f77e108d186ff3f7e89ec78012af65a1 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 2 Jun 2016 18:10:36 +1200 Subject: [PATCH] Since we have locks over the logs, use direct access rather than API requests to get to them --- pathod/test.py | 8 +++----- test/pathod/test_app.py | 2 +- test/pathod/test_pathod.py | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pathod/test.py b/pathod/test.py index 797b49703..0804951e7 100644 --- a/pathod/test.py +++ b/pathod/test.py @@ -75,16 +75,13 @@ class Daemon: """ Return the log buffer as a list of dictionaries. """ - resp = requests.get("%s/api/log" % self.urlbase, verify=False) - return resp.json()["log"] + return self.thread.server.get_log() def clear_log(self): """ Clear the log. """ - self.logfp.truncate(0) - resp = requests.get("%s/api/clear_log" % self.urlbase, verify=False) - return resp.ok + return self.thread.server.clear_log() def shutdown(self): """ @@ -101,6 +98,7 @@ class _PaThread(threading.Thread): self.name = "PathodThread" self.iface, self.q, self.ssl = iface, q, ssl self.daemonargs = daemonargs + self.server = None def run(self): self.server = pathod.Pathod( diff --git a/test/pathod/test_app.py b/test/pathod/test_app.py index ac89c44c1..7f691485f 100644 --- a/test/pathod/test_app.py +++ b/test/pathod/test_app.py @@ -27,7 +27,7 @@ class TestApp(tutils.DaemonTests): def test_log(self): assert self.getpath("/log").status_code == 200 assert self.get("200:da").status_code == 200 - id = self.d.log()[0]["id"] + id = self.d.expect_log(1)[0]["id"] assert self.getpath("/log").status_code == 200 assert self.getpath("/log/%s" % id).status_code == 200 assert self.getpath("/log/9999999").status_code == 404 diff --git a/test/pathod/test_pathod.py b/test/pathod/test_pathod.py index 5773a3c9a..9916984ec 100644 --- a/test/pathod/test_pathod.py +++ b/test/pathod/test_pathod.py @@ -142,11 +142,10 @@ class CommonTests(tutils.DaemonTests): assert tuple(self.d.info()["version"]) == version.IVERSION def test_logs(self): - assert self.d.clear_log() - assert not self.d.last_log() + self.d.clear_log() assert self.get("202:da") - assert len(self.d.log()) == 1 - assert self.d.clear_log() + assert self.d.expect_log(1) + self.d.clear_log() assert len(self.d.log()) == 0 def test_disconnect(self):