Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.0.20 #109

Merged
merged 42 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
65bcb67
Adding better error screen when flash/wipe fails
qlrd Nov 1, 2024
bdd9d87
Fixed the tomli module mocking for python version <=10 in constants …
qlrd Nov 1, 2024
1e31918
coveraged detect_usermod_bin method on ask_permission_dialout_screen
qlrd Nov 2, 2024
8203af7
Merge branch 'selfcustody:main' into main
qlrd Nov 2, 2024
783909f
update test greetings_screen to be tested on macos mocking linux system
qlrd Nov 2, 2024
cddb4ac
update test ask_permission_dialout_screen to be tested on macos mocki…
qlrd Nov 2, 2024
cc43a97
coveraged 100% config_krux_installer
qlrd Nov 4, 2024
3a1f44e
coveraged 100% config_krux_installer II
qlrd Nov 4, 2024
fa3b5b5
coverated 100% ask_permission_dialout_screen
qlrd Nov 4, 2024
9c9372a
coveraged 100% main_screen
qlrd Nov 5, 2024
dbda0d3
added error redirection when no removables drives are found on air-ga…
qlrd Nov 5, 2024
ae9eed7
coveraged procedures that get drives on linux, mac and windows
qlrd Nov 6, 2024
6332e6e
fixed tests on windows
qlrd Nov 7, 2024
a973f1d
added coverage for warning_before_airgap_update_screen
qlrd Nov 11, 2024
a48e87c
fixed tests on linux
Nov 12, 2024
a199126
fixed tests on linux II
Nov 12, 2024
8c9da37
coverage 100% on airgap_update_screen
Nov 12, 2024
d57a127
coverage 100% on airgap_update_screen II
Nov 12, 2024
4556b60
coveraged 100% warning_after_airgap_update_screen
Nov 14, 2024
49e5154
coveraged 100% of unzip_stable_screen
qlrd Nov 14, 2024
9fb1060
coveraged some quit and back buttons on either flash and wipe screens
qlrd Nov 14, 2024
e0bee04
covered 99% of base_screen
qlrd Nov 15, 2024
e01f4f6
removed some unecessary graphical setups on wipe_screen tests
qlrd Nov 15, 2024
0729275
removed some unecessary graphical setups on wipe_screen tests II
Nov 15, 2024
5dfdde4
changed version to 0.0.20
Nov 15, 2024
50904c2
Covered hook exception on flash_screen
Nov 21, 2024
c7482b0
Merge branch 'main' of github.com:qlrd/krux-installer
Nov 21, 2024
7bc7c4e
covered exception hooks on wipe_screen
Nov 21, 2024
6815419
removed gui config from tests that do not need it
Nov 21, 2024
252d21b
fix #115
Dec 6, 2024
895bef3
fixing detection on greetings_screen for fedora
Dec 7, 2024
152beac
add disconnect/reconnect message in WipeScreen when the procedure is …
Dec 12, 2024
f2370a1
Merge branch 'main' of github.com:qlrd/krux-installer
Dec 12, 2024
d251d60
added get github badge to readme
tadeubas Dec 14, 2024
4cec3ce
alt text
tadeubas Dec 15, 2024
14ecf40
fix on flash/wipe for devices with two ports
Dec 15, 2024
144ab53
Merge pull request #17 from tadeubas/readme-changes
qlrd Dec 18, 2024
a28ab1e
removed a kanji on translation of 'disconnect and reconnect device be…
Dec 19, 2024
c0ae850
added multiline final message after wipe device in nl_NL and ru_RU
Dec 19, 2024
2826017
Merge branch 'main' of github.com:qlrd/krux-installer
Dec 19, 2024
1c674b8
added normpath on airgap_update_screen to fix double slashes on windows
Dec 20, 2024
b6a489c
added exception treatment on shutil operations o airgap_update_screen
Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ coverage:
status:
project:
default:
target: 100%
threshold: 15%
target: 95%
threshold: 5%
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ without typing any command in terminal for [flash the firmware onto the device](

## Installing

There are pre-built
[releases](https://github.com/selfcustody/krux-installer/releases) for:
[<img src="img/badge_github.png" alt="github releases page" width="186">](https://github.com/selfcustody/krux-installer/releases)

Available for:

* Linux:
* Debian-like;
Expand All @@ -23,7 +24,7 @@ There are pre-built
* intel processors;
* arm64 processors (M1/M2/M3).

To build it from the source, please follow the steps below:
## Build from source

* [System setup](/#system-setup)
* [Linux](/#linux)
Expand Down
71 changes: 70 additions & 1 deletion e2e/test_000_base_screen.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
from pathlib import Path
from unittest.mock import patch, call, MagicMock
from kivy.base import EventLoop, EventLoopBase
Expand Down Expand Up @@ -93,12 +94,21 @@ def test_static_open_settings(self, mock_get_ruunning_app):
BaseScreen.open_settings()
mock_get_ruunning_app.return_value.open_settings.assert_called_once()

@patch.object(EventLoopBase, "ensure_window", lambda x: None)
@patch("src.app.screens.base_screen.App.get_running_app")
def test_static_quit_app(self, mock_get_ruunning_app):
mock_get_ruunning_app.return_value = MagicMock()
mock_get_ruunning_app.return_value.stop = MagicMock()

BaseScreen.quit_app()
mock_get_ruunning_app.return_value.stop.assert_called_once()

@patch.object(EventLoopBase, "ensure_window", lambda x: None)
@patch("sys.platform", "linux")
@patch(
"src.app.screens.base_screen.BaseScreen.get_locale", return_value="en_US.UTF-8"
)
def test_init_linux(self, mock_get_locale):
def test_init_linux_no_frozen(self, mock_get_locale):
screen = BaseScreen(wid="mock", name="Mock")
self.render(screen)

Expand All @@ -112,6 +122,31 @@ def test_init_linux(self, mock_get_locale):

mock_get_locale.assert_called_once()

@patch.object(EventLoopBase, "ensure_window", lambda x: None)
@patch("sys.platform", "linux")
@patch(
"src.app.screens.base_screen.BaseScreen.get_locale", return_value="en_US.UTF-8"
)
def test_init_linux_frozen(self, mock_get_locale):
with patch.dict(
sys.__dict__, {"_MEIPASS": os.path.join("mock", "path"), "frozen": True}
):
screen = BaseScreen(wid="mock", name="Mock")
self.render(screen)

# get your Window instance safely
EventLoop.ensure_window()
window = EventLoop.window

# your asserts
self.assertEqual(
screen.logo_img, os.path.join("mock", "path", "assets", "logo.png")
)
self.assertEqual(window.children[0], screen)
self.assertEqual(window.children[0].height, window.height)

mock_get_locale.assert_called_once()

@patch.object(EventLoopBase, "ensure_window", lambda x: None)
@patch("src.app.screens.base_screen.BaseScreen.get_locale")
def test_init_win32(self, mock_get_locale):
Expand Down Expand Up @@ -401,6 +436,40 @@ def test_update_screen_locale(self, mock_get_locale):
self.assertEqual(screen.locale, "mocked")
mock_get_locale.assert_called_once()

@patch.object(EventLoopBase, "ensure_window", lambda x: None)
@patch(
"src.app.screens.base_screen.BaseScreen.get_locale", return_value="en_US.UTF-8"
)
@patch("src.app.screens.base_screen.BaseScreen.redirect_exception")
def test_fail_update_screen_locale(self, mock_redirect_exception, mock_get_locale):
screen = BaseScreen(wid="mock", name="Mock")
screen.make_grid(wid="mock_grid", rows=1)
screen.make_button(
row=0,
wid="mock_button",
root_widget="mock_grid",
text="Mocked button",
font_factor=32,
halign=None,
on_press=MagicMock(),
on_release=MagicMock(),
on_ref_press=MagicMock(),
)
setattr(screen, "update", MagicMock())
self.render(screen)
self.assertEqual(screen.locale, "en_US.UTF-8")

screen.update_screen(
name="MockedScreen",
key="locale",
value=None,
allowed_screens=("MockedScreen",),
on_update=MagicMock(),
)

mock_get_locale.assert_called_once()
mock_redirect_exception.assert_called_once()

@patch.object(EventLoopBase, "ensure_window", lambda x: None)
@patch("src.app.screens.base_screen.BaseScreen.get_locale")
@patch("src.app.screens.base_screen.Color")
Expand Down
48 changes: 34 additions & 14 deletions e2e/test_001_greetings_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from kivy.tests.common import GraphicUnitTest
from src.app.screens.greetings_screen import GreetingsScreen

# to be used in mocking grp
import src.app.screens.greetings_screen


class TestAboutScreen(GraphicUnitTest):

Expand Down Expand Up @@ -317,40 +320,50 @@ def test_fail_get_os_dialout_group_file_not_found(
mock_redirect_exception.assert_called()

@mark.skipif(
sys.platform in ("win32", "darwin"),
reason="does not run on windows or macos",
sys.platform in ("win32"),
reason="does not run on windows",
)
@patch("sys.platform", "linux") # Patch platform to Linux
@patch.object(EventLoopBase, "ensure_window", lambda x: None)
@patch(
"src.app.screens.base_screen.BaseScreen.get_locale", return_value="en_US.UTF-8"
)
@patch("src.app.screens.greetings_screen.grp")
def test_is_user_not_in_dialout(self, mock_grp, mock_get_locale):
def test_is_user_not_in_dialout(self, mock_get_locale):
# Create a mock grp module
mock_grp = MagicMock()
mock_grp.getgrall.return_value = [
MagicMock(gr_name="dialout", gr_passwd="x", gr_gid=1234, gr_mem=["brltty"])
]
# mock_grp.getgrall.return_value[0].__getitem__ = MagicMock(
# return_value=['dialout', 'x', 1234, ['brltty']]
# )

# Temporarily add the mock grp to greetings_screen's global namespace
setattr(src.app.screens.greetings_screen, "grp", mock_grp)

# Initialize the screen and call the method to test
screen = GreetingsScreen()
is_in_dialout = screen.is_user_in_dialout_group(
user="mockuser", group="dialout"
)
self.assertEqual(is_in_dialout, False)

# Assertions
self.assertEqual(is_in_dialout, False)
mock_get_locale.assert_called()
mock_grp.getgrall.assert_called()

# Clean up by removing the mock from the module's namespace
delattr(src.app.screens.greetings_screen, "grp")

@mark.skipif(
sys.platform in ("win32", "darwin"),
reason="does not run on windows or macos",
sys.platform in ("win32"),
reason="does not run on windows",
)
@patch("sys.platform", "linux") # Patch platform to Linux
@patch.object(EventLoopBase, "ensure_window", lambda x: None)
@patch(
"src.app.screens.base_screen.BaseScreen.get_locale", return_value="en_US.UTF-8"
)
@patch("src.app.screens.greetings_screen.grp")
def test_is_user_in_dialout(self, mock_grp, mock_get_locale):
def test_is_user_in_dialout(self, mock_get_locale):
# Create a mock grp module
mock_grp = MagicMock()
mock_grp.getgrall.return_value = [
MagicMock(
gr_name="dialout",
Expand All @@ -359,6 +372,11 @@ def test_is_user_in_dialout(self, mock_grp, mock_get_locale):
gr_mem=["brltty", "mockuser"],
)
]

# Temporarily add the mock grp to greetings_screen's global namespace
setattr(src.app.screens.greetings_screen, "grp", mock_grp)

# Initialize the screen and call the method to test
screen = GreetingsScreen()
is_in_dialout = screen.is_user_in_dialout_group(
user="mockuser", group="dialout"
Expand Down Expand Up @@ -459,9 +477,10 @@ def test_pass_check_dialout_permission_not_linux(
mock_schedule_once.assert_called()

@mark.skipif(
sys.platform in ("win32", "darwin"),
sys.platform in ("win32"),
reason="does not run on windows or darwin",
)
@patch("sys.platform", "linux")
@patch.object(EventLoopBase, "ensure_window", lambda x: None)
@patch("src.app.screens.greetings_screen.os.environ.get", return_value="mockuser")
@patch(
Expand Down Expand Up @@ -501,9 +520,10 @@ def test_check_dialout_permission_not_in_dialout(
mock_in_dialout.assert_called()

@mark.skipif(
sys.platform in ("win32", "darwin"),
sys.platform in ("win32"),
reason="does not run on windows or darwin",
)
@patch("sys.platform", "linux")
@patch.object(EventLoopBase, "ensure_window", lambda x: None)
@patch("src.app.screens.greetings_screen.os.environ.get", return_value="mockuser")
@patch(
Expand Down
Loading
Loading