| 1 |
# Copyright 2023 Red Hat, Inc. |
| 2 |
# All Rights Reserved. |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 |
# not use this file except in compliance with the License. You may obtain |
| 6 |
# a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 |
# License for the specific language governing permissions and limitations |
| 14 |
# under the License. |
| 15 |
|
| 16 |
|
| 17 |
from config_tempest.tests.base import BaseConfigTempestTest |
| 18 |
from config_tempest import utils |
| 19 |
|
| 20 |
|
| 21 |
class TestUtils(BaseConfigTempestTest): |
| 22 |
"""Utils test class |
| 23 |
|
| 24 |
Tests for get_base_url method. |
| 25 |
""" |
| 26 |
|
| 27 |
def setUp(self): |
| 28 |
super(TestUtils, self).setUp() |
| 29 |
self.fake_urls = [ |
| 30 |
"http://10.200.16.10:8774", |
| 31 |
"http://10.200.16.10:5000/v3", |
| 32 |
"http://10.200.16.10/path", |
| 33 |
"http://10.200.16.10:8774/path", |
| 34 |
"http://10.200.16.10:8774/path/v2.1", |
| 35 |
"http://10.200.16.10:8774/path/v2/58f582e50641fead037e8e3f7ca59f", |
| 36 |
] |
| 37 |
self.expected_base_urls = [ |
| 38 |
"http://10.200.16.10:8774/", |
| 39 |
"http://10.200.16.10:5000/", |
| 40 |
"http://10.200.16.10/path/", |
| 41 |
"http://10.200.16.10:8774/path/", |
| 42 |
"http://10.200.16.10:8774/path/", |
| 43 |
"http://10.200.16.10:8774/path/", |
| 44 |
] |
| 45 |
self.test_cases = zip(self.fake_urls, self.expected_base_urls) |
| 46 |
|
| 47 |
def test_get_base_url(self): |
| 48 |
for url, expected_base_url in self.test_cases: |
| 49 |
with self.subTest(url=url): |
| 50 |
base_url = utils.get_base_url(url) |
| 51 |
self.assertEqual(expected_base_url, base_url) |