summaryrefslogtreecommitdiff
path: root/gitlab/tests/test_utils.py
diff options
context:
space:
mode:
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)