mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
8 years ago
|
import pytest
|
||
7 years ago
|
|
||
8 years ago
|
import unittest
|
||
8 years ago
|
|
||
7 years ago
|
try:
|
||
6 years ago
|
import ansible.modules.cloud.amazon.aws_s3 as s3
|
||
7 years ago
|
except ImportError:
|
||
7 years ago
|
pytestmark = pytest.mark.skip("This test requires the s3 Python libraries")
|
||
7 years ago
|
|
||
8 years ago
|
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||
|
|
||
7 years ago
|
boto3 = pytest.importorskip("boto3")
|
||
8 years ago
|
|
||
|
|
||
8 years ago
|
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",
|
||
8 years ago
|
aws_secret_access_key="secret_key")
|
||
|
location = None
|
||
|
rgw = True
|
||
|
s3_url = "http://bla.blubb"
|
||
7 years ago
|
actual = s3.get_s3_connection(None, aws_connect_kwargs, location, rgw, s3_url)
|
||
|
self.assertEqual(bool("bla.blubb" in str(actual._endpoint)), True)
|