tweak test_configurable_parameters.py: add iff_present flag

apply a parameter only when it exists in the template, will be useful
for suci

Change-Id: I5811ecde4c4e880bb8dbd22fffe23faafcfe36ad
This commit is contained in:
Neels Hofmeyr
2026-04-25 06:06:20 +02:00
parent a1a85c3214
commit d28cf0a05e

View File

@@ -60,11 +60,12 @@ class ConfigurableParameterTest(unittest.TestCase):
)
class Paramtest:
def __init__(self, param_cls, val, expect_val, expect_clean_val=None):
def __init__(self, param_cls, val, expect_val, expect_clean_val=None, iff_present=False):
self.param_cls = param_cls
self.val = val
self.expect_clean_val = expect_clean_val
self.expect_val = expect_val
self.iff_present = iff_present
param_tests = [
Paramtest(param_cls=p13n.Imsi, val='123456',
@@ -397,6 +398,13 @@ class ConfigurableParameterTest(unittest.TestCase):
found = list((t.param_cls.get_value_from_pes(pes) or {}).values())
testlog.append(f"previous value: {found}")
if t.iff_present and not found:
testlog.append("skipping, param not in template.")
output = "\nskip: " + "\n ".join(testlog)
outputs.append(output)
print(output)
continue
try:
param.apply(pes)
except ValueError as e: