2017-03-02 22:07:56 +00:00
|
|
|
import pytest
|
2017-08-11 13:34:33 +00:00
|
|
|
|
2017-01-31 16:54:29 +00:00
|
|
|
import unittest
|
2017-05-30 17:05:19 +00:00
|
|
|
|
2017-08-22 15:50:45 +00:00
|
|
|
try:
|
2018-07-13 14:56:57 +00:00
|
|
|
import ansible.modules.cloud.amazon.aws_s3 as s3
|
2017-08-22 15:50:45 +00:00
|
|
|
except ImportError:
|
2017-11-30 22:04:09 +00:00
|
|
|
pytestmark = pytest.mark.skip("This test requires the s3 Python libraries")
|
2017-08-22 15:50:45 +00:00
|
|
|
|
2017-01-31 16:54:29 +00:00
|
|
|
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
|
|
|
|
2017-08-11 13:34:33 +00:00
|
|
|
boto3 = pytest.importorskip("boto3")
|
2017-05-30 17:05:19 +00:00
|
|
|
|
|
|
|
|
2017-01-31 16:54:29 +00:00
|
|
|
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_get_s3_connection(self):
|
|
|
|
aws_connect_kwargs = dict(aws_access_key_id="access_key",
|
2017-05-30 17:05:19 +00:00
|
|
|
aws_secret_access_key="secret_key")
|
|
|
|
location = None
|
|
|
|
rgw = True
|
|
|
|
s3_url = "http://bla.blubb"
|
2017-08-11 13:34:33 +00:00
|
|
|
actual = s3.get_s3_connection(None, aws_connect_kwargs, location, rgw, s3_url)
|
|
|
|
self.assertEqual(bool("bla.blubb" in str(actual._endpoint)), True)
|