summaryrefslogtreecommitdiff
path: root/.github/instructions/tests.instructions.md
diff options
context:
space:
mode:
Diffstat (limited to '.github/instructions/tests.instructions.md')
-rw-r--r--.github/instructions/tests.instructions.md10
1 files changed, 9 insertions, 1 deletions
diff --git a/.github/instructions/tests.instructions.md b/.github/instructions/tests.instructions.md
index 66f08f88..150db41e 100644
--- a/.github/instructions/tests.instructions.md
+++ b/.github/instructions/tests.instructions.md
@@ -20,15 +20,23 @@ class TestVyosFooModule(TestVyosModule):
## Mocking: resource modules
-Resource module tests require two framework-level patches in `setUp`:
+Resource module tests require two framework-level patches in `setUp` with corresponding cleanup in `tearDown`:
```python
+# in setUp:
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
)
+self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
+
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
+self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
+
+# in tearDown:
+self.mock_get_resource_connection_config.stop()
+self.mock_get_resource_connection_facts.stop()
```
Most resource module tests also patch the facts class's `get_device_data` method directly and use it in `load_fixtures`: