Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita7e44a0

Browse files
authored
Merge pull request#1078 from python-gitlab/refactor/split-unit-tests
Refactor: split unit tests by API resources
2 parentse2dc9ec +204782a commita7e44a0

File tree

42 files changed

+2778
-2617
lines changed

Some content is hidden

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

42 files changed

+2778
-2617
lines changed

‎gitlab/__init__.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@
4545
ALLOWED_KEYSET_ENDPOINTS= ["/projects"]
4646

4747

48-
def_sanitize(value):
49-
ifisinstance(value,dict):
50-
returndict((k,_sanitize(v))fork,vinvalue.items())
51-
ifisinstance(value,str):
52-
returnvalue.replace("/","%2F")
53-
returnvalue
54-
55-
5648
classGitlab(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"inparameters:
324316
returnparameters["next_url"]
325-
args=_sanitize(parameters)
317+
args=utils.sanitize_parameters(parameters)
326318

327319
url_attr="_url"
328320
ifactionisnotNone:

‎gitlab/cli.py

Lines changed: 0 additions & 1 deletion
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__importprint_function
2019

2120
importargparse
2221
importfunctools

‎gitlab/tests/conftest.py

Lines changed: 40 additions & 0 deletions
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+
defgl_trailing():
18+
returngitlab.Gitlab(
19+
"http://localhost/",private_token="private_token",api_version=4
20+
)
21+
22+
23+
@pytest.fixture
24+
defdefault_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+
returnstr(config_path)
38+
39+
40+
@pytest.fixture
41+
defgroup(gl):
42+
returngl.groups.get(1,lazy=True)
43+
44+
45+
@pytest.fixture
46+
defproject(gl):
47+
returngl.projects.get(1,lazy=True)
48+
49+
50+
@pytest.fixture
51+
defuser(gl):
52+
returngl.users.get(1,lazy=True)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
fromgitlab.mixinsimport (
2+
CreateMixin,
3+
CRUDMixin,
4+
DeleteMixin,
5+
GetMixin,
6+
ListMixin,
7+
NoUpdateMixin,
8+
UpdateMixin,
9+
RetrieveMixin,
10+
)
11+
12+
13+
deftest_retrieve_mixin():
14+
classM(RetrieveMixin):
15+
pass
16+
17+
obj=M()
18+
asserthasattr(obj,"list")
19+
asserthasattr(obj,"get")
20+
assertnothasattr(obj,"create")
21+
assertnothasattr(obj,"update")
22+
assertnothasattr(obj,"delete")
23+
assertisinstance(obj,ListMixin)
24+
assertisinstance(obj,GetMixin)
25+
26+
27+
deftest_crud_mixin():
28+
classM(CRUDMixin):
29+
pass
30+
31+
obj=M()
32+
asserthasattr(obj,"get")
33+
asserthasattr(obj,"list")
34+
asserthasattr(obj,"create")
35+
asserthasattr(obj,"update")
36+
asserthasattr(obj,"delete")
37+
assertisinstance(obj,ListMixin)
38+
assertisinstance(obj,GetMixin)
39+
assertisinstance(obj,CreateMixin)
40+
assertisinstance(obj,UpdateMixin)
41+
assertisinstance(obj,DeleteMixin)
42+
43+
44+
deftest_no_update_mixin():
45+
classM(NoUpdateMixin):
46+
pass
47+
48+
obj=M()
49+
asserthasattr(obj,"get")
50+
asserthasattr(obj,"list")
51+
asserthasattr(obj,"create")
52+
assertnothasattr(obj,"update")
53+
asserthasattr(obj,"delete")
54+
assertisinstance(obj,ListMixin)
55+
assertisinstance(obj,GetMixin)
56+
assertisinstance(obj,CreateMixin)
57+
assertnotisinstance(obj,UpdateMixin)
58+
assertisinstance(obj,DeleteMixin)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp