mirror of
https://github.com/SeedSigner/seedsigner.git
synced 2026-10-05 15:08:25 +00:00
76 lines
3.0 KiB
Python
76 lines
3.0 KiB
Python
from mock import patch
|
|
|
|
# Must import test base before the Controller
|
|
from base import FlowTest, FlowStep
|
|
|
|
from seedsigner.controller import StopFlowBasedTest
|
|
from seedsigner.gui.screens.screen import RET_CODE__POWER_BUTTON
|
|
from seedsigner.models.settings import Settings
|
|
from seedsigner.views.tools_views import ToolsCalcFinalWordNumWordsView, ToolsMenuView
|
|
from seedsigner.views.view import MainMenuView, NotYetImplementedView, PowerOptionsView, PowerOffView, RestartView, UnhandledExceptionView, View
|
|
|
|
|
|
|
|
class TestViewFlows(FlowTest):
|
|
|
|
def test_restart_flow(self):
|
|
"""
|
|
Basic flow from MainMenuView to RestartView
|
|
"""
|
|
with patch('seedsigner.views.view.RestartView.DoResetThread'):
|
|
self.run_sequence([
|
|
FlowStep(MainMenuView, screen_return_value=RET_CODE__POWER_BUTTON),
|
|
FlowStep(PowerOptionsView, button_data_selection=PowerOptionsView.RESET),
|
|
FlowStep(RestartView, screen_return_value=StopFlowBasedTest()),
|
|
])
|
|
|
|
|
|
def test_power_off_flow(self):
|
|
"""
|
|
Basic flow from MainMenuView to PowerOffView
|
|
"""
|
|
with patch('seedsigner.views.view.PowerOffView.PowerOffThread'):
|
|
self.run_sequence([
|
|
FlowStep(MainMenuView, screen_return_value=RET_CODE__POWER_BUTTON),
|
|
FlowStep(PowerOptionsView, button_data_selection=PowerOptionsView.POWER_OFF),
|
|
FlowStep(PowerOffView, screen_return_value=StopFlowBasedTest()),
|
|
])
|
|
|
|
# And again, but this time as if we were in the SeedSigner OS
|
|
Settings.HOSTNAME = Settings.SEEDSIGNER_OS
|
|
self.run_sequence([
|
|
FlowStep(MainMenuView, screen_return_value=RET_CODE__POWER_BUTTON),
|
|
FlowStep(PowerOptionsView, button_data_selection=PowerOptionsView.POWER_OFF),
|
|
FlowStep(PowerOffView), # returns BackStackView
|
|
FlowStep(PowerOptionsView, screen_return_value=StopFlowBasedTest()),
|
|
])
|
|
|
|
|
|
def test_not_yet_implemented_flow(self):
|
|
"""
|
|
Run an incomplete View that returns None and ensure that we get the NotYetImplementedView
|
|
"""
|
|
class IncompleteView(View):
|
|
def run(self):
|
|
self.run_screen(None)
|
|
return None
|
|
|
|
self.run_sequence([
|
|
FlowStep(IncompleteView),
|
|
FlowStep(NotYetImplementedView),
|
|
FlowStep(MainMenuView, screen_return_value=StopFlowBasedTest()),
|
|
])
|
|
|
|
|
|
def test_unhandled_exception_flow(self):
|
|
"""
|
|
Basic flow from any arbitrary View to the UnhandledExceptionView
|
|
"""
|
|
self.run_sequence([
|
|
FlowStep(MainMenuView, button_data_selection=MainMenuView.TOOLS),
|
|
FlowStep(ToolsMenuView, button_data_selection=ToolsMenuView.KEYBOARD),
|
|
FlowStep(ToolsCalcFinalWordNumWordsView, screen_return_value=Exception("Test exception")), # <-- force an exception
|
|
FlowStep(UnhandledExceptionView),
|
|
FlowStep(MainMenuView, screen_return_value=StopFlowBasedTest()),
|
|
])
|