mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
s3 module: fix urlparse invocation and netloc mixup on Python 3 (#20836)
This commit is contained in:
parent
65f561e496
commit
3f14061584
2 changed files with 83 additions and 31 deletions
46
test/units/modules/cloud/amazon/test_s3.py
Normal file
46
test/units/modules/cloud/amazon/test_s3.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
from nose.plugins.skip import SkipTest
|
||||
|
||||
try:
|
||||
import boto
|
||||
HAS_BOTO = True
|
||||
except ImportError:
|
||||
HAS_BOTO = False
|
||||
|
||||
if not HAS_BOTO:
|
||||
raise SkipTest("test_s3.py requires the python module 'boto3' and 'botocore'")
|
||||
|
||||
import unittest
|
||||
import ansible.modules.cloud.amazon.s3 as s3
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||
|
||||
class TestUrlparse(unittest.TestCase):
|
||||
|
||||
def test_urlparse(self):
|
||||
actual = urlparse("http://test.com/here")
|
||||
self.assertEqual("http", actual.scheme)
|
||||
self.assertEqual("test.com", actual.netloc)
|
||||
self.assertEqual("/here", actual.path)
|
||||
|
||||
def test_is_fakes3(self):
|
||||
actual = s3.is_fakes3("fakes3://bla.blubb")
|
||||
self.assertEqual(True, actual)
|
||||
|
||||
def test_is_walrus(self):
|
||||
actual = s3.is_walrus("trulywalrus_but_invalid_url")
|
||||
#I don't know if this makes sense, but this is the current behaviour...
|
||||
self.assertEqual(True, actual)
|
||||
actual = s3.is_walrus("http://notwalrus.amazonaws.com")
|
||||
self.assertEqual(False, actual)
|
||||
|
||||
def test_get_s3_connection(self):
|
||||
aws_connect_kwargs = dict(aws_access_key_id="access_key",
|
||||
aws_secret_access_key="secret_key")
|
||||
location=None
|
||||
rgw=True
|
||||
s3_url="http://bla.blubb"
|
||||
actual = s3.get_s3_connection(aws_connect_kwargs, location, rgw, s3_url)
|
||||
self.assertEqual("bla.blubb", actual.host)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Add table
Add a link
Reference in a new issue