Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 575ff2a

Browse files
committed
test: add first platform test
1 parent b59cf31 commit 575ff2a

File tree

4 files changed

+32
-48
lines changed

4 files changed

+32
-48
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ignore = ["E501", "W504"]
2222
max-complexity = 10
2323

2424
[tool.pytest.ini_options]
25-
addopts = "--cov=src --cov=test --cov-report=term-missing:skip-covered --cov-fail-under=63"
25+
addopts = "--cov=src --cov=test --cov-report=term-missing:skip-covered --cov-fail-under=70"
2626
pythonpath = ["src/progman"]
2727
testpaths = ["test"]
2828

test/test_core/test_shortcut.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ def setup_method(self):
1414
separate_icon_path="/home/my_user/images/app_icon.png"
1515
)
1616

17+
def test_display_name_from_link(self) -> None:
18+
test_object = Shortcut("c:/program folder/app folder/app.exe",
19+
"--foo",
20+
"c:/program folder/app_folder",
21+
"c:/program folder/app folder/abc.ico",
22+
link_path="c:/users/my_user/app_data/Microsoft/Windows/Start Menu/Programs/efg.lnk")
23+
assert test_object.name == "efg"
24+
1725
@patch(f"{namespace}.Path.exists", return_value=True)
1826
def test_icon(self, exists: Mock):
1927
assert self.test_object.icon == self.test_object.separate_icon_path
@@ -45,3 +53,8 @@ def test___hash__(self):
4553
result = self.test_object.__hash__()
4654
assert result == mocked_hash.return_value
4755
mocked_hash.assert_called_once_with("/usr/bin/app--arg1 value1/home/my_user/documents")
56+
57+
def test_is_web_link(self):
58+
assert self.test_object.is_web_link is False
59+
self.test_object.target_path = "https://google.com"
60+
assert self.test_object.is_web_link

test/test_platforms/test___init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
from unittest.mock import patch
3+
4+
from pytest import raises
5+
6+
7+
class TestInit:
8+
9+
def test_windows(self) -> None:
10+
with patch("platform.system", return_value="windows"):
11+
import platforms
12+
assert platforms.IconLoader
13+
del sys.modules["platforms"]
14+
15+
def test_linux(self) -> None:
16+
with patch("platform.system", return_value="linux"):
17+
with raises(NotImplementedError):
18+
import platforms # noqa: F401

test/test_platforms/test_shortcut.py

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)