File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed
Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 4141
4242
4343def _sanitize (value ):
44+ if isinstance (value , dict ):
45+ return dict ((k , _sanitize (v ))
46+ for k , v in six .iteritems (value ))
4447 if isinstance (value , six .string_types ):
4548 return value .replace ('/' , '%2F' )
4649 return value
4750
4851
49- def _sanitize_dict (src ):
50- return dict ((k , _sanitize (v )) for k , v in src .items ())
51-
52-
5352class Gitlab (object ):
5453 """Represents a GitLab server connection.
5554
@@ -213,7 +212,7 @@ def set_url(self, url):
213212 def _construct_url (self , id_ , obj , parameters ):
214213 if 'next_url' in parameters :
215214 return parameters ['next_url' ]
216- args = _sanitize_dict (parameters )
215+ args = _sanitize (parameters )
217216 if id_ is None and obj ._urlPlural is not None :
218217 url = obj ._urlPlural % args
219218 else :
Original file line number Diff line number Diff line change 2727from httmock import response # noqa
2828from httmock import urlmatch # noqa
2929
30+ import gitlab
3031from gitlab import * # noqa
3132
3233
34+ class TestSanitize (unittest .TestCase ):
35+ def test_do_nothing (self ):
36+ self .assertEqual (1 , gitlab ._sanitize (1 ))
37+ self .assertEqual (1.5 , gitlab ._sanitize (1.5 ))
38+ self .assertEqual ("foo" , gitlab ._sanitize ("foo" ))
39+
40+ def test_slash (self ):
41+ self .assertEqual ("foo%2Fbar" , gitlab ._sanitize ("foo/bar" ))
42+
43+ def test_dict (self ):
44+ source = {"url" : "foo/bar" , "id" : 1 }
45+ expected = {"url" : "foo%2Fbar" , "id" : 1 }
46+ self .assertEqual (expected , gitlab ._sanitize (source ))
47+
48+
3349class TestGitlabRawMethods (unittest .TestCase ):
3450 def setUp (self ):
3551 self .gl = Gitlab ("http://localhost" , private_token = "private_token" ,
You can’t perform that action at this time.
0 commit comments