summaryrefslogtreecommitdiff
path: root/gitlab/tests/test_utils.py
diff options
context:
space:
mode:
authorMax Wittig <max.wittig@siemens.com>2020-08-26 11:01:17 +0200
committerGitHub <noreply@github.com>2020-08-26 11:01:17 +0200
commita7e44a0bb3629f776a52967d56ba67d9a61346eb (patch)
tree24fb533a60a84e71386cc500d6ac2f00548f96ac /gitlab/tests/test_utils.py
parente2dc9ece1a0af37073c41bfa8161fcec5fa01234 (diff)
parent204782a117f77f367dee87aa2c70822587829147 (diff)
downloadgitlab-a7e44a0bb3629f776a52967d56ba67d9a61346eb.tar.gz
Merge pull request #1078 from python-gitlab/refactor/split-unit-tests
Refactor: split unit tests by 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 b57deda..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"
- self.assertEqual(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"
- self.assertEqual(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"
- self.assertEqual(dest, utils.sanitized_url(src))
- src = "http://localhost/foo.bar.baz"
- dest = "http://localhost/foo%2Ebar%2Ebaz"
- self.assertEqual(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)