Ci cd fixes #10

Merged
JMR-dev merged 4 commits from ci-cd-fix into main 2025-09-23 00:20:18 +00:00
6 changed files with 53 additions and 17 deletions
+13 -2
View File
@@ -55,7 +55,7 @@ jobs:
- name: Run tests
run: |
poetry run pytest -v
poetry run pytest tests/ -v
run-unit-tests-windows:
runs-on: windows-latest
@@ -69,6 +69,17 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
- name: Ensure Poetry is on PATH (Windows)
shell: pwsh
run: |
# Add Poetry user bin to PATH for subsequent steps in this job
$poetryPath = Join-Path $env:USERPROFILE ".local\bin"
Write-Output $poetryPath >> $Env:GITHUB_PATH
- name: Install dependencies
run: |
@@ -76,7 +87,7 @@ jobs:
- name: Run tests
run: |
poetry run pytest -v
poetry run pytest tests/ -v
build-windows:
needs: [run-unit-tests-linux, run-unit-tests-windows]
if: contains(github.event.inputs.jobs, 'build-windows')
+1 -1
View File
@@ -10,7 +10,7 @@ test-act.yml
pkg_dist_debian
pkg*
.pytest*
!pytest.ini
# Python cache files
__pycache__/
*.py[cod]
+7
View File
@@ -0,0 +1,7 @@
[pytest]
minversion = 7.0
testpaths = tests
python_files = test_*.py *_test.py
python_classes = Test*
python_functions = test_*
addopts = -v --tb=short -p no:qt
+8 -4
View File
@@ -48,7 +48,8 @@ class TestADBFileTransfer:
result = transfer.pull_file("/sdcard/test.txt", "/local/test.txt")
assert result is True
mock_runner.run_adb_command.assert_called_with(['pull', '/sdcard/test.txt', '/local/test.txt'])
expected_local_path = os.path.normpath('/local/test.txt')
mock_runner.run_adb_command.assert_called_with(['pull', '/sdcard/test.txt', expected_local_path])
@patch('src.core.file_transfer.ADBCommandRunner')
@patch('os.path.exists')
@@ -93,7 +94,8 @@ class TestADBFileTransfer:
result = transfer.push_file("/local/test.txt", "/sdcard/test.txt")
assert result is True
mock_runner.run_adb_command.assert_called_with(['push', '/local/test.txt', '/sdcard/test.txt'])
expected_local_path = os.path.normpath('/local/test.txt')
mock_runner.run_adb_command.assert_called_with(['push', expected_local_path, '/sdcard/test.txt'])
@patch('src.core.file_transfer.ADBCommandRunner')
@patch('os.path.exists')
@@ -140,7 +142,8 @@ class TestADBFileTransfer:
result = transfer.pull_folder("/sdcard/Documents", "/local/Documents")
assert result is True
mock_runner.run_adb_command.assert_called_with(['pull', '/sdcard/Documents', '/local/Documents'])
expected_local_path = os.path.normpath('/local/Documents')
mock_runner.run_adb_command.assert_called_with(['pull', '/sdcard/Documents', expected_local_path])
@patch('src.core.file_transfer.ADBCommandRunner')
@patch('os.path.exists')
@@ -171,7 +174,8 @@ class TestADBFileTransfer:
result = transfer.push_folder("/local/Documents", "/sdcard/Documents")
assert result is True
mock_runner.run_adb_command.assert_called_with(['push', '/local/Documents', '/sdcard/Documents'])
expected_local_path = os.path.normpath('/local/Documents')
mock_runner.run_adb_command.assert_called_with(['push', expected_local_path, '/sdcard/Documents'])
@patch('src.core.file_transfer.ADBCommandRunner')
@patch('os.path.exists')
+14 -5
View File
@@ -58,14 +58,23 @@ class TestPlatformTools(unittest.TestCase):
def test_ensure_platform_tools_simple(self):
"""Test basic platform tools installation."""
# Just test the function doesn't crash with basic mocking
def mock_isdir(path):
# Return True for the extracted platform-tools directory and target directory checks
if path == '/tmp/test/platform-tools':
return True
if path.endswith('platform-tools') and 'tmp' in path:
return True
# Return False for other directory checks (like existing target_dir)
return False
with patch('os.makedirs'):
with patch('os.path.islink', return_value=False):
with patch('os.path.isdir', return_value=False):
with patch('os.path.isdir', side_effect=mock_isdir):
with patch('tempfile.mkdtemp', return_value='/tmp/test'):
with patch('requests.get') as mock_get:
with patch('builtins.open', mock_open()):
with patch('zipfile.ZipFile') as mock_zip:
with patch('os.path.isdir', side_effect=lambda p: p == '/tmp/test/platform-tools'):
with patch('os.listdir', return_value=['platform-tools']): # Mock directory listing
with patch('requests.get') as mock_get:
with patch('builtins.open', mock_open()):
with patch('zipfile.ZipFile') as mock_zip:
with patch('shutil.move'):
with patch('os.chmod'):
with patch('os.symlink'):
+10 -5
View File
@@ -58,21 +58,24 @@ class TestPlatformUtils:
with patch.object(sys, 'frozen', True, create=True):
with patch('src.core.platform_utils.get_executable_directory', return_value='/app/dir'):
result = get_platform_tools_directory()
assert result == '/app/dir/platform-tools'
expected = os.path.join('/app/dir', 'platform-tools')
assert result == expected
def test_get_platform_tools_directory_src(self):
"""Test platform-tools directory when running from src."""
with patch.object(sys, 'frozen', False, create=True):
with patch('src.core.platform_utils.get_executable_directory', return_value='/project/src'):
result = get_platform_tools_directory()
assert result == '/project/src/platform-tools'
expected = os.path.join('/project/src', 'platform-tools')
assert result == expected
def test_get_platform_tools_directory_gui_subdirectory(self):
"""Test platform-tools directory when running from src/gui."""
with patch.object(sys, 'frozen', False, create=True):
with patch('src.core.platform_utils.get_executable_directory', return_value='/project/src/gui'):
result = get_platform_tools_directory()
assert result == '/project/src/platform-tools'
expected = os.path.join('/project/src', 'platform-tools')
assert result == expected
def test_get_platform_tools_directory_project_root(self):
"""Test platform-tools directory when running from project root."""
@@ -80,7 +83,8 @@ class TestPlatformUtils:
with patch('src.core.platform_utils.get_executable_directory', return_value='/project'):
with patch('os.path.exists', return_value=True):
result = get_platform_tools_directory()
assert result == '/project/src/platform-tools'
expected = os.path.join('/project', 'src', 'platform-tools')
assert result == expected
def test_get_platform_tools_directory_fallback(self):
"""Test platform-tools directory fallback behavior."""
@@ -88,4 +92,5 @@ class TestPlatformUtils:
with patch('src.core.platform_utils.get_executable_directory', return_value='/somewhere'):
with patch('os.path.exists', return_value=False):
result = get_platform_tools_directory()
assert result == '/somewhere/src/platform-tools'
expected = os.path.join('/somewhere', 'src', 'platform-tools')
assert result == expected