-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Synchronise tox configuration between amazon.aws and community.aws (#…
…2486) SUMMARY tox configs needed a little cleanup to ensure that things were consistently in the import path when running pylint. ISSUE TYPE Feature Pull Request COMPONENT NAME pyproject.toml tests/unit/conftest.py tox.ini ADDITIONAL INFORMATION See also: ansible-collections/community.aws#2219 Reviewed-by: Alina Buzachis (cherry picked from commit 62ea880)
- Loading branch information
1 parent
9db670e
commit c0cebeb
Showing
89 changed files
with
893 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of Ansible | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
# While it may seem appropriate to import our custom fixtures here, the pytest_ansible pytest plugin | ||
# isn't as agressive as the ansible_test._util.target.pytest.plugins.ansible_pytest_collections plugin | ||
# when it comes to rewriting the import paths and as such we can't import fixtures via their | ||
# absolute import path or across collections. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of Ansible | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
# pylint: disable=unused-import | ||
|
||
import pytest | ||
|
||
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_maybe_sleep | ||
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_placeboify |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
tests/unit/module_utils/conftest.py → tests/unit/plugins/module_utils/conftest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# (c) 2021 Red Hat Inc. | ||
# | ||
# This file is part of Ansible | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from ansible_collections.amazon.aws.plugins.module_utils import s3 | ||
|
||
mod_urlparse = "ansible_collections.amazon.aws.plugins.module_utils.s3.urlparse" | ||
|
||
|
||
class UrlInfo: | ||
def __init__(self, scheme=None, hostname=None, port=None): | ||
self.hostname = hostname | ||
self.scheme = scheme | ||
self.port = port | ||
|
||
|
||
@patch(mod_urlparse) | ||
def test_is_fakes3_with_none_arg(m_urlparse): | ||
m_urlparse.side_effect = SystemExit(1) | ||
result = s3.is_fakes3(None) | ||
assert not result | ||
m_urlparse.assert_not_called() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url,scheme,result", | ||
[ | ||
("https://test-s3.amazon.com", "https", False), | ||
("fakes3://test-s3.amazon.com", "fakes3", True), | ||
("fakes3s://test-s3.amazon.com", "fakes3s", True), | ||
], | ||
) | ||
@patch(mod_urlparse) | ||
def test_is_fakes3(m_urlparse, url, scheme, result): | ||
m_urlparse.return_value = UrlInfo(scheme=scheme) | ||
assert result == s3.is_fakes3(url) | ||
m_urlparse.assert_called_with(url) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url,urlinfo,endpoint", | ||
[ | ||
( | ||
"fakes3://test-s3.amazon.com", | ||
{"scheme": "fakes3", "hostname": "test-s3.amazon.com"}, | ||
{"endpoint": "http://test-s3.amazon.com:80", "use_ssl": False}, | ||
), | ||
( | ||
"fakes3://test-s3.amazon.com:8080", | ||
{"scheme": "fakes3", "hostname": "test-s3.amazon.com", "port": 8080}, | ||
{"endpoint": "http://test-s3.amazon.com:8080", "use_ssl": False}, | ||
), | ||
( | ||
"fakes3s://test-s3.amazon.com", | ||
{"scheme": "fakes3s", "hostname": "test-s3.amazon.com"}, | ||
{"endpoint": "https://test-s3.amazon.com:443", "use_ssl": True}, | ||
), | ||
( | ||
"fakes3s://test-s3.amazon.com:9096", | ||
{"scheme": "fakes3s", "hostname": "test-s3.amazon.com", "port": 9096}, | ||
{"endpoint": "https://test-s3.amazon.com:9096", "use_ssl": True}, | ||
), | ||
], | ||
) | ||
@patch(mod_urlparse) | ||
def test_parse_fakes3_endpoint(m_urlparse, url, urlinfo, endpoint): | ||
m_urlparse.return_value = UrlInfo(**urlinfo) | ||
result = s3.parse_fakes3_endpoint(url) | ||
assert endpoint == result | ||
m_urlparse.assert_called_with(url) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url,scheme,use_ssl", | ||
[ | ||
("https://test-s3-ceph.amazon.com", "https", True), | ||
("http://test-s3-ceph.amazon.com", "http", False), | ||
], | ||
) | ||
@patch(mod_urlparse) | ||
def test_parse_ceph_endpoint(m_urlparse, url, scheme, use_ssl): | ||
m_urlparse.return_value = UrlInfo(scheme=scheme) | ||
result = s3.parse_ceph_endpoint(url) | ||
assert result == {"endpoint": url, "use_ssl": use_ssl} | ||
m_urlparse.assert_called_with(url) |
File renamed without changes.
Oops, something went wrong.