Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/update_compatible_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
update-compatible-versions:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Checkout repository
Expand Down
10 changes: 8 additions & 2 deletions app/utils/aggregated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
plaform = 'macos' if platform.system() == 'Darwin' else platform.system().lower()
download_details = result.get(plaform, None)
Comment thread
colorzzr marked this conversation as resolved.
Outdated
Comment thread
colorzzr marked this conversation as resolved.
Outdated

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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "app"
version = "3.19.6"
version = "3.19.7"
Comment thread
colorzzr marked this conversation as resolved.
Outdated
description = "This service is designed to support pilot platform"
authors = ["Indoc Systems"]

Expand Down
32 changes: 32 additions & 0 deletions tests/app/utils/test_aggregated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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('platform.system', return_value=platform_name)
Comment thread
colorzzr marked this conversation as resolved.
Outdated
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']
Loading