From 3af29683164a0acbd50c695161d85bf591c4e6d5 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 19 Oct 2024 12:31:31 +0200 Subject: [PATCH 01/12] Update links to stable-2. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a773b72..9149046 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Browsing the [**latest** collection documentation](https://docs.ansible.com/ansi Browsing the [**devel** collection documentation](https://docs.ansible.com/ansible/devel/collections/community/routeros) shows docs for the _latest version released on Galaxy_. -We also separately publish [**latest commit** collection documentation](https://ansible-collections.github.io/community.routeros/branch/main/) which shows docs for the _latest commit in the `main` branch_. +We also separately publish [**latest commit** collection documentation](https://ansible-collections.github.io/community.routeros/branch/stable-2/) which shows docs for the _latest commit in the `stable-2` branch_. If you use the Ansible package and do not update collections independently, use **latest**. If you install or update this collection directly from Galaxy, use **devel**. If you are looking to contribute, use **latest commit**. @@ -183,7 +183,7 @@ See [Ansible's dev guide](https://docs.ansible.com/ansible/devel/dev_guide/devel ## Release notes -See the [collection's changelog](https://github.com/ansible-collections/community.routeros/blob/main/CHANGELOG.md). +See the [collection's changelog](https://github.com/ansible-collections/community.routeros/blob/stable-2/CHANGELOG.md). ## Roadmap @@ -203,8 +203,8 @@ We plan to regularly release minor and patch versions, whenever new features are This collection is primarily licensed and distributed as a whole under the GNU General Public License v3.0 or later. -See [LICENSES/GPL-3.0-or-later.txt](https://github.com/ansible-collections/community.routeros/blob/main/COPYING) for the full text. +See [LICENSES/GPL-3.0-or-later.txt](https://github.com/ansible-collections/community.routeros/blob/stable-2/COPYING) for the full text. -Parts of the collection are licensed under the [BSD 2-Clause license](https://github.com/ansible-collections/community.routeros/blob/main/LICENSES/BSD-2-Clause.txt). +Parts of the collection are licensed under the [BSD 2-Clause license](https://github.com/ansible-collections/community.routeros/blob/stable-2/LICENSES/BSD-2-Clause.txt). All files have a machine readable `SDPX-License-Identifier:` comment denoting its respective license(s) or an equivalent entry in an accompanying `.license` file. Only changelog fragments (which will not be part of a release) are covered by a blanket statement in `.reuse/dep5`. This conforms to the [REUSE specification](https://reuse.software/spec/). From b0453b2e4785403e27e33c0b992e39a82de87a90 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 19 Oct 2024 12:34:51 +0200 Subject: [PATCH 02/12] Fix reuse workflow branches. (cherry picked from commit 5fdbd52303a419b4033b26cebc6f8cfdcd50c763) --- .github/workflows/reuse.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml index 7c15c11..b552396 100644 --- a/.github/workflows/reuse.yml +++ b/.github/workflows/reuse.yml @@ -7,9 +7,13 @@ name: Verify REUSE on: push: - branches: [main] + branches: + - main + - stable-* pull_request: - branches: [main] + branches: + - main + - stable-* # Run CI once per day (at 05:15 UTC) schedule: - cron: '15 5 * * *' From 353027cb5cace3316e6238f7d2b8e4304458be8a Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 15:17:24 +0100 Subject: [PATCH 03/12] Fix some issues pointed out by zizmor. (#333) (#334) (cherry picked from commit 995ab18e7bf30886030394cbabeed07bde785333) Co-authored-by: Felix Fontein --- .github/workflows/ee.yml | 3 ++- .github/workflows/extra-tests.yml | 1 + .github/workflows/reuse.yml | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ee.yml b/.github/workflows/ee.yml index cd6341f..32c0c50 100644 --- a/.github/workflows/ee.yml +++ b/.github/workflows/ee.yml @@ -68,6 +68,7 @@ jobs: uses: actions/checkout@v4 with: path: ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }} + persist-credentials: false - name: Set up Python uses: actions/setup-python@v5 @@ -101,7 +102,7 @@ jobs: - name: Create files for building execution environment run: | - COLLECTION_FILENAME="$(ls "${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}"-*.tar.gz)" + COLLECTION_FILENAME="$(ls "${NAMESPACE}-${COLLECTION_NAME}"-*.tar.gz)" # EE config cat > execution-environment.yml < Date: Sat, 28 Dec 2024 14:27:15 +0100 Subject: [PATCH 04/12] Improve language. (cherry picked from commit 77de6d90bf22582d3ac194a0681e9fc1f40a6314) --- plugins/module_utils/_api_data.py | 2 +- plugins/module_utils/api.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/_api_data.py b/plugins/module_utils/_api_data.py index 847f5b1..e4a5182 100644 --- a/plugins/module_utils/_api_data.py +++ b/plugins/module_utils/_api_data.py @@ -5142,7 +5142,7 @@ PATHS = { 'protocol': KeyInfo(default='all'), 'src-address': KeyInfo(), 'src-port': KeyInfo(default='any'), - # The template field can't really be changed once the item is + # The template field ca not really be changed once the item is # created. This config captures the behavior best as it can # i.e. template=yes is shown, template=no is hidden. 'template': KeyInfo(can_disable=True, remove_value=False), diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 6c276d7..aa3aa2e 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -77,7 +77,7 @@ def _ros_api_connect(module, username, password, host, port, use_tls, force_no_c elif not validate_cert_hostname: ctx.check_hostname = False else: - # Since librouteros doesn't pass server_hostname, + # Since librouteros does not pass server_hostname, # we have to do this ourselves: def wrap_context(*args, **kwargs): kwargs.pop('server_hostname', None) From f8f86f6ec0b814860128d60d5ea9ebeafcedd54e Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 4 Jan 2025 11:25:03 +0100 Subject: [PATCH 05/12] Fix CI badge image URL. Add documentation badge. (cherry picked from commit 1466c9f984e4570f8c4d530daa868e4348101dff) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9149046..b11b3b1 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ SPDX-License-Identifier: GPL-3.0-or-later --> # Community RouterOS Collection -[![CI](https://github.com/ansible-collections/community.routeros/workflows/CI/badge.svg?event=push)](https://github.com/ansible-collections/community.routeros/actions) +[![Documentation](https://img.shields.io/badge/docs-brightgreen.svg)](https://docs.ansible.com/ansible/latest/collections/community/routeros/) +[![CI](https://github.com/ansible-collections/community.routeros/actions/workflows/ansible-test.yml/badge.svg?branch=stable-2)](https://github.com/ansible-collections/community.routeros/actions) [![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/community.routeros)](https://codecov.io/gh/ansible-collections/community.routeros) [![REUSE status](https://api.reuse.software/badge/github.com/ansible-collections/community.routeros)](https://api.reuse.software/info/github.com/ansible-collections/community.routeros) From c5f1fb50d7f3de3a1893fd8284c94be99e33b072 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 7 Mar 2025 20:45:39 +0100 Subject: [PATCH 06/12] Improve tests (#348) * Simplify filter error tests. * Convert set_module_args to context manager. (cherry picked from commit be9a7ed3ad9db5d8e83f768b8cd600d2af5347f7) --- .../targets/filter_quoting/tasks/main.yml | 2 +- tests/unit/plugins/modules/test_api.py | 76 ++++---- tests/unit/plugins/modules/test_api_facts.py | 12 +- .../modules/test_api_find_and_modify.py | 68 +++---- tests/unit/plugins/modules/test_api_info.py | 72 ++++---- tests/unit/plugins/modules/test_api_modify.py | 172 +++++++++--------- tests/unit/plugins/modules/test_command.py | 36 ++-- tests/unit/plugins/modules/test_facts.py | 20 +- tests/unit/plugins/modules/utils.py | 7 +- 9 files changed, 234 insertions(+), 231 deletions(-) diff --git a/tests/integration/targets/filter_quoting/tasks/main.yml b/tests/integration/targets/filter_quoting/tasks/main.yml index e7a2d29..c80af59 100644 --- a/tests/integration/targets/filter_quoting/tasks/main.yml +++ b/tests/integration/targets/filter_quoting/tasks/main.yml @@ -22,7 +22,7 @@ assert: that: - >- - result.msg == "Unexpected end of string during escaped parameter" + "Unexpected end of string during escaped parameter" in result.msg - name: "Test quote_argument filter" assert: diff --git a/tests/unit/plugins/modules/test_api.py b/tests/unit/plugins/modules/test_api.py index 4cfdeef..5df8430 100644 --- a/tests/unit/plugins/modules/test_api.py +++ b/tests/unit/plugins/modules/test_api.py @@ -34,8 +34,8 @@ class TestRouterosApiModule(ModuleTestCase): def test_module_fail_when_required_args_missing(self): with self.assertRaises(AnsibleFailJson) as exc: - set_module_args({}) - self.module.main() + with set_module_args({}): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -43,8 +43,8 @@ class TestRouterosApiModule(ModuleTestCase): @patch('ansible_collections.community.routeros.plugins.modules.api.ROS_api_module.api_add_path', new=fake_ros_api.path) def test_api_path(self): with self.assertRaises(AnsibleExitJson) as exc: - set_module_args(self.config_module_args.copy()) - self.module.main() + with set_module_args(self.config_module_args.copy()): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -54,8 +54,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleExitJson) as exc: module_args = self.config_module_args.copy() module_args['add'] = "name=unit_test_brige" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -65,8 +65,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleFailJson) as exc: module_args = self.config_module_args.copy() module_args['add'] = "name=unit_test_brige_exist" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -77,8 +77,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleExitJson) as exc: module_args = self.config_module_args.copy() module_args['remove'] = "*A1" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -88,8 +88,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleFailJson) as exc: module_args = self.config_module_args.copy() module_args['remove'] = "*A2" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -100,8 +100,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleExitJson) as exc: module_args = self.config_module_args.copy() module_args['cmd'] = "add name=unit_test_brige_arbitrary" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -111,8 +111,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleFailJson) as exc: module_args = self.config_module_args.copy() module_args['cmd'] = "add NONE_EXIST=unit_test_brige_arbitrary" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -123,8 +123,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleExitJson) as exc: module_args = self.config_module_args.copy() module_args['update'] = ".id=*A1 name=unit_test_brige" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -134,8 +134,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleFailJson) as exc: module_args = self.config_module_args.copy() module_args['update'] = ".id=*A2 name=unit_test_brige" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -146,8 +146,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleExitJson) as exc: module_args = self.config_module_args.copy() module_args['query'] = ".id name" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -162,8 +162,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleExitJson) as exc: module_args = self.config_module_args.copy() module_args['query'] = ".id other" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -174,8 +174,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleExitJson) as exc: module_args = self.config_module_args.copy() module_args['query'] = ".id name WHERE name == dummy_bridge_A2" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -188,8 +188,8 @@ class TestRouterosApiModule(ModuleTestCase): with self.assertRaises(AnsibleExitJson) as exc: module_args = self.config_module_args.copy() module_args['query'] = ".id name WHERE name != dummy_bridge_A2" - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -204,8 +204,8 @@ class TestRouterosApiModule(ModuleTestCase): module_args['extended_query'] = { 'attributes': ['.id', 'name'], } - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -222,8 +222,8 @@ class TestRouterosApiModule(ModuleTestCase): module_args['extended_query'] = { 'attributes': ['.id', 'other'], } - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -243,8 +243,8 @@ class TestRouterosApiModule(ModuleTestCase): }, ], } - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -266,8 +266,8 @@ class TestRouterosApiModule(ModuleTestCase): }, ], } - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -298,8 +298,8 @@ class TestRouterosApiModule(ModuleTestCase): }, ], } - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) diff --git a/tests/unit/plugins/modules/test_api_facts.py b/tests/unit/plugins/modules/test_api_facts.py index 64985f8..f9c76be 100644 --- a/tests/unit/plugins/modules/test_api_facts.py +++ b/tests/unit/plugins/modules/test_api_facts.py @@ -437,8 +437,8 @@ class TestRouterosApiFactsModule(ModuleTestCase): def test_module_fail_when_required_args_missing(self): with self.assertRaises(AnsibleFailJson) as exc: - set_module_args({}) - self.module.main() + with set_module_args({}): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -447,8 +447,8 @@ class TestRouterosApiFactsModule(ModuleTestCase): with self.assertRaises(AnsibleFailJson) as exc: module_args = self.config_module_args.copy() module_args['gather_subset'] = ['!foobar'] - set_module_args(module_args) - self.module.main() + with set_module_args(module_args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -456,8 +456,8 @@ class TestRouterosApiFactsModule(ModuleTestCase): def test_full_run(self): with self.assertRaises(AnsibleExitJson) as exc: - set_module_args(self.config_module_args.copy()) - self.module.main() + with set_module_args(self.config_module_args.copy()): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) diff --git a/tests/unit/plugins/modules/test_api_find_and_modify.py b/tests/unit/plugins/modules/test_api_find_and_modify.py index 2f47af4..2405d3a 100644 --- a/tests/unit/plugins/modules/test_api_find_and_modify.py +++ b/tests/unit/plugins/modules/test_api_find_and_modify.py @@ -117,8 +117,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): def test_module_fail_when_required_args_missing(self): with self.assertRaises(AnsibleFailJson) as exc: - set_module_args({}) - self.module.main() + with set_module_args({}): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -136,8 +136,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): 'comment': 'bar', }, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -155,8 +155,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): 'comment': 'bar', }, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -173,8 +173,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): '!comment': None, }, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -190,8 +190,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): '!comment': 'gone', }, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -212,8 +212,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): }, 'require_matches_min': 10, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -234,8 +234,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): }, 'require_matches_min': 10, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -256,8 +256,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): }, 'require_matches_max': 1, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -277,8 +277,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): 'name': 'bam', }, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -303,8 +303,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): 'require_matches_min': 2, 'allow_no_matches': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -325,8 +325,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): 'values': { }, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -349,8 +349,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): 'comment': None, }, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -374,8 +374,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): }, '_ansible_diff': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -450,8 +450,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): 'comment': None, }, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -502,8 +502,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): 'comment': '', }, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -553,8 +553,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): '!comment': None, }, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -606,8 +606,8 @@ class TestRouterosApiFindAndModifyModule(ModuleTestCase): '!connection-state': None, }, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) diff --git a/tests/unit/plugins/modules/test_api_info.py b/tests/unit/plugins/modules/test_api_info.py index 1c9d014..d20aa11 100644 --- a/tests/unit/plugins/modules/test_api_info.py +++ b/tests/unit/plugins/modules/test_api_info.py @@ -41,8 +41,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): def test_module_fail_when_required_args_missing(self): with self.assertRaises(AnsibleFailJson) as exc: - set_module_args({}) - self.module.main() + with set_module_args({}): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -53,8 +53,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): args.update({ 'path': 'something invalid' }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -68,8 +68,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): args.update({ 'path': 'ip dns static' }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -93,8 +93,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): args.update({ 'path': 'caps-man aaa', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -122,8 +122,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'path': 'caps-man aaa', 'hide_defaults': False, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -155,8 +155,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'path': 'caps-man aaa', 'unfiltered': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -189,8 +189,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'path': 'ip firewall filter', 'handle_disabled': 'exclamation', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -278,8 +278,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'path': 'ip firewall filter', 'handle_disabled': 'null-value', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -367,8 +367,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'path': 'ip firewall filter', 'handle_disabled': 'omit', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -402,8 +402,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'handle_disabled': 'omit', 'include_dynamic': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -460,8 +460,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'path': 'interface list', 'handle_disabled': 'omit', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -513,8 +513,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'handle_disabled': 'omit', 'include_builtin': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -605,8 +605,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'path': 'ip dhcp-server lease', 'handle_disabled': 'omit', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -688,8 +688,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): args.update({ 'path': 'interface gre', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -776,8 +776,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'handle_disabled': 'omit', 'hide_defaults': False, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -847,8 +847,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'handle_disabled': 'omit', 'restrict': [], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -899,8 +899,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'values': ['forward'], }], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -970,8 +970,8 @@ class TestRouterosApiInfoModule(ModuleTestCase): }, ], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) diff --git a/tests/unit/plugins/modules/test_api_modify.py b/tests/unit/plugins/modules/test_api_modify.py index f4aa777..20e29e1 100644 --- a/tests/unit/plugins/modules/test_api_modify.py +++ b/tests/unit/plugins/modules/test_api_modify.py @@ -318,8 +318,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): def test_module_fail_when_required_args_missing(self): with self.assertRaises(AnsibleFailJson) as exc: - set_module_args({}) - self.module.main() + with set_module_args({}): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -331,8 +331,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'path': 'something invalid', 'data': [], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -348,8 +348,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'foo': 'bar', }], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -366,8 +366,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): '!comment': None, }], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -383,8 +383,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): '!disabled': None, }], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -400,8 +400,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): '!comment': 'foo', }], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -416,8 +416,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'name': None, }], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -432,8 +432,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'interface': 'eth0', }], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -448,8 +448,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'address': '192.168.88.1', }], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -466,8 +466,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'address': '192.168.88.1', }], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['failed'], True) @@ -498,8 +498,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): }, ], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -533,8 +533,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_absent_entries': 'remove', 'handle_entries_content': 'remove', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -556,8 +556,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): }, ], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -591,8 +591,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): }, ], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -656,8 +656,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): }, ], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -722,8 +722,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): ], '_ansible_check_mode': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -785,8 +785,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_absent_entries': 'remove', 'handle_entries_content': 'remove', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -844,8 +844,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_entries_content': 'remove', '_ansible_check_mode': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -903,8 +903,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_absent_entries': 'remove', 'handle_entries_content': 'remove', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -963,8 +963,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_entries_content': 'remove', '_ansible_check_mode': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1017,8 +1017,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_absent_entries': 'remove', 'handle_entries_content': 'remove', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1077,8 +1077,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_entries_content': 'remove', '_ansible_check_mode': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1128,8 +1128,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_absent_entries': 'remove', 'handle_entries_content': 'remove', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1164,8 +1164,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_entries_content': 'remove', '_ansible_check_mode': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1212,8 +1212,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_entries_content': 'remove', 'ensure_order': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1285,8 +1285,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'ensure_order': True, '_ansible_check_mode': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1340,8 +1340,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): }, ], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -1363,8 +1363,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): ], 'handle_entries_content': 'remove', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -1386,8 +1386,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): }, ], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1426,8 +1426,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): ], '_ansible_check_mode': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1466,8 +1466,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): ], 'handle_entries_content': 'remove', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1507,8 +1507,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_entries_content': 'remove', '_ansible_check_mode': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1551,8 +1551,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): }, ], }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -1587,8 +1587,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_absent_entries': 'remove', 'handle_entries_content': 'remove', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -1621,8 +1621,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_absent_entries': 'remove', 'handle_entries_content': 'remove', }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1676,8 +1676,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_entries_content': 'remove', '_ansible_check_mode': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1729,8 +1729,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_entries_content': 'remove', 'ensure_order': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1785,8 +1785,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'ensure_order': True, '_ansible_check_mode': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1847,8 +1847,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_entries_content': 'remove', 'ensure_order': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -1879,8 +1879,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_entries_content': 'remove', 'ensure_order': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -1911,8 +1911,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_entries_content': 'remove', 'ensure_order': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], True) @@ -1969,8 +1969,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_absent_entries': 'remove', 'ensure_order': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) @@ -2005,8 +2005,8 @@ class TestRouterosApiModifyModule(ModuleTestCase): 'handle_absent_entries': 'remove', 'ensure_order': True, }) - set_module_args(args) - self.module.main() + with set_module_args(args): + self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], False) diff --git a/tests/unit/plugins/modules/test_command.py b/tests/unit/plugins/modules/test_command.py index 3fc5865..72fbfd6 100644 --- a/tests/unit/plugins/modules/test_command.py +++ b/tests/unit/plugins/modules/test_command.py @@ -47,54 +47,54 @@ class TestRouterosCommandModule(TestRouterosModule): self.run_commands.side_effect = load_from_file def test_command_simple(self): - set_module_args(dict(commands=['/system resource print'])) - result = self.execute_module(changed=True) + with set_module_args(dict(commands=['/system resource print'])): + result = self.execute_module(changed=True) self.assertEqual(len(result['stdout']), 1) self.assertTrue('platform: "MikroTik"' in result['stdout'][0]) def test_command_multiple(self): - set_module_args(dict(commands=['/system resource print', '/system resource print'])) - result = self.execute_module(changed=True) + with set_module_args(dict(commands=['/system resource print', '/system resource print'])): + result = self.execute_module(changed=True) self.assertEqual(len(result['stdout']), 2) self.assertTrue('platform: "MikroTik"' in result['stdout'][0]) def test_command_wait_for(self): wait_for = 'result[0] contains "MikroTik"' - set_module_args(dict(commands=['/system resource print'], wait_for=wait_for)) - self.execute_module(changed=True) + with set_module_args(dict(commands=['/system resource print'], wait_for=wait_for)): + self.execute_module(changed=True) def test_command_wait_for_fails(self): wait_for = 'result[0] contains "test string"' - set_module_args(dict(commands=['/system resource print'], wait_for=wait_for)) - self.execute_module(failed=True) + with set_module_args(dict(commands=['/system resource print'], wait_for=wait_for)): + self.execute_module(failed=True) self.assertEqual(self.run_commands.call_count, 10) def test_command_retries(self): wait_for = 'result[0] contains "test string"' - set_module_args(dict(commands=['/system resource print'], wait_for=wait_for, retries=2)) - self.execute_module(failed=True) + with set_module_args(dict(commands=['/system resource print'], wait_for=wait_for, retries=2)): + self.execute_module(failed=True) self.assertEqual(self.run_commands.call_count, 2) def test_command_match_any(self): wait_for = ['result[0] contains "MikroTik"', 'result[0] contains "test string"'] - set_module_args(dict(commands=['/system resource print'], wait_for=wait_for, match='any')) - self.execute_module(changed=True) + with set_module_args(dict(commands=['/system resource print'], wait_for=wait_for, match='any')): + self.execute_module(changed=True) def test_command_match_all(self): wait_for = ['result[0] contains "MikroTik"', 'result[0] contains "RB1100"'] - set_module_args(dict(commands=['/system resource print'], wait_for=wait_for, match='all')) - self.execute_module(changed=True) + with set_module_args(dict(commands=['/system resource print'], wait_for=wait_for, match='all')): + self.execute_module(changed=True) def test_command_match_all_failure(self): wait_for = ['result[0] contains "MikroTik"', 'result[0] contains "test string"'] commands = ['/system resource print', '/system resource print'] - set_module_args(dict(commands=commands, wait_for=wait_for, match='all')) - self.execute_module(failed=True) + with set_module_args(dict(commands=commands, wait_for=wait_for, match='all')): + self.execute_module(failed=True) def test_command_wait_for_2(self): wait_for = 'result[0] contains "wireless"' - set_module_args(dict(commands=['/system package print'], wait_for=wait_for)) - self.execute_module(changed=True) + with set_module_args(dict(commands=['/system package print'], wait_for=wait_for)): + self.execute_module(changed=True) diff --git a/tests/unit/plugins/modules/test_facts.py b/tests/unit/plugins/modules/test_facts.py index 322fdda..a7e2c8b 100644 --- a/tests/unit/plugins/modules/test_facts.py +++ b/tests/unit/plugins/modules/test_facts.py @@ -39,8 +39,8 @@ class TestRouterosFactsModule(TestRouterosModule): self.run_commands.side_effect = load_from_file def test_facts_default(self): - set_module_args(dict(gather_subset='default')) - result = self.execute_module() + with set_module_args(dict(gather_subset='default')): + result = self.execute_module() self.assertEqual( result['ansible_facts']['ansible_net_hostname'], 'MikroTik' ) @@ -61,8 +61,8 @@ class TestRouterosFactsModule(TestRouterosModule): ) def test_facts_hardware(self): - set_module_args(dict(gather_subset='hardware')) - result = self.execute_module() + with set_module_args(dict(gather_subset='hardware')): + result = self.execute_module() self.assertEqual( result['ansible_facts']['ansible_net_spacefree_mb'], 64921.6 ) @@ -77,8 +77,8 @@ class TestRouterosFactsModule(TestRouterosModule): ) def test_facts_config(self): - set_module_args(dict(gather_subset='config')) - result = self.execute_module() + with set_module_args(dict(gather_subset='config')): + result = self.execute_module() self.assertIsInstance( result['ansible_facts']['ansible_net_config'], str ) @@ -88,8 +88,8 @@ class TestRouterosFactsModule(TestRouterosModule): ) def test_facts_interfaces(self): - set_module_args(dict(gather_subset='interfaces')) - result = self.execute_module() + with set_module_args(dict(gather_subset='interfaces')): + result = self.execute_module() self.assertIn( result['ansible_facts']['ansible_net_all_ipv4_addresses'][0], ['10.37.129.3', '10.37.0.0', '192.168.88.1'] ) @@ -118,8 +118,8 @@ class TestRouterosFactsModule(TestRouterosModule): self.assertEqual(result, None) def test_facts_routing(self): - set_module_args(dict(gather_subset='routing')) - result = self.execute_module() + with set_module_args(dict(gather_subset='routing')): + result = self.execute_module() self.assertIn( result['ansible_facts']['ansible_net_bgp_peer']['iBGP_BRAS.TYRMA']['name'], ['iBGP_BRAS.TYRMA'] ) diff --git a/tests/unit/plugins/modules/utils.py b/tests/unit/plugins/modules/utils.py index 419eef1..0926190 100644 --- a/tests/unit/plugins/modules/utils.py +++ b/tests/unit/plugins/modules/utils.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +import contextlib as _contextlib import json from ansible_collections.community.routeros.tests.unit.compat import unittest @@ -13,14 +14,16 @@ from ansible.module_utils import basic from ansible.module_utils.common.text.converters import to_bytes +@_contextlib.contextmanager def set_module_args(args): if '_ansible_remote_tmp' not in args: args['_ansible_remote_tmp'] = '/tmp' if '_ansible_keep_remote_files' not in args: args['_ansible_keep_remote_files'] = False - args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) - basic._ANSIBLE_ARGS = to_bytes(args) + serialized_args = to_bytes(json.dumps({'ANSIBLE_MODULE_ARGS': args})) + with patch.object(basic, '_ANSIBLE_ARGS', serialized_args): + yield class AnsibleExitJson(Exception): From 3a5b1175ffd7e73f8ccbf5b4a40ea771bb0a9dda Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 11 Mar 2025 21:56:44 +0100 Subject: [PATCH 07/12] Switch from ubuntu-20.04 to ubuntu-latest for old Ansible versions. (#349) --- .github/workflows/ansible-test.yml | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index ad01212..b3c551e 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -37,15 +37,7 @@ jobs: - stable-2.17 - stable-2.18 - devel - # Ansible-test on various stable branches does not yet work well with cgroups v2. - # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 - # image for these stable branches. The list of branches where this is necessary will - # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 - # for the latest list. - runs-on: >- - ${{ contains(fromJson( - '["stable-2.9", "stable-2.10", "stable-2.11"]' - ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} + runs-on: ubuntu-latest steps: - name: Perform sanity testing uses: felixfontein/ansible-test-gh-action@main @@ -60,15 +52,7 @@ jobs: git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.utils.git ../../ansible/utils units: - # Ansible-test on various stable branches does not yet work well with cgroups v2. - # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 - # image for these stable branches. The list of branches where this is necessary will - # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 - # for the latest list. - runs-on: >- - ${{ contains(fromJson( - '["stable-2.9", "stable-2.10", "stable-2.11"]' - ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} + runs-on: ubuntu-latest name: Units (Ⓐ${{ matrix.ansible }}) strategy: # As soon as the first unit test fails, cancel the others to free up the CI queue @@ -103,15 +87,7 @@ jobs: git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.utils.git ../../ansible/utils integration: - # Ansible-test on various stable branches does not yet work well with cgroups v2. - # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 - # image for these stable branches. The list of branches where this is necessary will - # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 - # for the latest list. - runs-on: >- - ${{ contains(fromJson( - '["stable-2.9", "stable-2.10", "stable-2.11"]' - ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} + runs-on: ubuntu-latest name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) strategy: fail-fast: false From 90780b9cd010ae26d92ed316012af57fe93012f5 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 20:12:13 +0100 Subject: [PATCH 08/12] Fix typo in "API" (#351) (#352) (cherry picked from commit ab446b44492f7c6b765e77240bff468f27772092) Co-authored-by: hansmi --- plugins/modules/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/api.py b/plugins/modules/api.py index 4857a3c..469b9ea 100644 --- a/plugins/modules/api.py +++ b/plugins/modules/api.py @@ -65,7 +65,7 @@ options: type: str query: description: - - Query given path for selected query attributes from RouterOS aip. + - Query given path for selected query attributes from RouterOS API. - WHERE is key word which extend query. WHERE format is key operator value - with spaces. - WHERE valid operators are V(==) or V(eq), V(!=) or V(not), V(>) or V(more), V(<) or V(less). - Example path V(ip address) and query V(.id address) will return only C(.id) and C(address) for all items in V(ip address) path. From 5f21f8f7c6e4368aee70176b58125d4775a0287c Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 12 Mar 2025 21:47:20 +0100 Subject: [PATCH 09/12] Use shared unit test utils from community.internal_test_tools (#353) (#354) * Use shared unit test utils from community.internal_test_tools. * Make sure community.internal_test_tools is installed in CI. (cherry picked from commit 30a79061f388ed30664216250f58213bc7be8bab) --- .github/workflows/ansible-test.yml | 3 + tests/sanity/ignore-2.17.txt | 1 - tests/sanity/ignore-2.18.txt | 1 - tests/sanity/ignore-2.19.txt | 1 - tests/unit/compat/__init__.py | 0 tests/unit/compat/builtins.py | 20 ---- tests/unit/compat/mock.py | 109 ------------------ tests/unit/compat/unittest.py | 25 ---- tests/unit/plugins/modules/routeros_module.py | 2 +- tests/unit/plugins/modules/test_api.py | 5 +- tests/unit/plugins/modules/test_api_facts.py | 5 +- .../modules/test_api_find_and_modify.py | 5 +- tests/unit/plugins/modules/test_api_info.py | 5 +- tests/unit/plugins/modules/test_api_modify.py | 5 +- tests/unit/plugins/modules/test_command.py | 5 +- tests/unit/plugins/modules/test_facts.py | 5 +- tests/unit/plugins/modules/utils.py | 57 --------- 17 files changed, 25 insertions(+), 229 deletions(-) delete mode 100644 tests/unit/compat/__init__.py delete mode 100644 tests/unit/compat/builtins.py delete mode 100644 tests/unit/compat/mock.py delete mode 100644 tests/unit/compat/unittest.py delete mode 100644 tests/unit/plugins/modules/utils.py diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index b3c551e..e062a88 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -50,6 +50,7 @@ jobs: pre-test-cmd: |- git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.netcommon.git ../../ansible/netcommon git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.utils.git ../../ansible/utils + git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ../../community/internal_test_tools units: runs-on: ubuntu-latest @@ -85,6 +86,7 @@ jobs: pre-test-cmd: |- git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.netcommon.git ../../ansible/netcommon git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.utils.git ../../ansible/utils + git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ../../community/internal_test_tools integration: runs-on: ubuntu-latest @@ -151,5 +153,6 @@ jobs: pre-test-cmd: |- git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.netcommon.git ../../ansible/netcommon git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.utils.git ../../ansible/utils + git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ../../community/internal_test_tools target-python-version: ${{ matrix.python }} testing-type: integration diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt index 0a5234b..ce635c3 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -1,2 +1 @@ update-docs.py shebang -tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2 diff --git a/tests/sanity/ignore-2.18.txt b/tests/sanity/ignore-2.18.txt index 0a5234b..ce635c3 100644 --- a/tests/sanity/ignore-2.18.txt +++ b/tests/sanity/ignore-2.18.txt @@ -1,2 +1 @@ update-docs.py shebang -tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2 diff --git a/tests/sanity/ignore-2.19.txt b/tests/sanity/ignore-2.19.txt index 0a5234b..ce635c3 100644 --- a/tests/sanity/ignore-2.19.txt +++ b/tests/sanity/ignore-2.19.txt @@ -1,2 +1 @@ update-docs.py shebang -tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2 diff --git a/tests/unit/compat/__init__.py b/tests/unit/compat/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/compat/builtins.py b/tests/unit/compat/builtins.py deleted file mode 100644 index d548601..0000000 --- a/tests/unit/compat/builtins.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2014, Toshio Kuratomi -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -# -# Compat for python2.7 -# - -# One unittest needs to import builtins via __import__() so we need to have -# the string that represents it -try: - import __builtin__ # noqa: F401, pylint: disable=unused-import -except ImportError: - BUILTINS = 'builtins' -else: - BUILTINS = '__builtin__' diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py deleted file mode 100644 index bdbea94..0000000 --- a/tests/unit/compat/mock.py +++ /dev/null @@ -1,109 +0,0 @@ -# Copyright (c) 2014, Toshio Kuratomi -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -''' -Compat module for Python3.x's unittest.mock module -''' -import sys - -# Python 2.7 - -# Note: Could use the pypi mock library on python3.x as well as python2.x. It -# is the same as the python3 stdlib mock library - -try: - # Allow wildcard import because we really do want to import all of mock's - # symbols into this compat shim - # pylint: disable=wildcard-import,unused-wildcard-import - from unittest.mock import * # noqa: F401, pylint: disable=unused-import -except ImportError: - # Python 2 - # pylint: disable=wildcard-import,unused-wildcard-import - try: - from mock import * # noqa: F401, pylint: disable=unused-import - except ImportError: - print('You need the mock library installed on python2.x to run tests') - - -# Prior to 3.4.4, mock_open cannot handle binary read_data -if sys.version_info >= (3,) and sys.version_info < (3, 4, 4): - file_spec = None - - def _iterate_read_data(read_data): - # Helper for mock_open: - # Retrieve lines from read_data via a generator so that separate calls to - # readline, read, and readlines are properly interleaved - sep = b'\n' if isinstance(read_data, bytes) else '\n' - data_as_list = [l + sep for l in read_data.split(sep)] - - if data_as_list[-1] == sep: - # If the last line ended in a newline, the list comprehension will have an - # extra entry that's just a newline. Remove this. - data_as_list = data_as_list[:-1] - else: - # If there wasn't an extra newline by itself, then the file being - # emulated doesn't have a newline to end the last line remove the - # newline that our naive format() added - data_as_list[-1] = data_as_list[-1][:-1] - - for line in data_as_list: - yield line - - def mock_open(mock=None, read_data=''): - """ - A helper function to create a mock to replace the use of `open`. It works - for `open` called directly or used as a context manager. - - The `mock` argument is the mock object to configure. If `None` (the - default) then a `MagicMock` will be created for you, with the API limited - to methods or attributes available on standard file handles. - - `read_data` is a string for the `read` methoddline`, and `readlines` of the - file handle to return. This is an empty string by default. - """ - def _readlines_side_effect(*args, **kwargs): - if handle.readlines.return_value is not None: - return handle.readlines.return_value - return list(_data) - - def _read_side_effect(*args, **kwargs): - if handle.read.return_value is not None: - return handle.read.return_value - return type(read_data)().join(_data) - - def _readline_side_effect(): - if handle.readline.return_value is not None: - while True: - yield handle.readline.return_value - for line in _data: - yield line - - global file_spec - if file_spec is None: - import _io - file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))) - - if mock is None: - mock = MagicMock(name='open', spec=open) - - handle = MagicMock(spec=file_spec) - handle.__enter__.return_value = handle - - _data = _iterate_read_data(read_data) - - handle.write.return_value = None - handle.read.return_value = None - handle.readline.return_value = None - handle.readlines.return_value = None - - handle.read.side_effect = _read_side_effect - handle.readline.side_effect = _readline_side_effect() - handle.readlines.side_effect = _readlines_side_effect - - mock.return_value = handle - return mock diff --git a/tests/unit/compat/unittest.py b/tests/unit/compat/unittest.py deleted file mode 100644 index d50bab8..0000000 --- a/tests/unit/compat/unittest.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (c) 2014, Toshio Kuratomi -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -''' -Compat module for Python2.7's unittest module -''' - -import sys - -# Allow wildcard import because we really do want to import all of -# unittests's symbols into this compat shim -# pylint: disable=wildcard-import,unused-wildcard-import -if sys.version_info < (2, 7): - try: - # Need unittest2 on python2.6 - from unittest2 import * # noqa: F401, pylint: disable=unused-import - except ImportError: - print('You need unittest2 installed on python2.6.x to run tests') -else: - from unittest import * # noqa: F401, pylint: disable=unused-import diff --git a/tests/unit/plugins/modules/routeros_module.py b/tests/unit/plugins/modules/routeros_module.py index 0ec44f7..4786da6 100644 --- a/tests/unit/plugins/modules/routeros_module.py +++ b/tests/unit/plugins/modules/routeros_module.py @@ -9,7 +9,7 @@ __metaclass__ = type import os import json -from ansible_collections.community.routeros.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') diff --git a/tests/unit/plugins/modules/test_api.py b/tests/unit/plugins/modules/test_api.py index 5df8430..9a03825 100644 --- a/tests/unit/plugins/modules/test_api.py +++ b/tests/unit/plugins/modules/test_api.py @@ -6,9 +6,10 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible_collections.community.routeros.tests.unit.compat.mock import patch, MagicMock +from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch, MagicMock +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase + from ansible_collections.community.routeros.tests.unit.plugins.modules.fake_api import FakeLibRouterosError, Key, Or, fake_ros_api -from ansible_collections.community.routeros.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase from ansible_collections.community.routeros.plugins.modules import api diff --git a/tests/unit/plugins/modules/test_api_facts.py b/tests/unit/plugins/modules/test_api_facts.py index f9c76be..7b019f9 100644 --- a/tests/unit/plugins/modules/test_api_facts.py +++ b/tests/unit/plugins/modules/test_api_facts.py @@ -6,9 +6,10 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible_collections.community.routeros.tests.unit.compat.mock import patch, MagicMock +from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch, MagicMock +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase + from ansible_collections.community.routeros.tests.unit.plugins.modules.fake_api import FakeLibRouterosError, Key, fake_ros_api -from ansible_collections.community.routeros.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase from ansible_collections.community.routeros.plugins.modules import api_facts diff --git a/tests/unit/plugins/modules/test_api_find_and_modify.py b/tests/unit/plugins/modules/test_api_find_and_modify.py index 2405d3a..fe93905 100644 --- a/tests/unit/plugins/modules/test_api_find_and_modify.py +++ b/tests/unit/plugins/modules/test_api_find_and_modify.py @@ -6,11 +6,12 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible_collections.community.routeros.tests.unit.compat.mock import patch, MagicMock +from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch, MagicMock +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase + from ansible_collections.community.routeros.tests.unit.plugins.modules.fake_api import ( FakeLibRouterosError, fake_ros_api, massage_expected_result_data, create_fake_path, ) -from ansible_collections.community.routeros.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase from ansible_collections.community.routeros.plugins.modules import api_find_and_modify diff --git a/tests/unit/plugins/modules/test_api_info.py b/tests/unit/plugins/modules/test_api_info.py index d20aa11..967a854 100644 --- a/tests/unit/plugins/modules/test_api_info.py +++ b/tests/unit/plugins/modules/test_api_info.py @@ -6,11 +6,12 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible_collections.community.routeros.tests.unit.compat.mock import patch, MagicMock +from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch, MagicMock +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase + from ansible_collections.community.routeros.tests.unit.plugins.modules.fake_api import ( FAKE_ROS_VERSION, FakeLibRouterosError, Key, fake_ros_api, ) -from ansible_collections.community.routeros.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase from ansible_collections.community.routeros.plugins.modules import api_info diff --git a/tests/unit/plugins/modules/test_api_modify.py b/tests/unit/plugins/modules/test_api_modify.py index 20e29e1..6edc046 100644 --- a/tests/unit/plugins/modules/test_api_modify.py +++ b/tests/unit/plugins/modules/test_api_modify.py @@ -6,11 +6,12 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible_collections.community.routeros.tests.unit.compat.mock import patch, MagicMock +from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch, MagicMock +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase + from ansible_collections.community.routeros.tests.unit.plugins.modules.fake_api import ( FAKE_ROS_VERSION, FakeLibRouterosError, fake_ros_api, massage_expected_result_data, create_fake_path, ) -from ansible_collections.community.routeros.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase from ansible_collections.community.routeros.plugins.modules import api_modify diff --git a/tests/unit/plugins/modules/test_command.py b/tests/unit/plugins/modules/test_command.py index 72fbfd6..06153f0 100644 --- a/tests/unit/plugins/modules/test_command.py +++ b/tests/unit/plugins/modules/test_command.py @@ -8,9 +8,10 @@ __metaclass__ = type import json -from ansible_collections.community.routeros.tests.unit.compat.mock import patch +from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args + from ansible_collections.community.routeros.plugins.modules import command -from ansible_collections.community.routeros.tests.unit.plugins.modules.utils import set_module_args from .routeros_module import TestRouterosModule, load_fixture diff --git a/tests/unit/plugins/modules/test_facts.py b/tests/unit/plugins/modules/test_facts.py index a7e2c8b..918f378 100644 --- a/tests/unit/plugins/modules/test_facts.py +++ b/tests/unit/plugins/modules/test_facts.py @@ -6,9 +6,10 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible_collections.community.routeros.tests.unit.compat.mock import patch +from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args + from ansible_collections.community.routeros.plugins.modules import facts -from ansible_collections.community.routeros.tests.unit.plugins.modules.utils import set_module_args from .routeros_module import TestRouterosModule, load_fixture diff --git a/tests/unit/plugins/modules/utils.py b/tests/unit/plugins/modules/utils.py deleted file mode 100644 index 0926190..0000000 --- a/tests/unit/plugins/modules/utils.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright (c) Ansible Project -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -import contextlib as _contextlib -import json - -from ansible_collections.community.routeros.tests.unit.compat import unittest -from ansible_collections.community.routeros.tests.unit.compat.mock import patch -from ansible.module_utils import basic -from ansible.module_utils.common.text.converters import to_bytes - - -@_contextlib.contextmanager -def set_module_args(args): - if '_ansible_remote_tmp' not in args: - args['_ansible_remote_tmp'] = '/tmp' - if '_ansible_keep_remote_files' not in args: - args['_ansible_keep_remote_files'] = False - - serialized_args = to_bytes(json.dumps({'ANSIBLE_MODULE_ARGS': args})) - with patch.object(basic, '_ANSIBLE_ARGS', serialized_args): - yield - - -class AnsibleExitJson(Exception): - pass - - -class AnsibleFailJson(Exception): - pass - - -def exit_json(*args, **kwargs): - if 'changed' not in kwargs: - kwargs['changed'] = False - raise AnsibleExitJson(kwargs) - - -def fail_json(*args, **kwargs): - kwargs['failed'] = True - raise AnsibleFailJson(kwargs) - - -class ModuleTestCase(unittest.TestCase): - - def setUp(self): - self.mock_module = patch.multiple(basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json) - self.mock_module.start() - self.mock_sleep = patch('time.sleep') - self.mock_sleep.start() - set_module_args({}) - self.addCleanup(self.mock_module.stop) - self.addCleanup(self.mock_sleep.stop) From 317fca85022ce863a40d5355544d4dae56c798e4 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 22 Mar 2025 11:57:24 +0100 Subject: [PATCH 10/12] Use shared unit test utils from community.internal_test_tools (#353) (#357) * Use shared unit test utils from community.internal_test_tools. * Make sure community.internal_test_tools is installed in CI. (cherry picked from commit 30a79061f388ed30664216250f58213bc7be8bab) From 8aed0204cfd413e6c7da39e9c9a5b24f976a5a9a Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 19 Apr 2025 16:20:32 +0200 Subject: [PATCH 11/12] Declare 2.x.y EOL. (#362) --- changelogs/fragments/2.20.1.yml | 6 ++++++ galaxy.yml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/2.20.1.yml diff --git a/changelogs/fragments/2.20.1.yml b/changelogs/fragments/2.20.1.yml new file mode 100644 index 0000000..b1b938e --- /dev/null +++ b/changelogs/fragments/2.20.1.yml @@ -0,0 +1,6 @@ +release_summary: | + This is the final community.routeros 2.x.y release. + + Please upgrade to community.routeros 3.x.y as soon as possible to receive further bugfixes. + + Thanks to everyone who contributed to community.routeros 2.x.y releases! diff --git a/galaxy.yml b/galaxy.yml index 7c40eda..4c73628 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -7,7 +7,7 @@ namespace: community name: routeros -version: 2.20.0 +version: 2.20.1 readme: README.md authors: - Egor Zaitsev (github.com/heuels) From 19363bb42477b05d8c34160263af77b7872ef705 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 19 Apr 2025 16:24:18 +0200 Subject: [PATCH 12/12] Release 2.2.0.1. --- CHANGELOG.md | 142 ++++++++++++++++++-------------- CHANGELOG.rst | 12 +++ changelogs/changelog.yaml | 15 ++++ changelogs/fragments/2.20.1.yml | 6 -- 4 files changed, 105 insertions(+), 70 deletions(-) delete mode 100644 changelogs/fragments/2.20.1.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index d104e3f..b7b9752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,128 +2,142 @@ **Topics** -- v2\.20\.0 +- v2\.20\.1 - Release Summary +- v2\.20\.0 + - Release Summary - Minor Changes - v2\.19\.0 - - Release Summary + - Release Summary - Minor Changes - v2\.18\.0 - - Release Summary + - Release Summary - Minor Changes - Deprecated Features - Bugfixes - v2\.17\.0 - - Release Summary + - Release Summary - Minor Changes - v2\.16\.0 - - Release Summary + - Release Summary - Minor Changes - v2\.15\.0 - - Release Summary + - Release Summary - Minor Changes - v2\.14\.0 - - Release Summary + - Release Summary - Minor Changes - v2\.13\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - v2\.12\.0 - - Release Summary + - Release Summary - Minor Changes - v2\.11\.0 - - Release Summary + - Release Summary - Minor Changes - v2\.10\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - v2\.9\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - v2\.8\.3 - - Release Summary + - Release Summary - Known Issues - v2\.8\.2 - - Release Summary + - Release Summary - Bugfixes - v2\.8\.1 - - Release Summary + - Release Summary - Bugfixes - v2\.8\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - v2\.7\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - v2\.6\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - v2\.5\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - v2\.4\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - Known Issues - v2\.3\.1 - - Release Summary + - Release Summary - Known Issues - v2\.3\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - v2\.2\.1 - - Release Summary + - Release Summary - Bugfixes - v2\.2\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - New Modules - v2\.1\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - New Modules - v2\.0\.0 - - Release Summary + - Release Summary - Minor Changes - Breaking Changes / Porting Guide - Bugfixes - New Plugins - Filter - v1\.2\.0 - - Release Summary + - Release Summary - Minor Changes - Bugfixes - v1\.1\.0 - - Release Summary + - Release Summary - Minor Changes - v1\.0\.1 - - Release Summary + - Release Summary - Bugfixes - v1\.0\.0 - - Release Summary + - Release Summary - Bugfixes - v0\.1\.1 - - Release Summary + - Release Summary - Bugfixes - v0\.1\.0 - - Release Summary + - Release Summary - Minor Changes + +## v2\.20\.1 + + +### Release Summary + +This is the final community\.routeros 2\.x\.y release\. + +Please upgrade to community\.routeros 3\.x\.y as soon as possible to receive further bugfixes\. + +Thanks to everyone who contributed to community\.routeros 2\.x\.y releases\! + ## v2\.20\.0 - + ### Release Summary Feature release\. @@ -139,7 +153,7 @@ Feature release\. ## v2\.19\.0 - + ### Release Summary Feature release\. @@ -156,7 +170,7 @@ Feature release\. ## v2\.18\.0 - + ### Release Summary Feature release\. @@ -185,7 +199,7 @@ Feature release\. ## v2\.17\.0 - + ### Release Summary Feature release\. @@ -200,7 +214,7 @@ Feature release\. ## v2\.16\.0 - + ### Release Summary Feature release\. @@ -214,7 +228,7 @@ Feature release\. ## v2\.15\.0 - + ### Release Summary Feature release\. @@ -236,7 +250,7 @@ Feature release\. ## v2\.14\.0 - + ### Release Summary Feature release\. @@ -251,7 +265,7 @@ Feature release\. ## v2\.13\.0 - + ### Release Summary Bugfix and feature release\. @@ -270,7 +284,7 @@ Bugfix and feature release\. ## v2\.12\.0 - + ### Release Summary Feature release\. @@ -289,7 +303,7 @@ Feature release\. ## v2\.11\.0 - + ### Release Summary Feature and bugfix release\. @@ -309,7 +323,7 @@ Feature and bugfix release\. ## v2\.10\.0 - + ### Release Summary Bugfix and feature release\. @@ -346,7 +360,7 @@ Bugfix and feature release\. ## v2\.9\.0 - + ### Release Summary Bugfix and feature release\. @@ -365,7 +379,7 @@ Bugfix and feature release\. ## v2\.8\.3 - + ### Release Summary Maintenance release with updated documentation\. @@ -386,7 +400,7 @@ for the rendered HTML version of the documentation of the latest release\. ## v2\.8\.2 - + ### Release Summary Bugfix release\. @@ -399,7 +413,7 @@ Bugfix release\. ## v2\.8\.1 - + ### Release Summary Bugfix release\. @@ -412,7 +426,7 @@ Bugfix release\. ## v2\.8\.0 - + ### Release Summary Bugfix and feature release\. @@ -437,7 +451,7 @@ Bugfix and feature release\. ## v2\.7\.0 - + ### Release Summary Bugfix and feature release\. @@ -455,7 +469,7 @@ Bugfix and feature release\. ## v2\.6\.0 - + ### Release Summary Regular bugfix and feature release\. @@ -475,7 +489,7 @@ Regular bugfix and feature release\. ## v2\.5\.0 - + ### Release Summary Feature and bugfix release\. @@ -493,7 +507,7 @@ Feature and bugfix release\. ## v2\.4\.0 - + ### Release Summary Feature release improving the api\* modules\. @@ -537,7 +551,7 @@ Feature release improving the api\* modules\. ## v2\.3\.1 - + ### Release Summary Maintenance release with improved documentation\. @@ -550,7 +564,7 @@ Maintenance release with improved documentation\. ## v2\.3\.0 - + ### Release Summary Feature and bugfix release\. @@ -570,7 +584,7 @@ Feature and bugfix release\. ## v2\.2\.1 - + ### Release Summary Bugfix release\. @@ -584,7 +598,7 @@ Bugfix release\. ## v2\.2\.0 - + ### Release Summary New feature release\. @@ -608,7 +622,7 @@ New feature release\. ## v2\.1\.0 - + ### Release Summary Feature and bugfix release with new modules\. @@ -637,7 +651,7 @@ Feature and bugfix release with new modules\. ## v2\.0\.0 - + ### Release Summary A new major release with breaking changes in the behavior of community\.routeros\.api and community\.routeros\.command\. @@ -678,7 +692,7 @@ A new major release with breaking changes in the behavior of community\.ro ## v1\.2\.0 - + ### Release Summary Bugfix and feature release\. @@ -699,7 +713,7 @@ Bugfix and feature release\. ## v1\.1\.0 - + ### Release Summary This release allow dashes in usernames for SSH\-based modules\. @@ -713,7 +727,7 @@ This release allow dashes in usernames for SSH\-based modules\. ## v1\.0\.1 - + ### Release Summary Maintenance release with a bugfix for api\. @@ -726,7 +740,7 @@ Maintenance release with a bugfix for api\. ## v1\.0\.0 - + ### Release Summary This is the first production \(non\-prerelease\) release of community\.routeros\. @@ -739,7 +753,7 @@ This is the first production \(non\-prerelease\) release of community\.rou ## v0\.1\.1 - + ### Release Summary Small improvements and bugfixes over the initial release\. @@ -752,7 +766,7 @@ Small improvements and bugfixes over the initial release\. ## v0\.1\.0 - + ### Release Summary The community\.routeros continues the work on the Ansible RouterOS modules from their state in community\.network 1\.2\.0\. The changes listed here are thus relative to the modules community\.network\.routeros\_\*\. diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 108831a..7a3b0a5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,18 @@ Community RouterOS Release Notes .. contents:: Topics +v2.20.1 +======= + +Release Summary +--------------- + +This is the final community.routeros 2.x.y release. + +Please upgrade to community.routeros 3.x.y as soon as possible to receive further bugfixes. + +Thanks to everyone who contributed to community.routeros 2.x.y releases! + v2.20.0 ======= diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 7185a2c..0ca7cbd 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -795,3 +795,18 @@ releases: - 322-add-l2tp-client-interface-configuration.yml - 323-add-ros-7.16-parameters.yml release_date: '2024-10-17' + 2.20.1: + changes: + release_summary: 'This is the final community.routeros 2.x.y release. + + + Please upgrade to community.routeros 3.x.y as soon as possible to receive + further bugfixes. + + + Thanks to everyone who contributed to community.routeros 2.x.y releases! + + ' + fragments: + - 2.20.1.yml + release_date: '2025-04-19' diff --git a/changelogs/fragments/2.20.1.yml b/changelogs/fragments/2.20.1.yml deleted file mode 100644 index b1b938e..0000000 --- a/changelogs/fragments/2.20.1.yml +++ /dev/null @@ -1,6 +0,0 @@ -release_summary: | - This is the final community.routeros 2.x.y release. - - Please upgrade to community.routeros 3.x.y as soon as possible to receive further bugfixes. - - Thanks to everyone who contributed to community.routeros 2.x.y releases!