Skip to content

Commit 708ac52

Browse files
committed
add github workflow for running tests
1 parent 34cf446 commit 708ac52

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

.github/workflows/tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Python tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches:
9+
- '**'
10+
11+
jobs:
12+
test:
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v5
18+
with:
19+
submodules: true
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.13'
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -r requirements.txt
30+
31+
- name: Run pytest
32+
run: |
33+
pip install pytest pytest-mock
34+
pytest

tests/integration/test_basic_commands.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def fake_run_as_root(run_args):
6161
exit_mock.assert_called_once()
6262

6363

64-
def test_upgrade_happy(cli, monkeypatch):
64+
def test_upgrade(cli, monkeypatch):
6565
monkeypatch.setattr(mytonctrl_module, "check_git", lambda args, default_repo, text: ("author", "repo", "branch", None))
6666

6767
calls = {}
@@ -122,13 +122,18 @@ def fake_upgrade_btc_teleport(local, ton, reinstall=False, branch="master", user
122122
teleport_calls["branch"] = branch
123123
teleport_calls["user"] = user
124124
monkeypatch.setattr(mytonctrl_module, "upgrade_btc_teleport", fake_upgrade_btc_teleport)
125-
output = cli.execute("upgrade")
125+
output = cli.execute("upgrade", no_color=True)
126126
assert teleport_calls.get("called") is True
127127
assert teleport_calls.get("reinstall") is False
128-
assert "Upgrade - \x1b[32mOK\x1b" in output
128+
assert "Upgrade - OK" in output
129129
assert "Error" not in output
130130
assert calls["run_args"] == ["bash", upg_path, "-a", "author", "-r", "repo", "-b", "branch"]
131131

132+
monkeypatch.setattr(mytonctrl_module, "run_as_root", lambda _: 1)
133+
output = cli.execute("upgrade", no_color=True)
134+
assert "Upgrade - Error" in output
135+
136+
132137
def test_upgrade_btc_teleport(cli, monkeypatch, mocker: MockerFixture):
133138
teleport_calls = {}
134139
def fake_upgrade_btc_teleport(local, ton, reinstall=False, branch="master", user=None):

0 commit comments

Comments
 (0)