diff options
author | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2016-01-10 17:21:28 +0100 |
---|---|---|
committer | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2016-01-10 17:21:28 +0100 |
commit | 03d804153f20932226fd3b8a6a5daab5727e878a (patch) | |
tree | 95c1bb029591c98430a5492757f715ce467c8348 /gitlab/tests/test_gitlab.py | |
parent | 4781fd7e4c3d9d5b343f0c1b0597a8a535d6bdbf (diff) | |
download | gitlab-03d804153f20932226fd3b8a6a5daab5727e878a.tar.gz |
Rework gitlab._sanitize
Make it a recursive function and eliminate _sanitize_dict.
Add unit tests.
Diffstat (limited to 'gitlab/tests/test_gitlab.py')
-rw-r--r-- | gitlab/tests/test_gitlab.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py index dc31875..337320f 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -27,9 +27,25 @@ from httmock import HTTMock # noqa from httmock import response # noqa from httmock import urlmatch # noqa +import gitlab from gitlab import * # noqa +class TestSanitize(unittest.TestCase): + def test_do_nothing(self): + self.assertEqual(1, gitlab._sanitize(1)) + self.assertEqual(1.5, gitlab._sanitize(1.5)) + self.assertEqual("foo", gitlab._sanitize("foo")) + + def test_slash(self): + self.assertEqual("foo%2Fbar", gitlab._sanitize("foo/bar")) + + def test_dict(self): + source = {"url": "foo/bar", "id": 1} + expected = {"url": "foo%2Fbar", "id": 1} + self.assertEqual(expected, gitlab._sanitize(source)) + + class TestGitlabRawMethods(unittest.TestCase): def setUp(self): self.gl = Gitlab("http://localhost", private_token="private_token", |