mirror of
https://github.com/ansible-collections/community.routeros.git
synced 2025-08-07 19:55:12 +02:00
Compare commits
12 commits
Author | SHA1 | Date | |
---|---|---|---|
|
19363bb424 | ||
|
8aed0204cf | ||
|
317fca8502 | ||
|
5f21f8f7c6 | ||
|
90780b9cd0 | ||
|
3a5b1175ff | ||
|
c5f1fb50d7 | ||
|
f8f86f6ec0 | ||
|
8eab877140 | ||
|
353027cb5c | ||
|
b0453b2e47 | ||
|
3af2968316 |
29 changed files with 383 additions and 558 deletions
33
.github/workflows/ansible-test.yml
vendored
33
.github/workflows/ansible-test.yml
vendored
|
@ -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
|
||||
|
@ -58,17 +50,10 @@ 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:
|
||||
# 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
|
||||
|
@ -101,17 +86,10 @@ 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:
|
||||
# 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
|
||||
|
@ -175,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
|
||||
|
|
3
.github/workflows/ee.yml
vendored
3
.github/workflows/ee.yml
vendored
|
@ -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 <<EOF
|
||||
|
|
1
.github/workflows/extra-tests.yml
vendored
1
.github/workflows/extra-tests.yml
vendored
|
@ -29,6 +29,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
|
||||
|
|
10
.github/workflows/reuse.yml
vendored
10
.github/workflows/reuse.yml
vendored
|
@ -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 * * *'
|
||||
|
@ -22,6 +26,8 @@ jobs:
|
|||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: REUSE Compliance Check
|
||||
uses: fsfe/reuse-action@v4
|
||||
|
|
142
CHANGELOG.md
142
CHANGELOG.md
|
@ -2,128 +2,142 @@
|
|||
|
||||
**Topics**
|
||||
|
||||
- <a href="#v2-20-0">v2\.20\.0</a>
|
||||
- <a href="#v2-20-1">v2\.20\.1</a>
|
||||
- <a href="#release-summary">Release Summary</a>
|
||||
- <a href="#v2-20-0">v2\.20\.0</a>
|
||||
- <a href="#release-summary-1">Release Summary</a>
|
||||
- <a href="#minor-changes">Minor Changes</a>
|
||||
- <a href="#v2-19-0">v2\.19\.0</a>
|
||||
- <a href="#release-summary-1">Release Summary</a>
|
||||
- <a href="#release-summary-2">Release Summary</a>
|
||||
- <a href="#minor-changes-1">Minor Changes</a>
|
||||
- <a href="#v2-18-0">v2\.18\.0</a>
|
||||
- <a href="#release-summary-2">Release Summary</a>
|
||||
- <a href="#release-summary-3">Release Summary</a>
|
||||
- <a href="#minor-changes-2">Minor Changes</a>
|
||||
- <a href="#deprecated-features">Deprecated Features</a>
|
||||
- <a href="#bugfixes">Bugfixes</a>
|
||||
- <a href="#v2-17-0">v2\.17\.0</a>
|
||||
- <a href="#release-summary-3">Release Summary</a>
|
||||
- <a href="#release-summary-4">Release Summary</a>
|
||||
- <a href="#minor-changes-3">Minor Changes</a>
|
||||
- <a href="#v2-16-0">v2\.16\.0</a>
|
||||
- <a href="#release-summary-4">Release Summary</a>
|
||||
- <a href="#release-summary-5">Release Summary</a>
|
||||
- <a href="#minor-changes-4">Minor Changes</a>
|
||||
- <a href="#v2-15-0">v2\.15\.0</a>
|
||||
- <a href="#release-summary-5">Release Summary</a>
|
||||
- <a href="#release-summary-6">Release Summary</a>
|
||||
- <a href="#minor-changes-5">Minor Changes</a>
|
||||
- <a href="#v2-14-0">v2\.14\.0</a>
|
||||
- <a href="#release-summary-6">Release Summary</a>
|
||||
- <a href="#release-summary-7">Release Summary</a>
|
||||
- <a href="#minor-changes-6">Minor Changes</a>
|
||||
- <a href="#v2-13-0">v2\.13\.0</a>
|
||||
- <a href="#release-summary-7">Release Summary</a>
|
||||
- <a href="#release-summary-8">Release Summary</a>
|
||||
- <a href="#minor-changes-7">Minor Changes</a>
|
||||
- <a href="#bugfixes-1">Bugfixes</a>
|
||||
- <a href="#v2-12-0">v2\.12\.0</a>
|
||||
- <a href="#release-summary-8">Release Summary</a>
|
||||
- <a href="#release-summary-9">Release Summary</a>
|
||||
- <a href="#minor-changes-8">Minor Changes</a>
|
||||
- <a href="#v2-11-0">v2\.11\.0</a>
|
||||
- <a href="#release-summary-9">Release Summary</a>
|
||||
- <a href="#release-summary-10">Release Summary</a>
|
||||
- <a href="#minor-changes-9">Minor Changes</a>
|
||||
- <a href="#v2-10-0">v2\.10\.0</a>
|
||||
- <a href="#release-summary-10">Release Summary</a>
|
||||
- <a href="#release-summary-11">Release Summary</a>
|
||||
- <a href="#minor-changes-10">Minor Changes</a>
|
||||
- <a href="#bugfixes-2">Bugfixes</a>
|
||||
- <a href="#v2-9-0">v2\.9\.0</a>
|
||||
- <a href="#release-summary-11">Release Summary</a>
|
||||
- <a href="#release-summary-12">Release Summary</a>
|
||||
- <a href="#minor-changes-11">Minor Changes</a>
|
||||
- <a href="#bugfixes-3">Bugfixes</a>
|
||||
- <a href="#v2-8-3">v2\.8\.3</a>
|
||||
- <a href="#release-summary-12">Release Summary</a>
|
||||
- <a href="#release-summary-13">Release Summary</a>
|
||||
- <a href="#known-issues">Known Issues</a>
|
||||
- <a href="#v2-8-2">v2\.8\.2</a>
|
||||
- <a href="#release-summary-13">Release Summary</a>
|
||||
- <a href="#release-summary-14">Release Summary</a>
|
||||
- <a href="#bugfixes-4">Bugfixes</a>
|
||||
- <a href="#v2-8-1">v2\.8\.1</a>
|
||||
- <a href="#release-summary-14">Release Summary</a>
|
||||
- <a href="#release-summary-15">Release Summary</a>
|
||||
- <a href="#bugfixes-5">Bugfixes</a>
|
||||
- <a href="#v2-8-0">v2\.8\.0</a>
|
||||
- <a href="#release-summary-15">Release Summary</a>
|
||||
- <a href="#release-summary-16">Release Summary</a>
|
||||
- <a href="#minor-changes-12">Minor Changes</a>
|
||||
- <a href="#bugfixes-6">Bugfixes</a>
|
||||
- <a href="#v2-7-0">v2\.7\.0</a>
|
||||
- <a href="#release-summary-16">Release Summary</a>
|
||||
- <a href="#release-summary-17">Release Summary</a>
|
||||
- <a href="#minor-changes-13">Minor Changes</a>
|
||||
- <a href="#bugfixes-7">Bugfixes</a>
|
||||
- <a href="#v2-6-0">v2\.6\.0</a>
|
||||
- <a href="#release-summary-17">Release Summary</a>
|
||||
- <a href="#release-summary-18">Release Summary</a>
|
||||
- <a href="#minor-changes-14">Minor Changes</a>
|
||||
- <a href="#bugfixes-8">Bugfixes</a>
|
||||
- <a href="#v2-5-0">v2\.5\.0</a>
|
||||
- <a href="#release-summary-18">Release Summary</a>
|
||||
- <a href="#release-summary-19">Release Summary</a>
|
||||
- <a href="#minor-changes-15">Minor Changes</a>
|
||||
- <a href="#bugfixes-9">Bugfixes</a>
|
||||
- <a href="#v2-4-0">v2\.4\.0</a>
|
||||
- <a href="#release-summary-19">Release Summary</a>
|
||||
- <a href="#release-summary-20">Release Summary</a>
|
||||
- <a href="#minor-changes-16">Minor Changes</a>
|
||||
- <a href="#bugfixes-10">Bugfixes</a>
|
||||
- <a href="#known-issues-1">Known Issues</a>
|
||||
- <a href="#v2-3-1">v2\.3\.1</a>
|
||||
- <a href="#release-summary-20">Release Summary</a>
|
||||
- <a href="#release-summary-21">Release Summary</a>
|
||||
- <a href="#known-issues-2">Known Issues</a>
|
||||
- <a href="#v2-3-0">v2\.3\.0</a>
|
||||
- <a href="#release-summary-21">Release Summary</a>
|
||||
- <a href="#release-summary-22">Release Summary</a>
|
||||
- <a href="#minor-changes-17">Minor Changes</a>
|
||||
- <a href="#bugfixes-11">Bugfixes</a>
|
||||
- <a href="#v2-2-1">v2\.2\.1</a>
|
||||
- <a href="#release-summary-22">Release Summary</a>
|
||||
- <a href="#release-summary-23">Release Summary</a>
|
||||
- <a href="#bugfixes-12">Bugfixes</a>
|
||||
- <a href="#v2-2-0">v2\.2\.0</a>
|
||||
- <a href="#release-summary-23">Release Summary</a>
|
||||
- <a href="#release-summary-24">Release Summary</a>
|
||||
- <a href="#minor-changes-18">Minor Changes</a>
|
||||
- <a href="#bugfixes-13">Bugfixes</a>
|
||||
- <a href="#new-modules">New Modules</a>
|
||||
- <a href="#v2-1-0">v2\.1\.0</a>
|
||||
- <a href="#release-summary-24">Release Summary</a>
|
||||
- <a href="#release-summary-25">Release Summary</a>
|
||||
- <a href="#minor-changes-19">Minor Changes</a>
|
||||
- <a href="#bugfixes-14">Bugfixes</a>
|
||||
- <a href="#new-modules-1">New Modules</a>
|
||||
- <a href="#v2-0-0">v2\.0\.0</a>
|
||||
- <a href="#release-summary-25">Release Summary</a>
|
||||
- <a href="#release-summary-26">Release Summary</a>
|
||||
- <a href="#minor-changes-20">Minor Changes</a>
|
||||
- <a href="#breaking-changes--porting-guide">Breaking Changes / Porting Guide</a>
|
||||
- <a href="#bugfixes-15">Bugfixes</a>
|
||||
- <a href="#new-plugins">New Plugins</a>
|
||||
- <a href="#filter">Filter</a>
|
||||
- <a href="#v1-2-0">v1\.2\.0</a>
|
||||
- <a href="#release-summary-26">Release Summary</a>
|
||||
- <a href="#release-summary-27">Release Summary</a>
|
||||
- <a href="#minor-changes-21">Minor Changes</a>
|
||||
- <a href="#bugfixes-16">Bugfixes</a>
|
||||
- <a href="#v1-1-0">v1\.1\.0</a>
|
||||
- <a href="#release-summary-27">Release Summary</a>
|
||||
- <a href="#release-summary-28">Release Summary</a>
|
||||
- <a href="#minor-changes-22">Minor Changes</a>
|
||||
- <a href="#v1-0-1">v1\.0\.1</a>
|
||||
- <a href="#release-summary-28">Release Summary</a>
|
||||
- <a href="#release-summary-29">Release Summary</a>
|
||||
- <a href="#bugfixes-17">Bugfixes</a>
|
||||
- <a href="#v1-0-0">v1\.0\.0</a>
|
||||
- <a href="#release-summary-29">Release Summary</a>
|
||||
- <a href="#release-summary-30">Release Summary</a>
|
||||
- <a href="#bugfixes-18">Bugfixes</a>
|
||||
- <a href="#v0-1-1">v0\.1\.1</a>
|
||||
- <a href="#release-summary-30">Release Summary</a>
|
||||
- <a href="#release-summary-31">Release Summary</a>
|
||||
- <a href="#bugfixes-19">Bugfixes</a>
|
||||
- <a href="#v0-1-0">v0\.1\.0</a>
|
||||
- <a href="#release-summary-31">Release Summary</a>
|
||||
- <a href="#release-summary-32">Release Summary</a>
|
||||
- <a href="#minor-changes-23">Minor Changes</a>
|
||||
|
||||
<a id="v2-20-1"></a>
|
||||
## v2\.20\.1
|
||||
|
||||
<a id="release-summary"></a>
|
||||
### 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\!
|
||||
|
||||
<a id="v2-20-0"></a>
|
||||
## v2\.20\.0
|
||||
|
||||
<a id="release-summary"></a>
|
||||
<a id="release-summary-1"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature release\.
|
||||
|
@ -139,7 +153,7 @@ Feature release\.
|
|||
<a id="v2-19-0"></a>
|
||||
## v2\.19\.0
|
||||
|
||||
<a id="release-summary-1"></a>
|
||||
<a id="release-summary-2"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature release\.
|
||||
|
@ -156,7 +170,7 @@ Feature release\.
|
|||
<a id="v2-18-0"></a>
|
||||
## v2\.18\.0
|
||||
|
||||
<a id="release-summary-2"></a>
|
||||
<a id="release-summary-3"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature release\.
|
||||
|
@ -185,7 +199,7 @@ Feature release\.
|
|||
<a id="v2-17-0"></a>
|
||||
## v2\.17\.0
|
||||
|
||||
<a id="release-summary-3"></a>
|
||||
<a id="release-summary-4"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature release\.
|
||||
|
@ -200,7 +214,7 @@ Feature release\.
|
|||
<a id="v2-16-0"></a>
|
||||
## v2\.16\.0
|
||||
|
||||
<a id="release-summary-4"></a>
|
||||
<a id="release-summary-5"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature release\.
|
||||
|
@ -214,7 +228,7 @@ Feature release\.
|
|||
<a id="v2-15-0"></a>
|
||||
## v2\.15\.0
|
||||
|
||||
<a id="release-summary-5"></a>
|
||||
<a id="release-summary-6"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature release\.
|
||||
|
@ -236,7 +250,7 @@ Feature release\.
|
|||
<a id="v2-14-0"></a>
|
||||
## v2\.14\.0
|
||||
|
||||
<a id="release-summary-6"></a>
|
||||
<a id="release-summary-7"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature release\.
|
||||
|
@ -251,7 +265,7 @@ Feature release\.
|
|||
<a id="v2-13-0"></a>
|
||||
## v2\.13\.0
|
||||
|
||||
<a id="release-summary-7"></a>
|
||||
<a id="release-summary-8"></a>
|
||||
### Release Summary
|
||||
|
||||
Bugfix and feature release\.
|
||||
|
@ -270,7 +284,7 @@ Bugfix and feature release\.
|
|||
<a id="v2-12-0"></a>
|
||||
## v2\.12\.0
|
||||
|
||||
<a id="release-summary-8"></a>
|
||||
<a id="release-summary-9"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature release\.
|
||||
|
@ -289,7 +303,7 @@ Feature release\.
|
|||
<a id="v2-11-0"></a>
|
||||
## v2\.11\.0
|
||||
|
||||
<a id="release-summary-9"></a>
|
||||
<a id="release-summary-10"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature and bugfix release\.
|
||||
|
@ -309,7 +323,7 @@ Feature and bugfix release\.
|
|||
<a id="v2-10-0"></a>
|
||||
## v2\.10\.0
|
||||
|
||||
<a id="release-summary-10"></a>
|
||||
<a id="release-summary-11"></a>
|
||||
### Release Summary
|
||||
|
||||
Bugfix and feature release\.
|
||||
|
@ -346,7 +360,7 @@ Bugfix and feature release\.
|
|||
<a id="v2-9-0"></a>
|
||||
## v2\.9\.0
|
||||
|
||||
<a id="release-summary-11"></a>
|
||||
<a id="release-summary-12"></a>
|
||||
### Release Summary
|
||||
|
||||
Bugfix and feature release\.
|
||||
|
@ -365,7 +379,7 @@ Bugfix and feature release\.
|
|||
<a id="v2-8-3"></a>
|
||||
## v2\.8\.3
|
||||
|
||||
<a id="release-summary-12"></a>
|
||||
<a id="release-summary-13"></a>
|
||||
### Release Summary
|
||||
|
||||
Maintenance release with updated documentation\.
|
||||
|
@ -386,7 +400,7 @@ for the rendered HTML version of the documentation of the latest release\.
|
|||
<a id="v2-8-2"></a>
|
||||
## v2\.8\.2
|
||||
|
||||
<a id="release-summary-13"></a>
|
||||
<a id="release-summary-14"></a>
|
||||
### Release Summary
|
||||
|
||||
Bugfix release\.
|
||||
|
@ -399,7 +413,7 @@ Bugfix release\.
|
|||
<a id="v2-8-1"></a>
|
||||
## v2\.8\.1
|
||||
|
||||
<a id="release-summary-14"></a>
|
||||
<a id="release-summary-15"></a>
|
||||
### Release Summary
|
||||
|
||||
Bugfix release\.
|
||||
|
@ -412,7 +426,7 @@ Bugfix release\.
|
|||
<a id="v2-8-0"></a>
|
||||
## v2\.8\.0
|
||||
|
||||
<a id="release-summary-15"></a>
|
||||
<a id="release-summary-16"></a>
|
||||
### Release Summary
|
||||
|
||||
Bugfix and feature release\.
|
||||
|
@ -437,7 +451,7 @@ Bugfix and feature release\.
|
|||
<a id="v2-7-0"></a>
|
||||
## v2\.7\.0
|
||||
|
||||
<a id="release-summary-16"></a>
|
||||
<a id="release-summary-17"></a>
|
||||
### Release Summary
|
||||
|
||||
Bugfix and feature release\.
|
||||
|
@ -455,7 +469,7 @@ Bugfix and feature release\.
|
|||
<a id="v2-6-0"></a>
|
||||
## v2\.6\.0
|
||||
|
||||
<a id="release-summary-17"></a>
|
||||
<a id="release-summary-18"></a>
|
||||
### Release Summary
|
||||
|
||||
Regular bugfix and feature release\.
|
||||
|
@ -475,7 +489,7 @@ Regular bugfix and feature release\.
|
|||
<a id="v2-5-0"></a>
|
||||
## v2\.5\.0
|
||||
|
||||
<a id="release-summary-18"></a>
|
||||
<a id="release-summary-19"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature and bugfix release\.
|
||||
|
@ -493,7 +507,7 @@ Feature and bugfix release\.
|
|||
<a id="v2-4-0"></a>
|
||||
## v2\.4\.0
|
||||
|
||||
<a id="release-summary-19"></a>
|
||||
<a id="release-summary-20"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature release improving the <code>api\*</code> modules\.
|
||||
|
@ -537,7 +551,7 @@ Feature release improving the <code>api\*</code> modules\.
|
|||
<a id="v2-3-1"></a>
|
||||
## v2\.3\.1
|
||||
|
||||
<a id="release-summary-20"></a>
|
||||
<a id="release-summary-21"></a>
|
||||
### Release Summary
|
||||
|
||||
Maintenance release with improved documentation\.
|
||||
|
@ -550,7 +564,7 @@ Maintenance release with improved documentation\.
|
|||
<a id="v2-3-0"></a>
|
||||
## v2\.3\.0
|
||||
|
||||
<a id="release-summary-21"></a>
|
||||
<a id="release-summary-22"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature and bugfix release\.
|
||||
|
@ -570,7 +584,7 @@ Feature and bugfix release\.
|
|||
<a id="v2-2-1"></a>
|
||||
## v2\.2\.1
|
||||
|
||||
<a id="release-summary-22"></a>
|
||||
<a id="release-summary-23"></a>
|
||||
### Release Summary
|
||||
|
||||
Bugfix release\.
|
||||
|
@ -584,7 +598,7 @@ Bugfix release\.
|
|||
<a id="v2-2-0"></a>
|
||||
## v2\.2\.0
|
||||
|
||||
<a id="release-summary-23"></a>
|
||||
<a id="release-summary-24"></a>
|
||||
### Release Summary
|
||||
|
||||
New feature release\.
|
||||
|
@ -608,7 +622,7 @@ New feature release\.
|
|||
<a id="v2-1-0"></a>
|
||||
## v2\.1\.0
|
||||
|
||||
<a id="release-summary-24"></a>
|
||||
<a id="release-summary-25"></a>
|
||||
### Release Summary
|
||||
|
||||
Feature and bugfix release with new modules\.
|
||||
|
@ -637,7 +651,7 @@ Feature and bugfix release with new modules\.
|
|||
<a id="v2-0-0"></a>
|
||||
## v2\.0\.0
|
||||
|
||||
<a id="release-summary-25"></a>
|
||||
<a id="release-summary-26"></a>
|
||||
### Release Summary
|
||||
|
||||
A new major release with breaking changes in the behavior of <code>community\.routeros\.api</code> and <code>community\.routeros\.command</code>\.
|
||||
|
@ -678,7 +692,7 @@ A new major release with breaking changes in the behavior of <code>community\.ro
|
|||
<a id="v1-2-0"></a>
|
||||
## v1\.2\.0
|
||||
|
||||
<a id="release-summary-26"></a>
|
||||
<a id="release-summary-27"></a>
|
||||
### Release Summary
|
||||
|
||||
Bugfix and feature release\.
|
||||
|
@ -699,7 +713,7 @@ Bugfix and feature release\.
|
|||
<a id="v1-1-0"></a>
|
||||
## v1\.1\.0
|
||||
|
||||
<a id="release-summary-27"></a>
|
||||
<a id="release-summary-28"></a>
|
||||
### 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\.
|
|||
<a id="v1-0-1"></a>
|
||||
## v1\.0\.1
|
||||
|
||||
<a id="release-summary-28"></a>
|
||||
<a id="release-summary-29"></a>
|
||||
### Release Summary
|
||||
|
||||
Maintenance release with a bugfix for <code>api</code>\.
|
||||
|
@ -726,7 +740,7 @@ Maintenance release with a bugfix for <code>api</code>\.
|
|||
<a id="v1-0-0"></a>
|
||||
## v1\.0\.0
|
||||
|
||||
<a id="release-summary-29"></a>
|
||||
<a id="release-summary-30"></a>
|
||||
### Release Summary
|
||||
|
||||
This is the first production \(non\-prerelease\) release of <code>community\.routeros</code>\.
|
||||
|
@ -739,7 +753,7 @@ This is the first production \(non\-prerelease\) release of <code>community\.rou
|
|||
<a id="v0-1-1"></a>
|
||||
## v0\.1\.1
|
||||
|
||||
<a id="release-summary-30"></a>
|
||||
<a id="release-summary-31"></a>
|
||||
### Release Summary
|
||||
|
||||
Small improvements and bugfixes over the initial release\.
|
||||
|
@ -752,7 +766,7 @@ Small improvements and bugfixes over the initial release\.
|
|||
<a id="v0-1-0"></a>
|
||||
## v0\.1\.0
|
||||
|
||||
<a id="release-summary-31"></a>
|
||||
<a id="release-summary-32"></a>
|
||||
### Release Summary
|
||||
|
||||
The <code>community\.routeros</code> continues the work on the Ansible RouterOS modules from their state in <code>community\.network</code> 1\.2\.0\. The changes listed here are thus relative to the modules <code>community\.network\.routeros\_\*</code>\.
|
||||
|
|
|
@ -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
|
||||
=======
|
||||
|
||||
|
|
11
README.md
11
README.md
|
@ -5,7 +5,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
-->
|
||||
|
||||
# Community RouterOS Collection
|
||||
[](https://github.com/ansible-collections/community.routeros/actions)
|
||||
[](https://docs.ansible.com/ansible/latest/collections/community/routeros/)
|
||||
[](https://github.com/ansible-collections/community.routeros/actions)
|
||||
[](https://codecov.io/gh/ansible-collections/community.routeros)
|
||||
[](https://api.reuse.software/info/github.com/ansible-collections/community.routeros)
|
||||
|
||||
|
@ -53,7 +54,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 +184,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 +204,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/).
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
update-docs.py shebang
|
||||
tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
update-docs.py shebang
|
||||
tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
update-docs.py shebang
|
||||
tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
# Copyright (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
|
||||
# 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__'
|
|
@ -1,109 +0,0 @@
|
|||
# Copyright (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
|
||||
# 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
|
|
@ -1,25 +0,0 @@
|
|||
# Copyright (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
|
||||
# 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
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
@ -34,8 +35,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 +44,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 +55,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 +66,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 +78,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 +89,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 +101,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 +112,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 +124,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 +135,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 +147,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 +163,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 +175,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 +189,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 +205,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 +223,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 +244,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 +267,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 +299,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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
@ -437,8 +438,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 +448,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 +457,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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
@ -117,8 +118,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 +137,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 +156,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 +174,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 +191,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 +213,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 +235,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 +257,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 +278,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 +304,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 +326,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 +350,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 +375,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 +451,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 +503,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 +554,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 +607,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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
@ -41,8 +42,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 +54,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 +69,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 +94,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 +123,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 +156,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 +190,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 +279,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 +368,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 +403,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 +461,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 +514,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 +606,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 +689,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 +777,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 +848,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 +900,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 +971,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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
@ -318,8 +319,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 +332,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 +349,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 +367,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 +384,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 +401,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 +417,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 +433,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 +449,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 +467,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 +499,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 +534,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 +557,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 +592,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 +657,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 +723,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 +786,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 +845,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 +904,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 +964,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 +1018,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 +1078,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 +1129,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 +1165,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 +1213,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 +1286,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 +1341,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 +1364,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 +1387,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 +1427,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 +1467,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 +1508,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 +1552,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 +1588,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 +1622,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 +1677,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 +1730,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 +1786,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 +1848,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 +1880,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 +1912,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 +1970,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 +2006,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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
@ -47,54 +48,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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
@ -39,8 +40,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 +62,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 +78,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 +89,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 +119,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']
|
||||
)
|
||||
|
|
|
@ -1,54 +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 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
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
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)
|
Loading…
Add table
Add a link
Reference in a new issue