code cleanup

* funcs internal to test_funcs shouldn't start with "test"
* comments in test modules preferred to repeating comments in code
* type hinting in code preferred to explaining w/ comments
This commit is contained in:
Jean Do
2023-07-07 09:51:47 -04:00
parent e25de29a64
commit 35b3dc65cd
3 changed files with 12 additions and 14 deletions
+1 -3
View File
@@ -707,10 +707,8 @@ class SeedExportXpubDetailsView(View):
selected_menu_num = 0
else:
# imported locally instead of at module level to avoid flow-test warnings: "comparing int to MagicMock"
from seedsigner.gui.screens.screen import LoadingScreenThread
# The derivation calc takes a few moments. Run the loading screen while we wait.
from seedsigner.gui.screens.screen import LoadingScreenThread
self.loading_screen = LoadingScreenThread(text="Generating xpub...")
self.loading_screen.start()
+1 -1
View File
@@ -26,7 +26,7 @@ class BaseTest:
# Ensure there are no on-disk artifacts after running tests.
Settings.SETTINGS_FILENAME = "settings-test.json"
# Mock out the loading screen so it can't spawn.
# Mock out the loading screen so it can't spawn. View classes must import locally!
patch('seedsigner.gui.screens.screen.LoadingScreenThread').start()
+10 -10
View File
@@ -96,7 +96,7 @@ class TestSeedFlows(FlowTest):
Selecting "Export XPUB" from the SeedOptionsView should enter the Export XPUB flow and end at the MainMenuView
"""
def test_standard_xpubs(sig_tuple, script_tuple, coord_tuple):
def flowtest_standard_xpub(sig_tuple, script_tuple, coord_tuple):
self.run_sequence(
initial_destination_view_args=dict(seed_num=0),
sequence=[
@@ -116,10 +116,10 @@ class TestSeedFlows(FlowTest):
self.controller.storage.set_pending_seed(Seed(mnemonic=mnemonic))
self.controller.storage.finalize_pending_seed()
# these are (constant_value, display_name) tuples
sig_types = SettingsConstants.ALL_SIG_TYPES
script_types = SettingsConstants.ALL_SCRIPT_TYPES
coordinators = SettingsConstants.ALL_COORDINATORS
# these are lists of (constant_value, display_name) tuples
sig_types: list[tuple[str, str]] = SettingsConstants.ALL_SIG_TYPES
script_types: list[tuple[str, str]] = SettingsConstants.ALL_SCRIPT_TYPES
coordinators: list[tuple[str, str]] = SettingsConstants.ALL_COORDINATORS
# enable non-defaults so they're available in views
self.settings.set_value(SettingsConstants.SETTING__SIG_TYPES, [x for x,y in sig_types])
@@ -138,7 +138,7 @@ class TestSeedFlows(FlowTest):
continue
else:
print('\n\ntest_standard_xpubs(%s, %s, %s)' % (sig_tuple, script_tuple, coord_tuple))
test_standard_xpubs(sig_tuple, script_tuple, coord_tuple)
flowtest_standard_xpub(sig_tuple, script_tuple, coord_tuple)
def test_export_xpub_disabled_not_available_flow(self):
@@ -150,10 +150,10 @@ class TestSeedFlows(FlowTest):
self.controller.storage.set_pending_seed(Seed(mnemonic=mnemonic))
self.controller.storage.finalize_pending_seed()
# these are (constant_value, display_name) tuples
sig_types = SettingsConstants.ALL_SIG_TYPES
script_types = SettingsConstants.ALL_SCRIPT_TYPES
coordinators = SettingsConstants.ALL_COORDINATORS
# these are lists of (constant_value, display_name) tuples
sig_types: list[tuple[str, str]] = SettingsConstants.ALL_SIG_TYPES
script_types: list[tuple[str, str]] = SettingsConstants.ALL_SCRIPT_TYPES
coordinators: list[tuple[str, str]] = SettingsConstants.ALL_COORDINATORS
# these are the disabled types that we will be testing
disabled_sig = SettingsConstants.MULTISIG