From a43903f93a5a084bd856dba61949a0460bcb2ed9 Mon Sep 17 00:00:00 2001 From: ctosullivan <75556293+ctosullivan@users.noreply.github.com> Date: Mon, 14 Oct 2024 20:22:49 +0200 Subject: [PATCH] Minor bug fixes - ex30 fsm solution --- ex30_fsm/socket_fsm.py | 10 +++++----- ex30_fsm/test_fsm.py | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ex30_fsm/socket_fsm.py b/ex30_fsm/socket_fsm.py index 67b33f0..d5e4a07 100644 --- a/ex30_fsm/socket_fsm.py +++ b/ex30_fsm/socket_fsm.py @@ -25,9 +25,9 @@ def ACCEPTED(self, event): if event == "close": return "CLOSED" elif event == "read": - return "READING"(event) + return self.READING(event) elif event == "write": - return "WRITING"(event) + return self.WRITING(event) else: return "ERROR" @@ -35,7 +35,7 @@ def READING(self, event): if event == "read": return "READING" elif event == "write": - return "WRITING"(event) + return self.WRITING(event) elif event == "close": return "CLOSED" else: @@ -43,7 +43,7 @@ def READING(self, event): def WRITING(self, event): if event == "read": - return "READING"(event) + return self.READING(event) elif event == "write": return "WRITING" elif event == "close": @@ -52,7 +52,7 @@ def WRITING(self, event): return "ERROR" def CLOSED(self, event): - return "LISTENING"(event) + return self.LISTENING(event) def ERROR(self, event): return "ERROR" diff --git a/ex30_fsm/test_fsm.py b/ex30_fsm/test_fsm.py index 50e94d0..d4ccc32 100644 --- a/ex30_fsm/test_fsm.py +++ b/ex30_fsm/test_fsm.py @@ -3,9 +3,10 @@ def test_basic_connection(): fsm = SocketFSM() + fsm.handle("start") script = ["connect", "accept", "read", "read", "write", "close", "connect"] for event in script: - print(event, ">>>", fsm) + print(event, ">>>", fsm.state_name) fsm.handle(event) - + assert fsm.state_name == "CONNECTED" \ No newline at end of file