summaryrefslogtreecommitdiff
path: root/gitlab/tests/test_utils.py
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2020-04-17 02:26:28 +0200
committerNejc Habjan <nejc.habjan@siemens.com>2020-08-22 20:09:52 +0200
commit76b2cadf1418e4ea2ac420ebba5a4b4f16fbd4c7 (patch)
tree4dbe6ae57c4f03e1351f7a49e590cbbc6d31121a /gitlab/tests/test_utils.py
parent11383e70f74c70e6fe8a56f18b5b170db982f402 (diff)
downloadgitlab-76b2cadf1418e4ea2ac420ebba5a4b4f16fbd4c7.tar.gz
refactor: split unit tests by GitLab API resources
Diffstat (limited to 'gitlab/tests/test_utils.py')
-rw-r--r--gitlab/tests/test_utils.py48
1 files changed, 31 insertions, 17 deletions
diff --git a/gitlab/tests/test_utils.py b/gitlab/tests/test_utils.py
index 7ebd006..50aaecf 100644
--- a/gitlab/tests/test_utils.py
+++ b/gitlab/tests/test_utils.py
@@ -15,26 +15,40 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import unittest
-
from gitlab import utils
-class TestUtils(unittest.TestCase):
- def test_clean_str_id(self):
- src = "nothing_special"
- dest = "nothing_special"
- assert dest == utils.clean_str_id(src)
+def test_clean_str_id():
+ src = "nothing_special"
+ dest = "nothing_special"
+ assert dest == utils.clean_str_id(src)
+
+ src = "foo#bar/baz/"
+ dest = "foo%23bar%2Fbaz%2F"
+ assert dest == utils.clean_str_id(src)
+
+
+def test_sanitized_url():
+ src = "http://localhost/foo/bar"
+ dest = "http://localhost/foo/bar"
+ assert dest == utils.sanitized_url(src)
+
+ src = "http://localhost/foo.bar.baz"
+ dest = "http://localhost/foo%2Ebar%2Ebaz"
+ assert dest == utils.sanitized_url(src)
+
+
+def test_sanitize_parameters_does_nothing():
+ assert 1 == utils.sanitize_parameters(1)
+ assert 1.5 == utils.sanitize_parameters(1.5)
+ assert "foo" == utils.sanitize_parameters("foo")
+
- src = "foo#bar/baz/"
- dest = "foo%23bar%2Fbaz%2F"
- assert dest == utils.clean_str_id(src)
+def test_sanitize_parameters_slash():
+ assert "foo%2Fbar" == utils.sanitize_parameters("foo/bar")
- def test_sanitized_url(self):
- src = "http://localhost/foo/bar"
- dest = "http://localhost/foo/bar"
- assert dest == utils.sanitized_url(src)
- src = "http://localhost/foo.bar.baz"
- dest = "http://localhost/foo%2Ebar%2Ebaz"
- assert dest == utils.sanitized_url(src)
+def test_sanitize_parameters_dict():
+ source = {"url": "foo/bar", "id": 1}
+ expected = {"url": "foo%2Fbar", "id": 1}
+ assert expected == utils.sanitize_parameters(source)