Skip to content

Commit

Permalink
Merge pull request #339 from kdmukai/test_flows
Browse files Browse the repository at this point in the history
[Enhancement] Enable flow-based test scenarios
  • Loading branch information
newtonick authored Jul 20, 2023
2 parents 2a27989 + 94abdd3 commit ffc281f
Show file tree
Hide file tree
Showing 21 changed files with 1,515 additions and 475 deletions.
1 change: 1 addition & 0 deletions docs/manual_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ cd seedsigner
```bash
# Takes 1hr 45min on a Pi Zero 1.3
pip install -r requirements.txt
pip install -r requirements-raspi.txt
```

#### `pyzbar`
Expand Down
3 changes: 3 additions & 0 deletions requirements-raspi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
picamera==1.13
RPi.GPIO==0.7.0
spidev==3.5
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
embit==0.7.0
numpy==1.21.1
picamera==1.13
Pillow==8.2.0
-e git+https://github.com/seedsigner/pyzbar.git@c3c237821c6a20b17953efe59b90df0b514a1c03#egg=pyzbar
qrcode==7.3.1
RPi.GPIO==0.7.0
six==1.16.0
spidev==3.5
urtypes @ git+https://github.com/selfcustody/urtypes.git@7fb280eab3b3563dfc57d2733b0bf5cbc0a96a6a
44 changes: 42 additions & 2 deletions src/seedsigner/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ def __repr__(self):



class StopFlowBasedTest(Exception):
"""
This is a special exception that is only raised by the test suite to stop the
Controller's main loop. It should not be raised by any other code.
"""
pass


class FlowBasedTestException(Exception):
"""
This is a special exception that is only raised by the test suite.
It should not be raised by any other code.
"""
pass



class Controller(Singleton):
"""
The Controller is a globally available singleton that maintains SeedSigner state.
Expand Down Expand Up @@ -185,7 +202,13 @@ def clear_back_stack(self):
self.back_stack = BackStack()


def start(self) -> None:
def start(self, initial_destination: Destination = None) -> None:
"""
The main loop of the application.
* initial_destination: The first View to run. If None, the MainMenuView is
used. Only used by the test suite.
"""
from .views import MainMenuView, BackStackView
from .views.screensaver import OpeningSplashScreen

Expand Down Expand Up @@ -218,7 +241,10 @@ def run(self):
View_cls(**init_args).run()
"""
try:
next_destination = Destination(MainMenuView)
if initial_destination:
next_destination = initial_destination
else:
next_destination = Destination(MainMenuView)
while True:
# Destination(None) is a special case; render the Home screen
if next_destination.View_cls is None:
Expand All @@ -240,10 +266,24 @@ def run(self):
print(f"back_stack: {self.back_stack}")

try:
# Instantiate the View class and run it
print(f"Executing {next_destination}")
next_destination = next_destination.run()

except StopFlowBasedTest:
# This is a special exception that is only raised by the test suite
# to stop the Controller loop and exit the test.
return

except FlowBasedTestException as e:
# This is a special exception that is only raised by the test suite.
# Re-raise so the test suite can handle it.
raise e

except Exception as e:
# Display user-friendly error screen w/debugging info
import traceback
traceback.print_exc()
next_destination = self.handle_exception(e)

if not next_destination:
Expand Down
2 changes: 1 addition & 1 deletion src/seedsigner/models/settings_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class SettingsEntry:
visibility: str = SettingsConstants.VISIBILITY__GENERAL
type: str = SettingsConstants.TYPE__ENABLED_DISABLED
help_text: str = None
selection_options: List[str] = None
selection_options: list[tuple[str | int], str] = None
default_value: Any = None

def __post_init__(self):
Expand Down
Loading

0 comments on commit ffc281f

Please sign in to comment.