Skip to content

Commit fa899d7

Browse files
Oleksii ShkurupiiOleksii Shkurupii
Oleksii Shkurupii
authored and
Oleksii Shkurupii
committed
Merge branch 'master' into issue-1154
2 parents 88f8cc7 + a038e95 commit fa899d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2790
-2617
lines changed

docs/cli.rst

+12
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ List all the projects:
192192
193193
$ gitlab project list --all
194194
195+
List all projects of a group:
196+
197+
.. code-block:: console
198+
199+
$ gitlab group-project list --all --group-id 1
200+
201+
List all projects of a group and its subgroups:
202+
203+
.. code-block:: console
204+
205+
$ gitlab group-project list --all --include-subgroups true --group-id 1
206+
195207
Limit to 5 items per request, display the 1st page only
196208

197209
.. code-block:: console

gitlab/__init__.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@
4545
ALLOWED_KEYSET_ENDPOINTS = ["/projects"]
4646

4747

48-
def _sanitize(value):
49-
if isinstance(value, dict):
50-
return dict((k, _sanitize(v)) for k, v in value.items())
51-
if isinstance(value, str):
52-
return value.replace("/", "%2F")
53-
return value
54-
55-
5648
class Gitlab(object):
5749
"""Represents a GitLab server connection.
5850
@@ -322,7 +314,7 @@ def set_license(self, license, **kwargs):
322314
def _construct_url(self, id_, obj, parameters, action=None):
323315
if "next_url" in parameters:
324316
return parameters["next_url"]
325-
args = _sanitize(parameters)
317+
args = utils.sanitize_parameters(parameters)
326318

327319
url_attr = "_url"
328320
if action is not None:

gitlab/cli.py

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from __future__ import print_function
2019

2120
import argparse
2221
import functools

gitlab/tests/conftest.py

+40
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,43 @@ def gl():
1010
ssl_verify=True,
1111
api_version=4,
1212
)
13+
14+
15+
# Todo: parametrize, but check what tests it's really useful for
16+
@pytest.fixture
17+
def gl_trailing():
18+
return gitlab.Gitlab(
19+
"http://localhost/", private_token="private_token", api_version=4
20+
)
21+
22+
23+
@pytest.fixture
24+
def default_config(tmpdir):
25+
valid_config = """[global]
26+
default = one
27+
ssl_verify = true
28+
timeout = 2
29+
30+
[one]
31+
url = http://one.url
32+
private_token = ABCDEF
33+
"""
34+
35+
config_path = tmpdir.join("python-gitlab.cfg")
36+
config_path.write(valid_config)
37+
return str(config_path)
38+
39+
40+
@pytest.fixture
41+
def group(gl):
42+
return gl.groups.get(1, lazy=True)
43+
44+
45+
@pytest.fixture
46+
def project(gl):
47+
return gl.projects.get(1, lazy=True)
48+
49+
50+
@pytest.fixture
51+
def user(gl):
52+
return gl.users.get(1, lazy=True)
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from gitlab.mixins import (
2+
CreateMixin,
3+
CRUDMixin,
4+
DeleteMixin,
5+
GetMixin,
6+
ListMixin,
7+
NoUpdateMixin,
8+
UpdateMixin,
9+
RetrieveMixin,
10+
)
11+
12+
13+
def test_retrieve_mixin():
14+
class M(RetrieveMixin):
15+
pass
16+
17+
obj = M()
18+
assert hasattr(obj, "list")
19+
assert hasattr(obj, "get")
20+
assert not hasattr(obj, "create")
21+
assert not hasattr(obj, "update")
22+
assert not hasattr(obj, "delete")
23+
assert isinstance(obj, ListMixin)
24+
assert isinstance(obj, GetMixin)
25+
26+
27+
def test_crud_mixin():
28+
class M(CRUDMixin):
29+
pass
30+
31+
obj = M()
32+
assert hasattr(obj, "get")
33+
assert hasattr(obj, "list")
34+
assert hasattr(obj, "create")
35+
assert hasattr(obj, "update")
36+
assert hasattr(obj, "delete")
37+
assert isinstance(obj, ListMixin)
38+
assert isinstance(obj, GetMixin)
39+
assert isinstance(obj, CreateMixin)
40+
assert isinstance(obj, UpdateMixin)
41+
assert isinstance(obj, DeleteMixin)
42+
43+
44+
def test_no_update_mixin():
45+
class M(NoUpdateMixin):
46+
pass
47+
48+
obj = M()
49+
assert hasattr(obj, "get")
50+
assert hasattr(obj, "list")
51+
assert hasattr(obj, "create")
52+
assert not hasattr(obj, "update")
53+
assert hasattr(obj, "delete")
54+
assert isinstance(obj, ListMixin)
55+
assert isinstance(obj, GetMixin)
56+
assert isinstance(obj, CreateMixin)
57+
assert not isinstance(obj, UpdateMixin)
58+
assert isinstance(obj, DeleteMixin)

0 commit comments

Comments
 (0)