Skip to content

Commit

Permalink
add meta data and tests for nestedmachine
Browse files Browse the repository at this point in the history
  • Loading branch information
aleneum committed May 24, 2024
1 parent ac12663 commit 9391100
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions tests/test_imports.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
def test_imports() -> None:
from transitions_gui import WebMachine, NestedWebMachine
from transitions_gui import __version__, __uri__, __license__, __copyright__, __summary__
20 changes: 15 additions & 5 deletions tests/test_web.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from unittest import TestCase
from transitions_gui import WebMachine
from transitions_gui import WebMachine, NestedWebMachine
import time
import threading
from websocket import create_connection
Expand All @@ -14,10 +14,14 @@

class TestWebMachine(TestCase):

def setUp(self):
self.machine = None

def tearDown(self):
assert self.machine._thread is not None
self.machine.stop_server()
time.sleep(_INIT_DELAY)
if self.machine is not None:
assert self.machine._thread is not None
self.machine.stop_server()
time.sleep(_INIT_DELAY)

def test_server(self):
self.machine = WebMachine(**_SIMPLE_ARGS) # type: ignore
Expand Down Expand Up @@ -59,7 +63,7 @@ def test_client_transition(self):
time.sleep(_INIT_DELAY)
ws = create_connection(f"ws://localhost:{self.machine.port}/ws")
_ = ws.recv()
self.machine.next_state()
assert self.machine.next_state()
answer = json.loads(ws.recv())
assert answer["method"] == "state_changed"
config = answer["arg"]
Expand All @@ -84,3 +88,9 @@ def test_receive_message(self):
time.sleep(_INIT_DELAY)
assert self.machine.state != _SIMPLE_ARGS["initial"]
ws.close()

def test_hsm(self):
self.machine = NestedWebMachine(**_SIMPLE_ARGS) # type: ignore
time.sleep(_INIT_DELAY)
assert self.machine.next_state()
assert self.machine.state != _SIMPLE_ARGS["initial"]
6 changes: 6 additions & 0 deletions transitions_gui/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
from .version import __version__
from .web import WebMachine, NestedWebMachine

__copyright__ = "Copyright (c) 2024 Alexander Neumann"
__license__ = "MIT"
__summary__ = "A frontend for transitions state machines"
__uri__ = "https://github.com/pytransitions/transitions-gui"
6 changes: 6 additions & 0 deletions transitions_gui/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
from .web import NestedWebMachine as NestedWebMachine, WebMachine as WebMachine
from .version import __version__ as __version__

__copyright__: str
__license__: str
__summary__: str
__uri__: str

0 comments on commit 9391100

Please sign in to comment.