Skip to content

Commit

Permalink
Adds FlowTestUnexpectedRedirectException
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmukai committed Jul 15, 2024
1 parent 3205cdf commit 3957551
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ class FlowTestUnexpectedViewException(FlowBasedTestException):



class FlowTestUnexpectedRedirectException(FlowBasedTestException):
""" The Controller's current View triggered a redirect that was not expected by the current FlowStep in the sequence """
pass



class FlowTest(BaseTest):
""" Base class for any tests that do flow-based testing """

Expand Down Expand Up @@ -209,7 +215,7 @@ def run_view(destination: Destination, *args, **kwargs):
if mock_run_screen.call_count == prev_mock_run_screen_call_count and cur_flow_step.is_redirect is not True:
# The current View redirected without calling run_screen()
# but we weren't expecting it.
raise FlowTestUnexpectedViewException(f"Unexpected redirect to {destination.View_cls}")
raise FlowTestUnexpectedRedirectException(f"Unexpected redirect to {destination.View_cls}")

finally:
# Regardless of the outcome, we always move our FlowTest
Expand Down
8 changes: 4 additions & 4 deletions tests/test_flows.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

# Must import test base before the Controller
from base import FlowTest, FlowStep, FlowTestUnexpectedViewException, FlowTestInvalidButtonDataSelectionException
from base import FlowTest, FlowStep, FlowTestUnexpectedRedirectException, FlowTestUnexpectedViewException, FlowTestInvalidButtonDataSelectionException

from seedsigner.controller import Controller
from seedsigner.gui.screens.screen import RET_CODE__BACK_BUTTON, RET_CODE__POWER_BUTTON
Expand Down Expand Up @@ -68,11 +68,11 @@ def test_FlowTestInvalidButtonDataSelectionException(self):
])


def test_unexpected_redirect_flow(self):
def test_FlowTestUnexpectedRedirectException(self):
"""
If the FlowStep doesn't specify is_redirect when the View redirects, raise an exception.
If the FlowStep doesn't specify is_redirect when the View redirects, raise FlowTestUnexpectedRedirectException
"""
with pytest.raises(FlowTestUnexpectedViewException) as e:
with pytest.raises(FlowTestUnexpectedRedirectException) as e:
self.run_sequence([
FlowStep(SeedsMenuView, screen_return_value=0), # <-- No seeds loaded, so it'll redirect elsewhere
])
Expand Down

0 comments on commit 3957551

Please sign in to comment.