Commit Graph

2192 Commits (87601969a3a9d9c793d3af6574aef0e8c15932c6)

Author SHA1 Message Date
Toshio Kuratomi 87601969a3 Correct places where match was intended
pytest.raises has two parameters, message and match.  message is meant
to be the error message that pytest gives when the tested code does not
raise the expected exception.  match is the string that pytest expects
to be a match for the repr of the exception.  Unfortunately, it seems
that message is often mistakenly used where match is meant.  Fix those
cases.

message is also deprecated so removed our usage of it.  Perhaps we
should write a sanity test later that prevents the use of
pytest.raises(message) to avoid this mistake.

seealso: https://docs.pytest.org/en/4.6-maintenance/deprecations.html#message-parameter-of-pytest-raises

Also update the exception message tested for as we're now properly
detecting that the messages have changed.
5 years ago
Aljaž Košir 42073b6331 Add lambda_bucket_event module (#58059) 5 years ago
Sumit Jaiswal b01b1d40cf
PR to add Unit TC for Checkpoint network module (#57710)
* cp_network unit TC

Signed-off-by: Sumit Jaiswal <sjaiswal@redhat.com>
5 years ago
Brian Coca a39b721db5
fixes to config manager (#58530)
* skip unreadable ansible.cfg

* all types should check for type

* patch access for tests and fix tests that relied on missing files not being checked
5 years ago
Matt Davis d28f25d118
patch ansible-connection collection plugin loading (#59119) 5 years ago
Matt Clay d4dec59cb0 Fix collection loader builtin handling. (#58897)
- Support more import statements:

  from ansible_collections.ansible.builtin.plugins.module_utils import basic
  from ansible_collections.ansible.builtin.plugins.module_utils.basic import AnsibleModule

- Add unit tests for more import statements.
- Raise ImportError instead of returning None if load_module fails.
5 years ago
Chris Archibald 8bf069114f New Module: Vscan Enable (#57953)
* new module

* fix netapp.py

* updates

* fixes
5 years ago
Alvaro Olmedo Rodriguez a1dcba63b3 java_keystore - Prefer SHA256 and solve SHA256 keytool in java11 version (#57302) 5 years ago
Chris Archibald f3aac3a112 MOTD was not idempotent (#57372)
* fix issue

* fix issues

* fix issues

* fix issues
5 years ago
Chris Archibald 9cb78b4826 New options to volume (#58531)
* updates to volume

* fix ansibot

* fix issues

* Revert "fix issues"

This reverts commit 54988709ae.
5 years ago
Chris Archibald 59feb63d19 Add uid, and gid to volume clone (#57371)
* and new features

* fix issues

* fix issues

* fix issues

* add unit tests
5 years ago
Chris Archibald 6e3d54ae81 Set vscan_fileop_profile for na_ontap_cifs (#57373)
* new features

* update unit tests
5 years ago
pratikgadiya12 e8f4ebb22c nmcli: Argument vlanid (int) is changed internally to string (#58963)
* Argument vlanid (int) is changed internally to string
* Modified test case to check vlan id

Fixes: #58949
5 years ago
Matt Clay c79afb1cba Move ansible-test unit coverage code into plugin. 5 years ago
rajaspachipulusu17 753f998262 Pluribus Networks ipv6 security reguard vlan module with UT (#58319) 5 years ago
Chris Archibald 8731fc7a86 returning invalid security (#58595) 5 years ago
Matt Clay 9e67953b2e
Fix collection loader and add unit tests. (#58701)
* Use `compile` before `eval` in collection loader.

This fixes two issues:

1. File names are available when tracing execution, such as with code coverage.
2. Future statements are not inherited from the collection loader.

* Add unit tests for collection loading.

These tests verify several things:

1. That unit tests can import code from collections when the collection loader is installed.
2. That tracing reports the correct file and line numbers (to support code coverage).
3. That collection code does not inherit __future__ statements from the collection loader.

* Update unit test handling of the collection loader.

Since the collection loader is installed simply by importing ansible.plugins.loader,
we may already have a collection loader installed when the test runs. This occurs if
any other tests are collected which use that import during collection. Until that code
is moved into an initialization function to avoid loading during import, the unit tests
will need to replace any existing collection loaders so that they reflect the desired
configuration.

* Insert into sys.modules before calling exec.

This is a requirement of PEP 302.

It will prevent recursion errors when importing the current module or using a relative import.

* Use the correct value for __package__ in modules.

This allows using relative imports in collections.

* Add warning about modifying code for trace test.

* Add test for relative import in collection.

* Add __init__.py to collection to satisfy pylint.

The relative-beyond-top-level rule in pylint may not be appropriate for collections.
However, until that rule is disabled for collections this will keep tests passing.
5 years ago
Jordan Borean b6791e6ae3
ansible-galaxy: add collection sub command (#57106)
* ansible-galaxy: add collection init sub command

* Fix changelog and other sanity issues

* Slim down skeleton structure, fix encoding issue on template

* Fix doc generation code to include sub commands

* Added build step

* Tidy up the build action

* Fixed up doc changes and slight testing tweaks

* Re-organise tests to use pytest

* Added publish step and fixed up issues after working with Galaxy

* Unit test improvments

* Fix unit test on 3.5

* Add remaining build tests

* Test fixes, make the integration tests clearer to debug on failures

* Removed unicode name tests until I've got further clarification

* Added publish unit tests

* Change expected length value

* Added collection install steps, tests forthcoming

* Added unit tests for collection install entrypoint

* Added some more tests for collection install

* follow proper encoding rules and added more tests

* Add remaining tests

* tidied up tests and code based on review

* exclude pre-release versions from galaxy API
5 years ago
Miguel Angel Muñoz González d50531c6bd New Fortinet's module for fortios_user_device (using new httpapi plugin) (#58291)
* New Fortinet's module for fortios_user_device (using new httpapi plugin

* Fix documentation errors

* Update lib/ansible/modules/network/fortios/fortios_user_device.py

Co-Authored-By: Sandra McCann <samccann@redhat.com>

* Update lib/ansible/modules/network/fortios/fortios_user_device.py

Co-Authored-By: Sandra McCann <samccann@redhat.com>

* Update lib/ansible/modules/network/fortios/fortios_user_device.py

Co-Authored-By: Sandra McCann <samccann@redhat.com>

* Update lib/ansible/modules/network/fortios/fortios_user_device.py

Co-Authored-By: Sandra McCann <samccann@redhat.com>

* Update lib/ansible/modules/network/fortios/fortios_user_device.py

Co-Authored-By: Sandra McCann <samccann@redhat.com>

* Update lib/ansible/modules/network/fortios/fortios_user_device.py

Co-Authored-By: Sandra McCann <samccann@redhat.com>
5 years ago
Andrey Klychkov 88ec5e14cb Add unit tests for lenient_lowercase function (#58586) 5 years ago
Abhijeet Kasurde 79fdc2190a role: Fix role's hash_params (#55263)
* role: Fix role's hash_params

Fix based upon work done by alikins.

Fixes: #20596

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>

* review comments

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
5 years ago
Diane Wang 9c140d26d5 VMware: add new module vmware_guest_network (#52075) 5 years ago
Toshio Kuratomi 0c992d5ae4 Fix for skipping of gitlab_runner test.
Correct variable name for skipping of the gitlab test when gitlab python
client is not installed.
5 years ago
Mariusz Mazur 2fb06650a7 kubevirt: even more unit tests (#58593) 5 years ago
Abhijeet Kasurde 96eccda23b
VMware: Add module vmware_vm_storage_policy_info (#56263)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
5 years ago
Ganesh Nalawade 1e3034b96d
junos_facts refactor to work with resources modules (#58566)
* junos_facts refactor to work with resources modules

*  Refactor junos_facts module to work with
   network resource module.

* Fix unit test failures

* Fix review comments
5 years ago
Brian Coca ee4cba1b85 ensure bytes in run_command (#58411)
* ensure we pass bytes to run_command

* changed tests for new behaviour

* dont b the pytest

* fixes by sivel
5 years ago
Andrey Klychkov 10af2636d1 Add unit tests for human_to_bytes (#58584) 5 years ago
Felix Fontein f0801879c7 Rename xenserver_guest_facts -> xenserver_guest_info (#57032)
* Rename xenserver_guest_facts -> xenserver_guest_info.

* Add changelog.

* Forgot one test.
5 years ago
Sam Doran ab6a9ef130
Get minor version number for CentOS and Debian (#57814)
* Get the most detailed version number from distro.version() for CentOS and Debian
* Update tests and fixtures
* Update fixture generation script to gather distro info and work with Python 3
* Update LinuxMint fixtures
* Cleanup fixture formatting
* Improvements based on feedback from abadger:
    - use unicode since that is what distro returns
    - use frozenset with a tuple
    - include link Debian to bug
5 years ago
Sam Doran 6cf6f5a34b
Use atexit to cleanup tmp dirs (#56532)
* Wrap everything in try/except to avoid leaving files behind
* Add unit tests, integration tests, and changelog
* Do text the correct way
5 years ago
Toshio Kuratomi 8acf71f78f
Skip tests with unsatisfied deps (#55853)
* Skip gitlab tests if dependencies aren't met

* Skip certain unittests if passlib is not installed

* Fix tests with deps on paramiko to skip if paramiko is not installed

* Use pytest to skip for cloudstack

If either on Python-2.6 or the cs library is not installed we cannot run
this test so skip it
5 years ago
Sloane Hertel 826f224f02
Handle vaulted non-ascii characters for Python2 (#58503)
* Handle vaulted non-ascii characters for Python2

* Add a test to ensure str() no longer raises UnicodeEncodeError
5 years ago
Olivier Scherler 7ed7d374e4 Fix onepassword lookup plugin and onepassword_facts module when a field has no name. (#58308)
* Fix onepassword lookup plugin crashing on fields with no 'name' or 't' property.

* Fix onepassword_facts module crashing on fields with no 'name' or 't' property.

* Add unit test for onepassword lookup plugin failing on entries without a name.

* Add changelog fragment for onepassword lookup plugin and onepassword_facts module fixes on fields without a name.
5 years ago
Chris Van Heuveln 0868fec8bd nxos_vpc: pkl_vrf fixes for #57069 (#57370)
* nxos_vpc: pkl_vrf fixes for #57069

Fixes #57069

- Symptom: When playbooks specify `pkl_vrf: default`, the result is that the cli does not set the `vrf` state.

- Analysis:
 - First issue: 'default' is a reserved word when used with the `peer-keepalive` `vrf` keyword. It refers to the default rib.
   - This is confusing in several ways because `peer-keepalive`'s *default* vrf is the `management` vrf.

 - Second issue: When changing only one optional value (`pkl_vrf`) while other optional values are idempotent (`pkl_src`), the result is that the idempotent values are ignored; unfortunately the device cli *replaces* the entire command, in which case the idempotent values are removed.
   - e.g. playbook specifies this:
     ```
     { pkl_dest: 10.1.1.1, pkl_src: 10.2.2.2, pkl_vrf: my_vrf }
     ```

     ```
     peer-keepalive dest 10.1.1.1 src 10.2.2.2             # original

     peer-keepalive dest 10.1.1.1 src 10.2.2.2 vrf my_vrf  # intended result

     peer-keepalive dest 10.1.1.1 vrf my_vrf               # actual result
     ```

 - Third issue: the `pkl` getter was relying on positional data. This broke when the `udp` keyword nvgen'd where `vrf` used to appear (shifting all keywords to the right).

- Tested on regression platforms: `N3K,N6k,N7K,N9K,N3K-F,N9K-F`

* PEP fixes

* PEP fix 2

* pkl should merge by default, not override

* rmv debugs

* add mike's tests

* fix comments
5 years ago
Daniel Mellado Area db689f7221 Fix ovsdb module not being idempotent (#57735)
openvswitch_db was not parsing properly some arguments, which caused
some commands to be executed when they shouldn't. This commit fixesit
and adds unit testing for the usecase.

Closes-Bug: #55432
Closes-bug: #43858
5 years ago
Matt Martz e32d60bbcd
Add back _contains_vars method as maybe_template (#58290)
* Add back _contains_vars method as maybe_template. Fixes #58282

* Remove template guard in a few places

* maybe_template sounds like it might template something, rename to is_possibly_template

* Add tests for is_possibly_template
5 years ago
Wojciech Wypior ac101f7f33 adds initial_hotfix parameter to vcmp guest (#58180) 5 years ago
Mariusz Mazur 06292566ec kubevirt: more unit tests (#57739)
* Add tests for KubeAPIVersion

* Legibility improvements for KubevirtVM tests

* Create units.utils.kubevirt with common stuff

* Add some VMIRS unit tests
5 years ago
rajaspachipulusu17 fc1798cc14 Pluribus Networks ipv6security raguard module with UT (#57031)
* Pluribus Networks ipv6security raguard module with UT
* Doc fixes
5 years ago
Felix Fontein 4a12be31fb docker_* modules: improve error message when docker-py is missing (#57914)
* Improve error for docker modules when docker-py can't be imported.

* Add changelog.

* Mention platform and Python interpreter in more cases.

* Clarify wording.

* Adjust tests.
5 years ago
Wojciech Wypior 30ada17d4f Adds message routing transport module (#58201) 5 years ago
Wojciech Wypior b8fd2f4df3 adds generic routing peer module (#58189) 5 years ago
Wojciech Wypior 429bf5340e adds module for message routing protocol (#58188) 5 years ago
Wojciech Wypior 0a3a94a493 adds new module to manage firewall schedules (#58187) 5 years ago
Wojciech Wypior 92a1e6845c Adds two modules to manage AFM log profiles (#58186) 5 years ago
Toshio Kuratomi eb7e4591ae Fix ios test for python2 non-ascii paths 5 years ago
Wojciech Wypior fbca93b8ad removes args from the code and corrects few missed tests (#58175) 5 years ago
Wojciech Wypior 56b3b1ac56 adds message routing router module (#58191) 5 years ago
Wojciech Wypior c1f2df4753 adds message routing route module (#58190) 5 years ago