Feature/deploy target config bug fix #143
GitHub Actions / ansible-test (3.9) results
failed
Mar 20, 2024 in 0s
20 tests run, 19 passed, 0 skipped, 1 failed.
Annotations
Check failure on line 10 in tests/unit/plugins/action/test_determine_updates_required.py
github-actions / ansible-test (3.9) results
tests/unit/plugins/action/test_determine_updates_required.py.test_update_required
self = <ansible_collections.lagoon.api.tests.unit.plugins.action.test_determine_updates_required.DetermineUpdatesTester testMethod=test_update_required>
def test_update_required(self):
existing_configs = []
desired_configs = [
{
'branches': '^(main)$',
'deployTarget': 1,
'pullrequests': 'false',
}
]
> addition_required, deletion_required = determine_required_updates(existing_configs, desired_configs)
tests/unit/plugins/action/test_determine_updates_required.py:21:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
existing_configs = []
desired_configs = [{'branches': '^(main)$', 'deployTarget': 1, 'pullrequests': 'false'}]
def determine_required_updates(existing_configs, desired_configs):
addition_required = []
deletion_required = []
# Step 1: Group existing configurations by key attributes
grouped_configs = {}
for config in existing_configs:
key = (config['branches'], config['pullrequests'], str(config['deployTarget']['id']), str(config['weight']))
if key not in grouped_configs:
grouped_configs[key] = []
grouped_configs[key].append(config)
for key, configs in grouped_configs.items():
if len(configs) > 1:
sorted_configs = sorted(configs, key=lambda x: x['id'], reverse=True)
newest_config = sorted_configs[0]
for config in sorted_configs[1:]:
deletion_required.append(config['id'])
print(f"Marked older duplicate configurations for deletion based on key {key}, keeping newest configuration with ID {newest_config['id']}.")
grouped_configs[key] = [newest_config]
for desired in desired_configs:
> key = (desired['branches'], desired['pullrequests'], str(desired['deployTarget']), str(desired['weight']))
E KeyError: 'weight'
plugins/action/deploy_target_config.py:117: KeyError
Raw output
self = <ansible_collections.lagoon.api.tests.unit.plugins.action.test_determine_updates_required.DetermineUpdatesTester testMethod=test_update_required>
def test_update_required(self):
existing_configs = []
desired_configs = [
{
'branches': '^(main)$',
'deployTarget': 1,
'pullrequests': 'false',
}
]
> addition_required, deletion_required = determine_required_updates(existing_configs, desired_configs)
tests/unit/plugins/action/test_determine_updates_required.py:21:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
existing_configs = []
desired_configs = [{'branches': '^(main)$', 'deployTarget': 1, 'pullrequests': 'false'}]
def determine_required_updates(existing_configs, desired_configs):
addition_required = []
deletion_required = []
# Step 1: Group existing configurations by key attributes
grouped_configs = {}
for config in existing_configs:
key = (config['branches'], config['pullrequests'], str(config['deployTarget']['id']), str(config['weight']))
if key not in grouped_configs:
grouped_configs[key] = []
grouped_configs[key].append(config)
for key, configs in grouped_configs.items():
if len(configs) > 1:
sorted_configs = sorted(configs, key=lambda x: x['id'], reverse=True)
newest_config = sorted_configs[0]
for config in sorted_configs[1:]:
deletion_required.append(config['id'])
print(f"Marked older duplicate configurations for deletion based on key {key}, keeping newest configuration with ID {newest_config['id']}.")
grouped_configs[key] = [newest_config]
for desired in desired_configs:
> key = (desired['branches'], desired['pullrequests'], str(desired['deployTarget']), str(desired['weight']))
E KeyError: 'weight'
plugins/action/deploy_target_config.py:117: KeyError
Loading