Skip to content

Commit 0e4db56

Browse files
authored
Merge pull request #2069 from antoineauger/test/unit-tests-projects
test(projects): add unit tests for projects
2 parents 389e1e6 + a51f848 commit 0e4db56

File tree

3 files changed

+538
-107
lines changed

3 files changed

+538
-107
lines changed

tests/unit/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ def project(gl):
6969
return gl.projects.get(1, lazy=True)
7070

7171

72+
@pytest.fixture
73+
def another_project(gl):
74+
return gl.projects.get(2, lazy=True)
75+
76+
7277
@pytest.fixture
7378
def project_issue(project):
7479
return project.issues.get(1, lazy=True)

tests/unit/objects/test_project_import_export.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,36 @@ def resp_import_github():
7373
yield rsps
7474

7575

76+
@pytest.fixture
77+
def resp_import_bitbucket_server():
78+
content = {
79+
"id": 1,
80+
"name": "project",
81+
"import_status": "scheduled",
82+
}
83+
84+
with responses.RequestsMock() as rsps:
85+
rsps.add(
86+
method=responses.POST,
87+
url="http://localhost/api/v4/import/bitbucket_server",
88+
json=content,
89+
content_type="application/json",
90+
status=201,
91+
)
92+
yield rsps
93+
94+
7695
def test_import_project(gl, resp_import_project):
77-
project_import = gl.projects.import_project("file", "api-project")
96+
project_import = gl.projects.import_project(
97+
"file", "api-project", "api-project", "root"
98+
)
99+
assert project_import["import_status"] == "scheduled"
100+
101+
102+
def test_import_project_with_override_params(gl, resp_import_project):
103+
project_import = gl.projects.import_project(
104+
"file", "api-project", override_params={"visibility": "private"}
105+
)
78106
assert project_import["import_status"] == "scheduled"
79107

80108

@@ -94,6 +122,21 @@ def test_import_github(gl, resp_import_github):
94122
assert ret["full_name"].endswith(name)
95123

96124

125+
def test_import_bitbucket_server(gl, resp_import_bitbucket_server):
126+
res = gl.projects.import_bitbucket_server(
127+
bitbucket_server_project="project",
128+
bitbucket_server_repo="repo",
129+
bitbucket_server_url="url",
130+
bitbucket_server_username="username",
131+
personal_access_token="token",
132+
new_name="new_name",
133+
target_namespace="namespace",
134+
)
135+
assert res["id"] == 1
136+
assert res["name"] == "project"
137+
assert res["import_status"] == "scheduled"
138+
139+
97140
def test_create_project_export(project, resp_export):
98141
export = project.exports.create()
99142
assert export.message == "202 Accepted"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy