Skip to content

Commit 38f318f

Browse files
authored
Pilot 7101: Update the message of new version notification (#210)
* build on testing * build on testing * remove the testing code * update new version notification * remove the testing pipeline
1 parent 130de12 commit 38f318f

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

app/services/output_manager/message_handler.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,16 @@ def container_registry_share_project_success(role, project, username):
353353

354354
@staticmethod
355355
def newer_version_available(version, download_url, print_message=True):
356-
clickable_text = f'\033]8;;{download_url}\033\\latest cli version\033]8;;\033\\'
357-
message = (
358-
f'\nNewer version available! Pilotcli v{version} is available. Please vist \n{clickable_text}. '
359-
'This link will expire in 10 minutes. If the link doesn\'t show up, Please visit the \n'
360-
'support page on portal to download the latest version.'
361-
)
356+
message = f"""
357+
🚀 **Newer Version Available!**
358+
**Pilotcli v{version}** is now available.
359+
360+
🔗 **Download Here:**
361+
[Linux Version (v{version})]({download_url})
362+
363+
⏳ **Note:** This link will expire in **10 minutes**.
364+
If the download link doesn’t work, please visit the **support page** on the portal to get the latest version.
365+
"""
362366
if print_message:
363367
logger.warning(message)
364368

app/utils/aggregated.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import app.services.logger_services.log_functions as logger
1818
from app.configs.app_config import AppConfig
19-
from app.configs.user_config import UserConfig
2019
from app.models.item import ItemStatus
2120
from app.models.item import ItemType
2221
from app.services.clients.base_auth_client import BaseAuthClient
@@ -234,13 +233,17 @@ def remove_the_output_file(filepath: str) -> None:
234233

235234

236235
def get_latest_cli_version() -> Tuple[Version, str]:
236+
'''
237+
Summary:
238+
Get the latest version of the CLI and download link
239+
from backend.
240+
Returns:
241+
- latest_version(Version): the latest version of the CLI
242+
- download_url(str): the download link of the CLI
243+
'''
237244

238245
try:
239246
httpx_client = BaseClient(AppConfig.Connections.url_fileops_greenroom)
240-
user_config = UserConfig()
241-
if not user_config.is_access_token_exists():
242-
return Version('0.0.0')
243-
244247
headers = {'Authorization': 'Bearer'}
245248
response = httpx_client._get('v1/download/cli/presigned', headers=headers)
246249
result = response.json().get('result', {})

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "app"
3-
version = "3.15.2"
3+
version = "3.16.0"
44
description = "This service is designed to support pilot platform"
55
authors = ["Indoc Systems"]
66

tests/app/commands/test_user.py

+3-13
Original file line numberDiff line numberDiff line change
@@ -93,39 +93,32 @@ def test_login_command_with_newer_version_available_message(
9393
api_key = fake.pystr(20)
9494
monkeypatch.setenv('PILOT_API_KEY', api_key)
9595
login_using_api_key_mock = mocker.patch('app.commands.user.login_using_api_key', return_value=True)
96-
access_token_exists = mocker.patch('app.utils.aggregated.UserConfig.is_access_token_exists', return_value=True)
9796

9897
download_url = fake.url()
9998
httpx_mock.add_response(
10099
url=AppConfig.Connections.url_fileops_greenroom + '/v1/download/cli/presigned',
101100
status_code=200,
102-
json={'result': {'linux': {'version': new_version, 'url': download_url}}},
101+
json={'result': {'linux': {'version': new_version, 'download_url': download_url}}},
103102
)
104103
mocker.patch('pkg_resources.get_distribution', return_value=mocker.Mock(version=current_version))
105104

106105
result = cli_runner.invoke(login)
107106

108107
assert result.exit_code == 0
109108
assert login_using_api_key_mock.called_once_with(api_key)
110-
assert access_token_exists.called_once()
111109
if Version(current_version) < Version(new_version):
112-
clickable_text = f'\033]8;;{download_url}\033\\latest cli version\033]8;;\033\\'
113-
expected_message = result.output.replace(
114-
'\x1b]8;;\x1b\\latest cli version\x1b]8;;\x1b\\', clickable_text
115-
).strip()
116-
actual_message = mhandler.SrvOutPutHandler.newer_version_available(
110+
except_message = mhandler.SrvOutPutHandler.newer_version_available(
117111
new_version, download_url, print_message=False
118112
)
119113

120-
assert actual_message.strip() == expected_message.split('\n\n')[1].strip()
114+
assert except_message in result.output
121115

122116

123117
# nothing should be printed out
124118
def test_login_command_when_url_link_fails(mocker, cli_runner, fake, monkeypatch, httpx_mock):
125119
api_key = fake.pystr(20)
126120
monkeypatch.setenv('PILOT_API_KEY', api_key)
127121
mocker.patch('app.commands.user.login_using_api_key', return_value=True)
128-
access_token_exists = mocker.patch('app.utils.aggregated.UserConfig.is_access_token_exists', return_value=True)
129122

130123
httpx_mock.add_response(
131124
url=AppConfig.Connections.url_fileops_greenroom + '/v1/download/cli/presigned',
@@ -136,17 +129,14 @@ def test_login_command_when_url_link_fails(mocker, cli_runner, fake, monkeypatch
136129

137130
result = cli_runner.invoke(login)
138131
assert result.exit_code == 0
139-
assert access_token_exists.called_once()
140132

141133

142134
# nothing should be printed out
143135
def test_help_command_without_login(mocker, cli_runner, fake, monkeypatch, httpx_mock):
144136
api_key = fake.pystr(20)
145137
monkeypatch.setenv('PILOT_API_KEY', api_key)
146138
mocker.patch('app.commands.user.login_using_api_key', return_value=True)
147-
access_token_exists = mocker.patch('app.utils.aggregated.UserConfig.is_access_token_exists', return_value=True)
148139
mocker.patch('pkg_resources.get_distribution', return_value=mocker.Mock(version='1.0.0'))
149140

150141
result = cli_runner.invoke(login)
151142
assert result.exit_code == 0
152-
assert access_token_exists.called_once()

0 commit comments

Comments
 (0)