Skip to content

Commit

Permalink
test(projects): add unit tests for projects
Browse files Browse the repository at this point in the history
  • Loading branch information
antoineauger committed Jun 16, 2022
1 parent ca98d88 commit 67942f0
Show file tree
Hide file tree
Showing 3 changed files with 537 additions and 100 deletions.
5 changes: 5 additions & 0 deletions tests/unit/conftest.py
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
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

0 comments on commit 67942f0

Please sign in to comment.