Check settings of installations post-0.4.2. Installations from 0.4.2 onwards will have a "updater_latest_version" field in their settings. When these installations get upgraded to a newer version, we must make sure that this field becomes equal to the new version, so that the user is no
(
isolated_settings: settings.Settings,
monkeypatch: MonkeyPatch,
)
| 76 | |
| 77 | |
| 78 | def test_post_0_4_2_settings( |
| 79 | isolated_settings: settings.Settings, |
| 80 | monkeypatch: MonkeyPatch, |
| 81 | ) -> None: |
| 82 | """Check settings of installations post-0.4.2. |
| 83 | |
| 84 | Installations from 0.4.2 onwards will have a "updater_latest_version" field in their |
| 85 | settings. When these installations get upgraded to a newer version, we must make |
| 86 | sure that this field becomes equal to the new version, so that the user is not |
| 87 | erroneously prompted to a version they already have. |
| 88 | """ |
| 89 | # Store the settings of Dangerzone 0.4.2 to the filesystem. |
| 90 | tmp_path = isolated_settings.settings_filename.parent |
| 91 | old_settings = settings.Settings.generate_default_settings() |
| 92 | old_settings["updater_latest_version"] = "0.4.2" |
| 93 | # isolated_settings.set("updater_last_check", 0) |
| 94 | save_settings(tmp_path, old_settings) |
| 95 | |
| 96 | # Mimic an upgrade to version 0.4.3, by making Dangerzone report that the current |
| 97 | # version is 0.4.3. |
| 98 | expected_settings = default_updater_settings() |
| 99 | expected_settings["updater_latest_version"] = "0.4.3" |
| 100 | monkeypatch.setattr(settings, "get_version", lambda: "0.4.3") |
| 101 | |
| 102 | # Ensure that the Settings class will correct the latest version field to 0.4.3. |
| 103 | isolated_settings.load() |
| 104 | assert isolated_settings.get_updater_settings() == expected_settings |
| 105 | |
| 106 | # Simulate an updater check that found a newer Dangerzone version (e.g., 0.4.4). |
| 107 | expected_settings["updater_latest_version"] = "0.4.4" |
| 108 | isolated_settings.set( |
| 109 | "updater_latest_version", expected_settings["updater_latest_version"] |
| 110 | ) |
| 111 | isolated_settings.save() |
| 112 | |
| 113 | # Ensure that the Settings class will leave the "updater_latest_version" field |
| 114 | # intact the next time we reload the settings. |
| 115 | isolated_settings.load() |
| 116 | assert isolated_settings.get_updater_settings() == expected_settings |
| 117 | |
| 118 | |
| 119 | @pytest.mark.skipif(platform.system() != "Linux", reason="Linux-only test") |
nothing calls this directly
no test coverage detected