|
10 | 10 |
|
11 | 11 | import tempfile |
12 | 12 | from pathlib import Path |
| 13 | +from unittest.mock import patch |
13 | 14 |
|
14 | 15 | import pytest |
15 | 16 |
|
@@ -154,6 +155,34 @@ def test_test_with_suffix_unsigned(self): |
154 | 155 | class TestTestToTestUpdateReturnsDownloadUrl: |
155 | 156 | """Test build updating to newer test build gets a valid download_url (no 404 after publishing test releases).""" |
156 | 157 |
|
| 158 | + def test_thread_path_keeps_test_channel_for_test_build(self): |
| 159 | + """_do_check (thread path, used on Windows) must not overwrite test channel with preference. |
| 160 | +
|
| 161 | + Bug: channel was set from preferences.get_channel() so test builds fetched stable feed. |
| 162 | + """ |
| 163 | + with tempfile.NamedTemporaryFile(suffix=".json", delete=False) as f: |
| 164 | + prefs_path = f.name |
| 165 | + try: |
| 166 | + prefs = UpdatePreferences(preferences_file=Path(prefs_path)) |
| 167 | + prefs.set_channel(UpdatePreferences.CHANNEL_STABLE) |
| 168 | + manager = UpdateManager( |
| 169 | + current_version="0.0.1-test", |
| 170 | + feed_url="https://example.com/updates", |
| 171 | + preferences=prefs, |
| 172 | + ) |
| 173 | + assert manager.checker.channel == "test" |
| 174 | + feed_url_before = manager.checker.get_feed_url("windows") |
| 175 | + assert "/test/" in feed_url_before |
| 176 | + |
| 177 | + with patch.object(manager.checker, "check_for_updates", return_value=None): |
| 178 | + manager._do_check() |
| 179 | + |
| 180 | + assert manager.checker.channel == "test" |
| 181 | + feed_url_after = manager.checker.get_feed_url("windows") |
| 182 | + assert "/test/" in feed_url_after |
| 183 | + finally: |
| 184 | + Path(prefs_path).unlink(missing_ok=True) |
| 185 | + |
157 | 186 | def test_test_version_sees_newer_test_in_appcast_with_download_url(self): |
158 | 187 | """0.0.3-test sees 0.0.4-test in appcast and gets update with HTTPS download_url.""" |
159 | 188 | # Minimal appcast with one item: 0.0.4-test, GitHub-style enclosure URL |
|
0 commit comments