|
58 | 58 | },
|
59 | 59 | },
|
60 | 60 | },
|
| 61 | + "test_module_4": { |
| 62 | + "hasync_parent": "hasync", |
| 63 | + "remote_system_username": "hasync/username", |
| 64 | + "php_requirements": ["req_1", "req_2"], |
| 65 | + "configure_functions": { |
| 66 | + "test_configure_function": { |
| 67 | + "name": "test_configure_function", |
| 68 | + "configure_params": ["param_1"], |
| 69 | + }, |
| 70 | + }, |
| 71 | + }, |
61 | 72 | "missing_php_requirements": {
|
62 | 73 | "setting_1": "settings/one",
|
63 | 74 | "setting_2": "settings/two",
|
|
105 | 116 | <one>1</one>
|
106 | 117 | <two>2</two>
|
107 | 118 | </settings>
|
| 119 | + <hasync> |
| 120 | + <username /> |
| 121 | + </hasync> |
108 | 122 | </opnsense>
|
109 | 123 | """
|
110 | 124 |
|
@@ -527,3 +541,36 @@ def test_set_with_missing_element(sample_config_path):
|
527 | 541 | },
|
528 | 542 | }
|
529 | 543 | new_config.save()
|
| 544 | + |
| 545 | + |
| 546 | +def test_fail_set_on_parent_node(sample_config_path): |
| 547 | + """ |
| 548 | + Test case to verify that setting a value for a parent node will fail. |
| 549 | +
|
| 550 | + Args: |
| 551 | + - sample_config_path (str): The path to the temporary test configuration file. |
| 552 | + """ |
| 553 | + with OPNsenseModuleConfig( |
| 554 | + module_name="test_module_4", |
| 555 | + config_context_names=["test_module_4"], |
| 556 | + path=sample_config_path, |
| 557 | + check_mode=False, |
| 558 | + ) as new_config: |
| 559 | + with pytest.raises(AttributeError): |
| 560 | + new_config.set("test", "hasync_parent") |
| 561 | + |
| 562 | + |
| 563 | +def test_success_set_on_empty_leaf_node(sample_config_path): |
| 564 | + """ |
| 565 | + Test case to verify that setting a leaf node with a value of None will succeed. |
| 566 | + - sample_config_path (str): The path to the temporary test configuration file. |
| 567 | + """ |
| 568 | + with OPNsenseModuleConfig( |
| 569 | + module_name="test_module_4", |
| 570 | + config_context_names=["test_module_4"], |
| 571 | + path=sample_config_path, |
| 572 | + check_mode=False, |
| 573 | + ) as new_config: |
| 574 | + new_config.set("test", "remote_system_username") |
| 575 | + assert new_config.get("remote_system_username").text == "test" |
| 576 | + new_config.save() |
0 commit comments