Refactor Windows build script for improved readability and consistency
- Cleaned up whitespace and formatting in build_windows.py for better readability. - Consolidated environment variable setup for stdout and stderr. - Streamlined subprocess command calls by removing unnecessary line breaks. - Enhanced error handling and logging for better debugging. - Updated comments for clarity and consistency. Update updater.py to improve checksum verification logic - Modified checksum verification to prioritize specific .sha256 files matching installer names. - Added fallback logic to check for any .sha256 file if no specific match is found. Enhance update manager UI with download progress dialog - Introduced DownloadingDialog to provide feedback during update downloads. - Updated MainWindow to manage the new downloading dialog and handle its lifecycle. - Removed the skip version functionality from the update dialog as per new requirements. Refactor update manager UI tests for clarity and maintainability - Removed tests related to the skip version functionality. - Updated test cases to reflect changes in the update manager UI. - Ensured all tests are aligned with the new dialog structure and signal emissions.
This commit is contained in:
parent
88d9f200ab
commit
025e9c888c
10 changed files with 3066 additions and 3088 deletions
|
|
@ -76,24 +76,17 @@ class TestUpdateAvailableDialog:
|
|||
def test_signals_emitted_update_now(self, qapp, qtbot):
|
||||
"""Test update now signal is emitted."""
|
||||
dialog = UpdateAvailableDialog("0.0.2", "Changes")
|
||||
|
||||
|
||||
with qtbot.waitSignal(dialog.update_now):
|
||||
dialog.update_now_btn.click()
|
||||
|
||||
def test_signals_emitted_update_later(self, qapp, qtbot):
|
||||
"""Test update later signal is emitted."""
|
||||
dialog = UpdateAvailableDialog("0.0.2", "Changes")
|
||||
|
||||
|
||||
with qtbot.waitSignal(dialog.update_later):
|
||||
dialog.update_later_btn.click()
|
||||
|
||||
def test_signals_emitted_skip(self, qapp, qtbot):
|
||||
"""Test skip version signal is emitted."""
|
||||
dialog = UpdateAvailableDialog("0.0.2", "Changes")
|
||||
|
||||
with qtbot.waitSignal(dialog.skip_version):
|
||||
dialog.skip_btn.click()
|
||||
|
||||
|
||||
class TestDownloadingDialog:
|
||||
"""Tests for DownloadingDialog."""
|
||||
|
|
@ -134,7 +127,7 @@ class TestDownloadingDialog:
|
|||
def test_cancel_signal(self, qapp, qtbot):
|
||||
"""Test cancel signal is emitted."""
|
||||
dialog = DownloadingDialog()
|
||||
|
||||
|
||||
with qtbot.waitSignal(dialog.cancel_download):
|
||||
dialog.cancel_btn.click()
|
||||
|
||||
|
|
@ -156,7 +149,7 @@ class TestInstallDialog:
|
|||
def test_install_signal(self, qapp, qtbot):
|
||||
"""Test install signal is emitted."""
|
||||
dialog = InstallDialog()
|
||||
|
||||
|
||||
with qtbot.waitSignal(dialog.install_now):
|
||||
dialog.install_btn.click()
|
||||
|
||||
|
|
@ -211,13 +204,13 @@ class TestErrorDialog:
|
|||
def test_retry_signal(self, qapp, qtbot):
|
||||
"""Test retry signal is emitted."""
|
||||
dialog = ErrorDialog("Error")
|
||||
|
||||
|
||||
with qtbot.waitSignal(dialog.retry):
|
||||
dialog.retry_btn.click()
|
||||
|
||||
def test_manual_download_signal(self, qapp, qtbot):
|
||||
"""Test manual download signal is emitted."""
|
||||
dialog = ErrorDialog("Error")
|
||||
|
||||
|
||||
with qtbot.waitSignal(dialog.manual_download):
|
||||
dialog.manual_btn.click()
|
||||
|
|
|
|||
|
|
@ -166,9 +166,7 @@ class TestCheckForUpdates:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
@patch.object(UpdateManager, "_fetch_release")
|
||||
async def test_check_for_updates_no_update(
|
||||
self, mock_fetch, update_manager
|
||||
):
|
||||
async def test_check_for_updates_no_update(self, mock_fetch, update_manager):
|
||||
"""Test no update available."""
|
||||
mock_fetch.return_value = {
|
||||
"tag_name": "v0.0.1",
|
||||
|
|
@ -184,9 +182,7 @@ class TestCheckForUpdates:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
@patch.object(UpdateManager, "_fetch_release")
|
||||
async def test_check_for_updates_uses_cache(
|
||||
self, mock_fetch, update_manager, sample_release
|
||||
):
|
||||
async def test_check_for_updates_uses_cache(self, mock_fetch, update_manager, sample_release):
|
||||
"""Test cache is used on subsequent calls."""
|
||||
mock_fetch.return_value = sample_release
|
||||
|
||||
|
|
@ -207,9 +203,7 @@ class TestDownloading:
|
|||
"""Test update downloading."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_download_update_success(
|
||||
self, update_manager, tmp_path
|
||||
):
|
||||
async def test_download_update_success(self, update_manager, tmp_path):
|
||||
"""Test successful update download."""
|
||||
# Create release with .msi asset
|
||||
release_data = {
|
||||
|
|
@ -237,9 +231,7 @@ class TestDownloading:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
@patch.object(UpdateManager, "_download_file")
|
||||
async def test_download_update_no_installer(
|
||||
self, mock_download, update_manager
|
||||
):
|
||||
async def test_download_update_no_installer(self, mock_download, update_manager):
|
||||
"""Test download fails when no installer in release."""
|
||||
release_data = {
|
||||
"tag_name": "v0.0.2",
|
||||
|
|
@ -270,8 +262,8 @@ class TestChecksumVerification:
|
|||
self, mock_download_checksum, update_manager, sample_release, tmp_path
|
||||
):
|
||||
"""Test successful checksum verification."""
|
||||
# Create test file
|
||||
test_file = tmp_path / "test.exe"
|
||||
# File must match the asset name so the .sha256 lookup succeeds
|
||||
test_file = tmp_path / "WebDropBridge.exe"
|
||||
test_file.write_bytes(b"test content")
|
||||
|
||||
# Calculate actual checksum
|
||||
|
|
@ -291,7 +283,8 @@ class TestChecksumVerification:
|
|||
self, mock_download_checksum, update_manager, sample_release, tmp_path
|
||||
):
|
||||
"""Test checksum verification fails on mismatch."""
|
||||
test_file = tmp_path / "test.exe"
|
||||
# File must match the asset name so the .sha256 lookup succeeds
|
||||
test_file = tmp_path / "WebDropBridge.exe"
|
||||
test_file.write_bytes(b"test content")
|
||||
|
||||
# Return wrong checksum
|
||||
|
|
@ -303,9 +296,7 @@ class TestChecksumVerification:
|
|||
assert result is False
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_verify_checksum_no_checksum_file(
|
||||
self, update_manager, tmp_path
|
||||
):
|
||||
async def test_verify_checksum_no_checksum_file(self, update_manager, tmp_path):
|
||||
"""Test verification skipped when no checksum file in release."""
|
||||
test_file = tmp_path / "test.exe"
|
||||
test_file.write_bytes(b"test content")
|
||||
|
|
@ -336,9 +327,7 @@ class TestInstallation:
|
|||
|
||||
@patch("subprocess.Popen")
|
||||
@patch("platform.system")
|
||||
def test_install_update_windows(
|
||||
self, mock_platform, mock_popen, update_manager, tmp_path
|
||||
):
|
||||
def test_install_update_windows(self, mock_platform, mock_popen, update_manager, tmp_path):
|
||||
"""Test installation on Windows."""
|
||||
mock_platform.return_value = "Windows"
|
||||
installer = tmp_path / "WebDropBridge.msi"
|
||||
|
|
@ -351,9 +340,7 @@ class TestInstallation:
|
|||
|
||||
@patch("subprocess.Popen")
|
||||
@patch("platform.system")
|
||||
def test_install_update_macos(
|
||||
self, mock_platform, mock_popen, update_manager, tmp_path
|
||||
):
|
||||
def test_install_update_macos(self, mock_platform, mock_popen, update_manager, tmp_path):
|
||||
"""Test installation on macOS."""
|
||||
mock_platform.return_value = "Darwin"
|
||||
installer = tmp_path / "WebDropBridge.dmg"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue