Skip to content

Commit 6454498

Browse files
committed
add building project to workflow, test project as package
1 parent 03f2efa commit 6454498

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ jobs:
3737
run: |
3838
ruff check mytonctrl # wip adding ruff linting across the whole project
3939
40+
- name: Build project
41+
run: |
42+
pip install -U .
43+
4044
- name: Run pytest
4145
run: |
42-
pytest
46+
pytest --import-mode=append # to test built package

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
author_email='igroman787',
1515
name='mytonctrl',
1616
version=version,
17-
packages=find_packages('.', exclude=['tests']),
17+
packages=find_packages('.', exclude=['tests', 'tests.*']),
1818
install_requires=install_requires,
1919
package_data={
2020
'mytoninstaller.scripts': ['*.sh'],

tests/integration/test_backup_commands.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from modules.backups import BackupModule
77
from modules import backups as backups_module
88
from mypylib.mypylib import MyPyClass
9+
from mytoncore import get_package_resource_path
910
from mytoncore.mytoncore import MyTonCore
1011
from pathlib import Path
1112

@@ -87,7 +88,8 @@ def fake_run_restore_backup(*args, **kwargs):
8788
monkeypatch.setattr(BackupModule, "run_restore_backup", staticmethod(fake_run_restore_backup))
8889

8990
current_user = get_current_user()
90-
backup_path = Path(__file__).resolve().parents[2] / 'mytonctrl'/ 'scripts' / 'restore_backup.sh'
91+
with get_package_resource_path('mytonctrl', 'scripts/restore_backup.sh') as backup_path:
92+
assert backup_path.is_file()
9193

9294
def assert_happy_run_args(outp: str, user: str):
9395
assert 'restore_backup - OK' in outp

tests/integration/test_basic_commands.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import requests
88
from pytest_mock import MockerFixture
99

10+
from mytoncore import get_package_resource_path
1011
from mytonctrl import mytonctrl as mytonctrl_module
1112
from mypylib.mypylib import MyPyClass
1213
from mypylib.mypylib import Dict
@@ -55,7 +56,8 @@ def fake_run_as_root(run_args):
5556
monkeypatch.setattr(mytonctrl_module, "run_as_root", fake_run_as_root)
5657

5758
output = cli.execute("update")
58-
upd_path = Path(__file__).resolve().parents[2] / 'mytonctrl'/ 'scripts' / 'update.sh'
59+
with get_package_resource_path('mytonctrl', 'scripts/update.sh') as upd_path:
60+
assert upd_path.is_file()
5961
assert "Error" not in output
6062
assert calls["run_args"] == ['bash', upd_path, '-a', 'author', '-r', 'repo', '-b', 'branch']
6163
exit_mock.assert_called_once()
@@ -72,7 +74,8 @@ def fake_run_as_root(run_args):
7274
monkeypatch.setattr(mytonctrl_module, "run_as_root", fake_run_as_root)
7375
monkeypatch.setattr(mytonctrl_module, "get_clang_major_version", lambda: 16)
7476
monkeypatch.setattr(MyTonCore, "using_validator", lambda self: False)
75-
upg_path = Path(__file__).resolve().parents[2] / "mytonctrl" / "scripts" / "upgrade.sh"
77+
with get_package_resource_path('mytonctrl', 'scripts/upgrade.sh') as upg_path:
78+
assert upg_path.is_file()
7679

7780
def fake_GetSettings(self, name):
7881
if name == "liteClient":

0 commit comments

Comments
 (0)