diff --git a/README.md b/README.md index 5762e844..0f59bba9 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Command line tool that allows the user to execute data operations on the platfor | 3.19.5 | 2.15.2 | 2.15.2 | | 3.19.6 | 2.15.2 | 2.15.2 | | 3.19.7 | 2.15.2 | 2.15.2 | +| 3.20.0 | 2.15.2 | 2.15.2 | ## Build Instructions diff --git a/app/utils/aggregated.py b/app/utils/aggregated.py index 5bf8fd49..bc33680f 100644 --- a/app/utils/aggregated.py +++ b/app/utils/aggregated.py @@ -3,6 +3,7 @@ # Contact Indoc Systems for any questions regarding the use of this source code. import os +import platform import re import shutil import time @@ -247,8 +248,13 @@ def get_latest_cli_version() -> Tuple[Version, str]: headers = {'Authorization': 'Bearer'} response = httpx_client._get('v1/download/cli/presigned', headers=headers) result = response.json().get('result', {}) - latest_version = result.get('linux', {}).get('version', '0.0.0') - download_url = result.get('linux', {}).get('download_url', '') + + # extract the download URL by platform + platform_key = 'macos' if platform.system() == 'Darwin' else platform.system().lower() + download_details = result.get(platform_key, {}) + + latest_version = download_details.get('version', '0.0.0') + download_url = download_details.get('download_url', '') return Version(latest_version), download_url except (SystemExit, Exception): diff --git a/docs/compatible_version.ndjson b/docs/compatible_version.ndjson index d0ef7a37..9332d22e 100644 --- a/docs/compatible_version.ndjson +++ b/docs/compatible_version.ndjson @@ -14,3 +14,4 @@ {"Cli Version": "3.19.5", "Pilot Release Version": "2.15.2", "Compatible Version": "2.15.2"} {"Cli Version": "3.19.6", "Pilot Release Version": "2.15.2", "Compatible Version": "2.15.2"} {"Cli Version": "3.19.7", "Pilot Release Version": "2.15.2", "Compatible Version": "2.15.2"} +{"Cli Version": "3.20.0", "Pilot Release Version": "2.15.2", "Compatible Version": "2.15.2"} diff --git a/pyproject.toml b/pyproject.toml index 85872206..7b5a640a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "app" -version = "3.19.7" +version = "3.20.0" description = "This service is designed to support pilot platform" authors = ["Indoc Systems"] diff --git a/tests/app/utils/test_aggregated.py b/tests/app/utils/test_aggregated.py index bca1e217..5914ce0f 100644 --- a/tests/app/utils/test_aggregated.py +++ b/tests/app/utils/test_aggregated.py @@ -7,6 +7,7 @@ from app.configs.app_config import AppConfig from app.models.item import ItemType from app.utils.aggregated import check_item_duplication +from app.utils.aggregated import get_latest_cli_version from app.utils.aggregated import get_version_compatibility from app.utils.aggregated import identify_target_folder from app.utils.aggregated import normalize_input_paths @@ -251,3 +252,34 @@ def test_get_version_compatibility_fail_with_version_incompatible(httpx_mock, ca f'CLI version is incompatible with server version. Please update the CLI to version {min_cli_version}' + f' or later, and minimum server version is {min_server_version}.' ) in out.rstrip() + + +@pytest.mark.parametrize('platform_name', ['Linux', 'Windows', 'Darwin']) +def test_get_download_link_by_platform(mocker, platform_name, httpx_mock): + mocker.patch('app.utils.aggregated.platform.system', return_value=platform_name) + expected_result = { + 'linux': { + 'version': '1.0.0', + 'download_url': 'https://example.com/download/linux', + }, + 'windows': { + 'version': '1.0.1', + 'download_url': 'https://example.com/download/windows', + }, + 'macos': { + 'version': '1.1.0', + 'download_url': 'https://example.com/download/macos', + }, + } + httpx_mock.add_response( + url=AppConfig.Connections.url_fileops_greenroom + '/v1/download/cli/presigned', + method='GET', + json={'result': expected_result}, + status_code=200, + ) + + version, url = get_latest_cli_version() + if platform_name.lower() == 'darwin': + platform_name = 'macos' + assert str(version) == expected_result[platform_name.lower()]['version'] + assert url == expected_result[platform_name.lower()]['download_url']