8000 test(projects): add unit tests for projects by antoineauger · Pull Request #2069 · python-gitlab/python-gitlab · GitHub
[go: up one dir, main page]

Skip to content

test(projects): add unit tests for projects #2069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def project(gl):
return gl.projects.get(1, lazy=True)


@pytest.fixture
def another_project(gl):
return gl.projects.get(2, lazy=True)


@pytest.fixture
def project_issue(project):
return project.issues.get(1, lazy=True)
Expand Down
45 changes: 44 additions & 1 deletion tests/unit/objects/test_project_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,36 @@ def resp_import_github():
yield rsps


@pytest.fixture
def resp_import_bitbucket_server():
content = {
"id": 1,
"name": "project",
"import_status": "scheduled",
}

with responses.RequestsMock() as rsps:
rsps.add(
method=responses.POST,
url="http://localhost/api/v4/import/bitbucket_server",
json=content,
content_type="application/json",
status=201,
)
yield rsps


def test_import_project(gl, resp_import_project):
project_import = gl.projects.import_project("file", "api-project")
project_import = gl.projects.import_project(
"file", "api-project", "api-project", "root"
)
assert project_import["import_status"] == "scheduled"


def test_import_project_with_override_params(gl, resp_import_project):
project_import = gl.projects.import_project(
"file", "api-project", override_params={"visibility": "private"}
)
assert project_import["import_status"] == "scheduled"


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


def test_import_bitbucket_server(gl, resp_import_bitbucket_server):
res = gl.projects.import_bitbucket_server(
bitbucket_server_project="project",
bitbucket_server_repo="repo",
bitbucket_server_url="url",
bitbucket_server_username="username",
personal_access_token="token",
new_name="new_name",
target_namespace="namespace",
)
assert res["id"] == 1
assert res["name"] == "project"
assert res["import_status"] == "scheduled"


def test_create_project_export(project, resp_export):
export = project.exports.create()
assert export.message == "202 Accepted"
Expand Down
Loading
0