-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
427 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/middlewared/middlewared/pytest/unit/plugins/catalog/test_custom_scale_version_checks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
|
||
from middlewared.plugins.catalog.apps_util import custom_scale_version_checks | ||
|
||
|
||
@pytest.mark.parametrize('min_version, max_version, sys_scale_version, expected', [ | ||
( | ||
'21.0', | ||
'23.1', | ||
'22.01', | ||
'' | ||
), | ||
( | ||
'22.15', | ||
'21.05', | ||
'22.01', | ||
'Your TrueNAS system version (22.01) is less than the minimum version (22.15) required by this application.' | ||
), | ||
( | ||
'22.01', | ||
'23.01', | ||
'22.01', | ||
'' | ||
), | ||
( | ||
'22.01', | ||
'23.02', | ||
'24.05', | ||
'Your TrueNAS system version (24.05) is greater than the maximum version (23.02) required by this application.' | ||
), | ||
( | ||
'22.01', | ||
'21.03', | ||
'22.0', | ||
'Unable to determine your TrueNAS system version' | ||
) | ||
]) | ||
def test_custom_scale_version(min_version, max_version, sys_scale_version, expected): | ||
result = custom_scale_version_checks(min_version, max_version, sys_scale_version) | ||
assert result == expected |
152 changes: 152 additions & 0 deletions
152
src/middlewared/middlewared/pytest/unit/plugins/catalog/test_get_app_details.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import pytest | ||
|
||
from middlewared.plugins.catalog.apps_util import get_app_details | ||
|
||
|
||
@pytest.mark.parametrize('app_data, versions, expected', [ | ||
( | ||
{ | ||
'app_readme': '', | ||
'categories': [ | ||
'media' | ||
], | ||
'description': '', | ||
'healthy': True, | ||
'healthy_error': None, | ||
'home': 'https://actualbudget.org', | ||
'location': '/mnt/.ix-apps/truenas_catalog/trains/community/actual-budget', | ||
'latest_version': '1.1.11', | ||
'latest_app_version': '24.10.1', | ||
'latest_human_version': '24.10.1_1.1.11', | ||
'last_update': '12-02-21 00:00:00', | ||
'name': 'actual-budget', | ||
'recommended': False, | ||
'title': 'Actual Budget', | ||
}, | ||
{ | ||
'1.0.1': { | ||
'name': 'chia', | ||
'categories': [], | ||
'app_readme': None, | ||
'location': '/mnt/mypool/ix-applications/catalogs/' | ||
'github_com_truenas_charts_git_master/charts/chia', | ||
'healthy': True, | ||
'supported': True, | ||
'healthy_error': None, | ||
'supported': True, | ||
'required_features': [], | ||
'version': '1.0.1', | ||
'human_version': '1.15.12', | ||
'home': None, | ||
'readme': None, | ||
'changelog': None, | ||
'last_update': '1200-20-00 00:00:00', | ||
'app_metadata': { | ||
'name': 'chia', | ||
'train': 'stable', | ||
'version': '1.0.1', | ||
'app_version': '1.0.1', | ||
'title': 'chia', | ||
'description': 'desc', | ||
'home': 'None', | ||
}, | ||
'schema': { | ||
"groups": [], | ||
"questions": [] | ||
} | ||
} | ||
}, | ||
{ | ||
'app_readme': '', | ||
'categories': ['media'], | ||
'description': '', | ||
'healthy': True, | ||
'healthy_error': None, | ||
'home': 'https://actualbudget.org', | ||
'location': '/mnt/.ix-apps/truenas_catalog/trains/community/actual-budget', | ||
'latest_version': '1.1.11', | ||
'latest_app_version': '24.10.1', | ||
'latest_human_version': '24.10.1_1.1.11', | ||
'last_update': '12-02-21 00:00:00', | ||
'name': 'actual-budget', | ||
'recommended': False, | ||
'title': 'Actual Budget', | ||
'versions': { | ||
'1.0.1': { | ||
'name': 'chia', | ||
'categories': [], | ||
'app_readme': None, | ||
'location': '/path/to/app/1.0.1', | ||
'healthy': True, | ||
'supported': True, | ||
'healthy_error': None, | ||
'required_features': [], | ||
'version': '1.0.1', | ||
'human_version': '1.15.12', | ||
'home': None, | ||
'readme': None, | ||
'changelog': None, | ||
'last_update': '1200-20-00 00:00:00', | ||
'app_metadata': { | ||
'name': 'chia', | ||
'train': 'stable', | ||
'version': '1.0.1', | ||
'app_version': '1.0.1', | ||
'title': 'chia', | ||
'description': 'desc', | ||
'home': 'None', | ||
}, | ||
'schema': { | ||
'groups': [], | ||
'questions': [] | ||
}, | ||
'values': {} | ||
} | ||
} | ||
} | ||
), | ||
( | ||
{ | ||
'app_readme': '', | ||
'categories': [ | ||
'media' | ||
], | ||
'description': '', | ||
'healthy': True, | ||
'healthy_error': None, | ||
'home': 'https://actualbudget.org', | ||
'location': '/mnt/.ix-apps/truenas_catalog/trains/community/actual-budget', | ||
'latest_version': '1.1.11', | ||
'latest_app_version': '24.10.1', | ||
'latest_human_version': '24.10.1_1.1.11', | ||
'last_update': '12-02-21 00:00:00', | ||
'name': 'actual-budget', | ||
'recommended': False, | ||
'title': 'Actual Budget', | ||
}, | ||
{}, | ||
{ | ||
'app_readme': '', | ||
'categories': ['media'], | ||
'description': '', | ||
'healthy': True, | ||
'healthy_error': None, | ||
'home': 'https://actualbudget.org', | ||
'location': '/mnt/.ix-apps/truenas_catalog/trains/community/actual-budget', | ||
'latest_version': '1.1.11', | ||
'latest_app_version': '24.10.1', | ||
'latest_human_version': '24.10.1_1.1.11', | ||
'last_update': '12-02-21 00:00:00', | ||
'name': 'actual-budget', | ||
'recommended': False, | ||
'title': 'Actual Budget', | ||
'versions': {} | ||
} | ||
), | ||
]) | ||
def test_get_app_details(mocker, app_data, versions, expected): | ||
mocker.patch('middlewared.plugins.catalog.apps_util.normalize_questions') | ||
mocker.patch('middlewared.plugins.catalog.apps_util.retrieve_cached_versions_data', return_value=versions) | ||
if isinstance(expected, dict): | ||
result = get_app_details('/path/to/app', app_data, {}) | ||
assert expected == result |
155 changes: 155 additions & 0 deletions
155
src/middlewared/middlewared/pytest/unit/plugins/catalog/test_min_max_scale_version_update.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import pytest | ||
|
||
from middlewared.plugins.catalog.apps_util import minimum_scale_version_check_update | ||
|
||
|
||
@pytest.mark.parametrize('version_data, expected', [ | ||
( | ||
{ | ||
'healthy': True, | ||
'supported': True, | ||
'healthy_error': None, | ||
'location': '/mnt/.ix-apps/truenas_catalog/trains/community/actual-budget/1.1.11', | ||
'last_update': '2024-10-09 20:30:25', | ||
'human_version': '24.10.1_1.1.11', | ||
'chart_metadata': { | ||
'annotations': { | ||
'min_scale_version': '21.01', | ||
'max_scale_version': '24.04' | ||
} | ||
}, | ||
'version': '1.1.11', | ||
'schema': { | ||
'groups': [ | ||
{ | ||
'name': 'Actual Budget Configuration', | ||
'description': 'Configure Actual Budget' | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
'healthy': True, | ||
'supported': False, | ||
'healthy_error': None, | ||
'location': '/mnt/.ix-apps/truenas_catalog/trains/community/actual-budget/1.1.11', | ||
'last_update': '2024-10-09 20:30:25', | ||
'human_version': '24.10.1_1.1.11', | ||
'chart_metadata': { | ||
'annotations': { | ||
'min_scale_version': '21.01', | ||
'max_scale_version': '24.04' | ||
} | ||
}, | ||
'version': '1.1.11', | ||
'schema': { | ||
'groups': [ | ||
{ | ||
'name': 'Actual Budget Configuration', | ||
'description': 'Configure Actual Budget' | ||
} | ||
] | ||
} | ||
} | ||
), | ||
( | ||
{ | ||
'healthy': True, | ||
'supported': True, | ||
'healthy_error': None, | ||
'location': '/mnt/.ix-apps/truenas_catalog/trains/community/actual-budget/1.1.11', | ||
'last_update': '2024-10-09 20:30:25', | ||
'human_version': '24.10.1_1.1.11', | ||
'chart_metadata': { | ||
'annotations': { | ||
'min_scale_version': '21.01', | ||
'max_scale_version': '27.04' | ||
} | ||
}, | ||
'version': '1.1.11', | ||
'schema': { | ||
'groups': [ | ||
{ | ||
'name': 'Actual Budget Configuration', | ||
'description': 'Configure Actual Budget' | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
'healthy': True, | ||
'supported': True, | ||
'healthy_error': None, | ||
'location': '/mnt/.ix-apps/truenas_catalog/trains/community/actual-budget/1.1.11', | ||
'last_update': '2024-10-09 20:30:25', | ||
'human_version': '24.10.1_1.1.11', | ||
'chart_metadata': { | ||
'annotations': { | ||
'min_scale_version': '21.01', | ||
'max_scale_version': '27.04' | ||
} | ||
}, | ||
'version': '1.1.11', | ||
'schema': { | ||
'groups': [ | ||
{ | ||
'name': 'Actual Budget Configuration', | ||
'description': 'Configure Actual Budget' | ||
} | ||
] | ||
} | ||
} | ||
), | ||
( | ||
{ | ||
'healthy': True, | ||
'supported': True, | ||
'healthy_error': None, | ||
'location': '/mnt/.ix-apps/truenas_catalog/trains/community/actual-budget/1.1.11', | ||
'last_update': '2024-10-09 20:30:25', | ||
'human_version': '24.10.1_1.1.11', | ||
'chart_metadata': { | ||
'annotations': { | ||
'min_scale_version': '26.04', | ||
'max_scale_version': '24.04' | ||
} | ||
}, | ||
'version': '1.1.11', | ||
'schema': { | ||
'groups': [ | ||
{ | ||
'name': 'Actual Budget Configuration', | ||
'description': 'Configure Actual Budget' | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
'healthy': True, | ||
'supported': False, | ||
'healthy_error': None, | ||
'location': '/mnt/.ix-apps/truenas_catalog/trains/community/actual-budget/1.1.11', | ||
'last_update': '2024-10-09 20:30:25', | ||
'human_version': '24.10.1_1.1.11', | ||
'chart_metadata': { | ||
'annotations': { | ||
'min_scale_version': '26.04', | ||
'max_scale_version': '24.04' | ||
} | ||
}, | ||
'version': '1.1.11', | ||
'schema': { | ||
'groups': [ | ||
{ | ||
'name': 'Actual Budget Configuration', | ||
'description': 'Configure Actual Budget' | ||
} | ||
] | ||
} | ||
} | ||
), | ||
]) | ||
def test_min_max_scale_version_update(mocker, version_data, expected): | ||
mocker.patch('middlewared.plugins.catalog.apps_util.sw_info', return_value={'version': '25.04.0'}) | ||
result = minimum_scale_version_check_update(version_data) | ||
assert result == expected |
Oops, something went wrong.