Skip to content

Commit

Permalink
tests black
Browse files Browse the repository at this point in the history
  • Loading branch information
tadeubas committed Nov 20, 2023
1 parent 6f52a44 commit c46448b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions tests/pages/test_login.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from ..shared_mocks import mock_context


@pytest.fixture
def mocker_printer(mocker):
mocker.patch("krux.printers.thermal.AdafruitPrinter", new=mocker.MagicMock())
Expand Down
17 changes: 11 additions & 6 deletions tests/pages/test_settings_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

@pytest.fixture
def mocker_printer(mocker):
mocker.patch('krux.printers.thermal.AdafruitPrinter', new=mocker.MagicMock())
mocker.patch("krux.printers.thermal.AdafruitPrinter", new=mocker.MagicMock())


@pytest.fixture
def mocker_ucryptolib(mocker):
sys.modules['ucryptolib'] = mocker.MagicMock()
sys.modules["ucryptolib"] = mocker.MagicMock()


def create_ctx(mocker, btn_seq, touch_seq=None):
Expand Down Expand Up @@ -353,22 +354,26 @@ def test_encryption_pbkdf2_setting(m5stickv, mocker, mocker_ucryptolib):

ctx = mock_context(mocker)
settings_page = SettingsPage(ctx)

enc_setting = EncryptionSettings()

# pbkdf2_iterations has default value
assert Settings().encryption.pbkdf2_iterations == 100000

# try to change the value
settings_page.capture_from_keypad = mocker.MagicMock(return_value=100001)
settings_page.number_setting(EncryptionSettings(), EncryptionSettings.pbkdf2_iterations)
settings_page.number_setting(
EncryptionSettings(), EncryptionSettings.pbkdf2_iterations
)

# continue with default value because it must be multiple of 10000
assert Settings().encryption.pbkdf2_iterations == 100000

# try to changhe the value to a multiple of 10000
settings_page.capture_from_keypad = mocker.MagicMock(return_value=110000)
settings_page.number_setting(EncryptionSettings(), EncryptionSettings.pbkdf2_iterations)
settings_page.number_setting(
EncryptionSettings(), EncryptionSettings.pbkdf2_iterations
)

# value changed!
assert Settings().encryption.pbkdf2_iterations == 110000
assert Settings().encryption.pbkdf2_iterations == 110000

0 comments on commit c46448b

Please sign in to comment.