From 1ff844062df1b315f984b27781eba8fb49371501 Mon Sep 17 00:00:00 2001 From: kdmukai Date: Sun, 12 Mar 2023 12:59:12 -0500 Subject: [PATCH] Cleanup, beginning to split requirements.txt --- requirements-raspi.txt | 3 +++ requirements.txt | 3 --- src/seedsigner/views/seed_views.py | 2 +- tests/base.py | 10 +++++++--- tests/test_flows_settings.py | 26 +------------------------- 5 files changed, 12 insertions(+), 32 deletions(-) create mode 100644 requirements-raspi.txt diff --git a/requirements-raspi.txt b/requirements-raspi.txt new file mode 100644 index 00000000..8053eeab --- /dev/null +++ b/requirements-raspi.txt @@ -0,0 +1,3 @@ +picamera==1.13 +RPi.GPIO==0.7.0 +spidev==3.5 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 34cf5663..e24650d4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/src/seedsigner/views/seed_views.py b/src/seedsigner/views/seed_views.py index 9e45a1f7..f796a93f 100644 --- a/src/seedsigner/views/seed_views.py +++ b/src/seedsigner/views/seed_views.py @@ -270,7 +270,7 @@ class SeedReviewPassphraseView(View): fingerprint_without = self.seed.get_fingerprint(network=network) self.seed.set_passphrase(passphrase) - # Because we have ane explicit "Edit" button, we disable "BACK" to keep the + # Because we have an explicit "Edit" button, we disable "BACK" to keep the # routing options sane. selected_menu_num = self.run_screen( seed_screens.SeedReviewPassphraseScreen, diff --git a/tests/base.py b/tests/base.py index 48e97738..568f8d30 100644 --- a/tests/base.py +++ b/tests/base.py @@ -119,14 +119,18 @@ class FlowTest(BaseTest): with patch(qualname + ".run_screen") as mock_run_screen: next_destination._instantiate_view() - if flow_step.run_before: - flow_step.run_before(next_destination.view) - + # A few Views need to reference their Screen; need to mock it out + # since we're not actually instantiating it. + next_destination.view.screen = MagicMock() + if flow_step.button_data_selection: mock_run_screen.return_value = next_destination.view.button_data.index(flow_step.button_data_selection) else: mock_run_screen.return_value = flow_step.screen_return_value + if flow_step.run_before: + flow_step.run_before(next_destination.view) + # Now we can run the View and grab its resulting next Destination next_destination = next_destination._run_view() except Exception as e: diff --git a/tests/test_flows_settings.py b/tests/test_flows_settings.py index fd373ff1..8c68d36a 100644 --- a/tests/test_flows_settings.py +++ b/tests/test_flows_settings.py @@ -19,10 +19,6 @@ class TestSettingsFlows(FlowTest): # Which option are we testing? settings_entry = SettingsDefinition.get_settings_entry(SettingsConstants.SETTING__PERSISTENT_SETTINGS) - def mock_settingsmenuview_screen(view: Type[View]): - # SettingsMenuView reaches into its `self.screen` so we need to mock it out - view.screen = MagicMock() - destination = self.run_sequence( Destination(MainMenuView), sequence=[ @@ -31,7 +27,6 @@ class TestSettingsFlows(FlowTest): ), FlowStep( expected_view=settings_views.SettingsMenuView, - run_before=mock_settingsmenuview_screen, button_data_selection=settings_entry.display_name ), FlowStep( @@ -52,10 +47,6 @@ class TestSettingsFlows(FlowTest): # Which option are we testing? settings_entry = SettingsDefinition.get_settings_entry(SettingsConstants.SETTING__COORDINATORS) - def mock_settingsmenuview_screen(view: Type[View]): - # SettingsMenuView reaches into its `self.screen` so we need to mock it out - view.screen = MagicMock() - destination = self.run_sequence( Destination(MainMenuView), sequence=[ @@ -64,7 +55,6 @@ class TestSettingsFlows(FlowTest): ), FlowStep( expected_view=settings_views.SettingsMenuView, - run_before=mock_settingsmenuview_screen, button_data_selection=settings_entry.display_name ), FlowStep( @@ -90,10 +80,6 @@ class TestSettingsFlows(FlowTest): def test_io_test(self): """ Basic flow from MainMenuView to I/O Test View """ - def mock_settingsmenuview_screen(view: Type[View]): - # SettingsMenuView reaches into its `self.screen` so we need to mock it out - view.screen = MagicMock() - destination = self.run_sequence( Destination(MainMenuView), sequence=[ @@ -102,7 +88,6 @@ class TestSettingsFlows(FlowTest): ), FlowStep( expected_view=settings_views.SettingsMenuView, - run_before=mock_settingsmenuview_screen, button_data_selection=settings_views.SettingsMenuView.IO_TEST ), FlowStep( @@ -116,15 +101,7 @@ class TestSettingsFlows(FlowTest): def test_donate(self): - """ Basic flow from MainMenuView to Donate View """ - # DonateView will be the nth_entry after we include the submenu to "Advanced" - # and the I/O Test - nth_entry = len(SettingsDefinition.get_settings_entries()) + 2 - - def mock_settingsmenuview_screen(view: Type[View]): - # SettingsMenuView reaches into its `self.screen` so we need to mock it out - view.screen = MagicMock() - + """ Basic flow from MainMenuView to Donate View """ destination = self.run_sequence( Destination(MainMenuView), sequence=[ @@ -133,7 +110,6 @@ class TestSettingsFlows(FlowTest): ), FlowStep( expected_view=settings_views.SettingsMenuView, - run_before=mock_settingsmenuview_screen, button_data_selection=settings_views.SettingsMenuView.DONATE ), FlowStep(