|
| 1 | +from pathlib import Path |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | +from cycode.cli.user_settings.config_file_manager import ConfigFileManager |
| 6 | + |
| 7 | + |
| 8 | +@pytest.fixture() |
| 9 | +def config_manager(tmp_path: Path) -> ConfigFileManager: |
| 10 | + return ConfigFileManager(tmp_path) |
| 11 | + |
| 12 | + |
| 13 | +def test_get_last_reported_activation_versions_returns_empty_when_not_set( |
| 14 | + config_manager: ConfigFileManager, |
| 15 | +) -> None: |
| 16 | + assert config_manager.get_last_reported_activation_versions() == {} |
| 17 | + |
| 18 | + |
| 19 | +def test_update_and_get_last_reported_activation_version_cli(config_manager: ConfigFileManager) -> None: |
| 20 | + config_manager.update_last_reported_activation_version('cli', '1.10.7') |
| 21 | + |
| 22 | + assert config_manager.get_last_reported_activation_versions() == {'cli': '1.10.7'} |
| 23 | + |
| 24 | + |
| 25 | +def test_update_and_get_last_reported_activation_version_plugin(config_manager: ConfigFileManager) -> None: |
| 26 | + config_manager.update_last_reported_activation_version('vscode_extension', '2.0.0') |
| 27 | + |
| 28 | + assert config_manager.get_last_reported_activation_versions() == {'vscode_extension': '2.0.0'} |
| 29 | + |
| 30 | + |
| 31 | +def test_update_last_reported_activation_version_multiple_clients(config_manager: ConfigFileManager) -> None: |
| 32 | + config_manager.update_last_reported_activation_version('cli', '1.10.7') |
| 33 | + config_manager.update_last_reported_activation_version('vscode_extension', '2.0.0') |
| 34 | + config_manager.update_last_reported_activation_version('jetbrains_extension', '1.5.0') |
| 35 | + |
| 36 | + assert config_manager.get_last_reported_activation_versions() == { |
| 37 | + 'cli': '1.10.7', |
| 38 | + 'vscode_extension': '2.0.0', |
| 39 | + 'jetbrains_extension': '1.5.0', |
| 40 | + } |
| 41 | + |
| 42 | + |
| 43 | +def test_update_last_reported_activation_version_overwrites_existing(config_manager: ConfigFileManager) -> None: |
| 44 | + config_manager.update_last_reported_activation_version('cli', '1.10.7') |
| 45 | + config_manager.update_last_reported_activation_version('cli', '1.10.8') |
| 46 | + |
| 47 | + assert config_manager.get_last_reported_activation_versions() == {'cli': '1.10.8'} |
| 48 | + |
| 49 | + |
| 50 | +def test_update_last_reported_activation_version_does_not_affect_other_clients( |
| 51 | + config_manager: ConfigFileManager, |
| 52 | +) -> None: |
| 53 | + config_manager.update_last_reported_activation_version('cli', '1.10.7') |
| 54 | + config_manager.update_last_reported_activation_version('vscode_extension', '2.0.0') |
| 55 | + config_manager.update_last_reported_activation_version('cli', '1.10.8') |
| 56 | + |
| 57 | + assert config_manager.get_last_reported_activation_versions()['vscode_extension'] == '2.0.0' |
0 commit comments