From 6b956bf8c7f57b6f212b481ef999d34bafb233f7 Mon Sep 17 00:00:00 2001 From: Tommaso Bailetti Date: Fri, 22 Sep 2023 09:54:11 +0200 Subject: [PATCH] fix: fixed configuration insertion for members --- src/nethsec/mwan/__init__.py | 4 ++-- tests/test_mwan.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/nethsec/mwan/__init__.py b/src/nethsec/mwan/__init__.py index df861acb..6ffbbbdb 100644 --- a/src/nethsec/mwan/__init__.py +++ b/src/nethsec/mwan/__init__.py @@ -107,7 +107,7 @@ def __store_member(e_uci: EUci, interface_name: str, metric: int, weight: int) - e_uci.set('mwan3', member_config_name, 'interface', interface_name) e_uci.set('mwan3', member_config_name, 'metric', metric) e_uci.set('mwan3', member_config_name, 'weight', weight) - return f'mwan3.{member_config_name}', changed + return member_config_name, changed def store_policy(e_uci: EUci, name: str, interfaces: list[dict]) -> list[str]: @@ -149,7 +149,7 @@ def store_policy(e_uci: EUci, name: str, interfaces: list[dict]) -> list[str]: interface['weight']) member_names.append(member_config_name) if member_created: - changed_config.append(member_config_name) + changed_config.append(f'mwan3.{member_config_name}') e_uci.set('mwan3', policy_config_name, 'use_member', member_names) diff --git a/tests/test_mwan.py b/tests/test_mwan.py index f5adcbe7..0bcc2f48 100644 --- a/tests/test_mwan.py +++ b/tests/test_mwan.py @@ -129,9 +129,9 @@ def test_interface_avoid_edit_of_metric(e_uci): def test_create_member(e_uci): - assert mwan.__store_member(e_uci, 'RED_1', 10, 100) == ('mwan3.ns_RED_1_M10_W100', True) - assert mwan.__store_member(e_uci, 'RED_1', 10, 100) == ('mwan3.ns_RED_1_M10_W100', False) - assert mwan.__store_member(e_uci, 'RED_1', 1, 100) == ('mwan3.ns_RED_1_M1_W100', True) + assert mwan.__store_member(e_uci, 'RED_1', 10, 100) == ('ns_RED_1_M10_W100', True) + assert mwan.__store_member(e_uci, 'RED_1', 10, 100) == ('ns_RED_1_M10_W100', False) + assert mwan.__store_member(e_uci, 'RED_1', 1, 100) == ('ns_RED_1_M1_W100', True) def test_create_default_mwan(e_uci): @@ -157,7 +157,7 @@ def test_create_default_mwan(e_uci): assert e_uci.get('mwan3', 'ns_default') == 'policy' assert e_uci.get('mwan3', 'ns_default', 'name') == 'default' assert e_uci.get('mwan3', 'ns_default', 'use_member', list=True) == ( - 'mwan3.ns_RED_1_M10_W200', 'mwan3.ns_RED_2_M20_W100') + 'ns_RED_1_M10_W200', 'ns_RED_2_M20_W100') def test_create_unique_mwan(e_uci):