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

test: update integration tests to run using Gitlab 16#2790

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 8 commits intopython-gitlab:mainfromTimKnight-DWP:update-tests
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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
3 changes: 3 additions & 0 deletionsCONTRIBUTING.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,6 +75,9 @@ You need to install ``tox`` (``pip3 install tox``) to run tests and lint checks
# run unit tests in one python environment only (useful for quick testing during development):
tox -e py311

# run unit and smoke tests in one python environment only
tox -e py312,smoke

# build the documentation - the result will be generated in build/sphinx/html/:
tox -e docs

Expand Down
7 changes: 6 additions & 1 deletiondocs/cli-examples.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,11 @@ CLI examples
CI Lint
-------

**ci-lint has been Removed in Gitlab 16, use project-ci-lint instead**

Lint a CI YAML configuration from a string:

.. note::
.. note::

To see output, you will need to use the ``-v``/``--verbose`` flag.

Expand DownExpand Up@@ -39,6 +41,9 @@ Validate a CI YAML configuration from a file (lints and exits with non-zero on f

$ gitlab ci-lint validate --content @.gitlab-ci.yml

Project CI Lint
---------------

Lint a project's CI YAML configuration:

.. code-block:: console
Expand Down
2 changes: 0 additions & 2 deletionstests/functional/api/test_boards.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@ def test_project_boards(project):
board = project.boards.get(board.id)

project.boards.delete(board.id)
assert not project.boards.list()


def test_group_boards(group):
Expand All@@ -15,4 +14,3 @@ def test_group_boards(group):
board = group.boards.get(board.id)

group.boards.delete(board.id)
assert not group.boards.list()
30 changes: 29 additions & 1 deletiontests/functional/api/test_bulk_imports.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
def test_bulk_imports(gl, group):
import time

import pytest

import gitlab


@pytest.fixture
def bulk_import_enabled(gl: gitlab.Gitlab):
settings = gl.settings.get()
bulk_import_default = settings.bulk_import_enabled

settings.bulk_import_enabled = True
settings.save()

# todo: why so fussy with feature flag timing?
time.sleep(5)
get_settings = gl.settings.get()
assert get_settings.bulk_import_enabled is True

yield settings

settings.bulk_import_enabled = bulk_import_default
settings.save()


# https://github.com/python-gitlab/python-gitlab/pull/2790#pullrequestreview-1873617123
@pytest.mark.xfail(reason="Bulk Imports to be worked on in a follow up")
def test_bulk_imports(gl, group, bulk_import_enabled):
destination = f"{group.full_path}-import"
configuration = {
"url": gl.url,
Expand Down
4 changes: 1 addition & 3 deletionstests/functional/api/test_current_user.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,6 @@ def test_current_user_email(gl):
assert mail in gl.user.emails.list()

mail.delete()
assert mail not in gl.user.emails.list()


def test_current_user_gpg_keys(gl, GPG_KEY):
Expand All@@ -14,8 +13,8 @@ def test_current_user_gpg_keys(gl, GPG_KEY):

# Seems broken on the gitlab side
gkey = gl.user.gpgkeys.get(gkey.id)

gkey.delete()
assert gkey not in gl.user.gpgkeys.list()


def test_current_user_ssh_keys(gl, SSH_KEY):
Expand All@@ -24,7 +23,6 @@ def test_current_user_ssh_keys(gl, SSH_KEY):
assert key in gl.user.keys.list()

key.delete()
assert key not in gl.user.keys.list()


def test_current_user_status(gl):
Expand Down
2 changes: 1 addition & 1 deletiontests/functional/api/test_deploy_keys.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,5 +7,5 @@ def test_project_deploy_keys(gl, project, DEPLOY_KEY):
assert deploy_key in project2.keys.list()

project2.keys.delete(deploy_key.id)
assert deploy_key not in project2.keys.list()

project2.delete()
12 changes: 6 additions & 6 deletionstests/functional/api/test_deploy_tokens.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
import datetime


def test_project_deploy_tokens(gl, project):
today = datetime.date.today().isoformat()
deploy_token = project.deploytokens.create(
{
"name": "foo",
"username": "bar",
"expires_at":"2022-01-01",
"expires_at":today,
"scopes": ["read_registry"],
}
)
Expand All@@ -12,13 +16,11 @@ def test_project_deploy_tokens(gl, project):

deploy_token = project.deploytokens.get(deploy_token.id)
assert deploy_token.name == "foo"
assert deploy_token.expires_at =="2022-01-01T00:00:00.000Z"
assert deploy_token.expires_at ==f"{today}T00:00:00.000Z"
assert deploy_token.scopes == ["read_registry"]
assert deploy_token.username == "bar"

deploy_token.delete()
assert deploy_token not in project.deploytokens.list()
assert deploy_token not in gl.deploytokens.list()


def test_group_deploy_tokens(gl, group):
Expand All@@ -37,5 +39,3 @@ def test_group_deploy_tokens(gl, group):
assert deploy_token.scopes == ["read_registry"]

deploy_token.delete()
assert deploy_token not in group.deploytokens.list()
assert deploy_token not in gl.deploytokens.list()
1 change: 0 additions & 1 deletiontests/functional/api/test_epics.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,6 @@ def test_epic_issues(epic, issue):
assert epic.issues.list()

epic_issue.delete()
assert not epic.issues.list()


def test_epic_notes(epic):
Expand Down
3 changes: 0 additions & 3 deletionstests/functional/api/test_gitlab.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,7 +53,6 @@ def test_broadcast_messages(gl, get_all_kwargs):
assert msg.color == "#444444"

msg.delete()
assert msg not in gl.broadcastmessages.list()


def test_markdown(gl):
Expand DownExpand Up@@ -151,7 +150,6 @@ def test_hooks(gl):
assert hook in gl.hooks.list()

hook.delete()
assert hook not in gl.hooks.list()


def test_namespaces(gl, get_all_kwargs):
Expand DownExpand Up@@ -202,7 +200,6 @@ def test_features(gl):
assert feat in gl.features.list()

feat.delete()
assert feat not in gl.features.list()


def test_pagination(gl, project):
Expand Down
12 changes: 4 additions & 8 deletionstests/functional/api/test_groups.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,15 +10,15 @@ def test_groups(gl):
"email": "user@test.com",
"username": "user",
"name": "user",
"password": "user_pass",
"password": "E4596f8be406Bc3a14a4ccdb1df80587#!1",
}
)
user2 = gl.users.create(
{
"email": "user2@test.com",
"username": "user2",
"name": "user2",
"password": "user2_pass",
"password": "E4596f8be406Bc3a14a4ccdb1df80587#!#2",
}
)
group1 = gl.groups.create(
Expand DownExpand Up@@ -105,8 +105,9 @@ def test_groups(gl):
assert result[0].id == user.id

group1.members.delete(user.id)
assert user not in group1.members.list()

assert group1.members_all.list()

member = group1.members.get(user2.id)
member.access_level = gitlab.const.AccessLevel.OWNER
member.save()
Expand DownExpand Up@@ -135,7 +136,6 @@ def test_group_labels(group):
assert label.name == "Label:that requires:encoding"

label.delete()
assert label not in group.labels.list()


@pytest.mark.gitlab_premium
Expand DownExpand Up@@ -194,7 +194,6 @@ def test_group_badges(group):
assert badge.image_url == "http://another.example.com"

badge.delete()
assert badge not in group.badges.list()


def test_group_milestones(group):
Expand DownExpand Up@@ -228,7 +227,6 @@ def test_group_custom_attributes(gl, group):
assert attr in group.customattributes.list()

attr.delete()
assert attr not in group.customattributes.list()


def test_group_subgroups_projects(gl, user):
Expand DownExpand Up@@ -270,7 +268,6 @@ def test_group_wiki(group):
wiki.save()

wiki.delete()
assert wiki not in group.wikis.list()


@pytest.mark.gitlab_premium
Expand All@@ -285,7 +282,6 @@ def test_group_hooks(group):
assert hook.note_events is True

hook.delete()
assert hook not in group.hooks.list()


def test_group_transfer(gl, group):
Expand Down
9 changes: 9 additions & 0 deletionstests/functional/api/test_import_export.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@
import gitlab


# https://github.com/python-gitlab/python-gitlab/pull/2790#pullrequestreview-1873617123
def test_group_import_export(gl, group, temp_dir):
export = group.exports.create()
assert export.message == "202 Accepted"
Expand All@@ -31,6 +32,8 @@ def test_group_import_export(gl, group, temp_dir):
assert group_import.name == import_name


# https://github.com/python-gitlab/python-gitlab/pull/2790#pullrequestreview-1873617123
@pytest.mark.xfail(reason="test_project_import_export to be worked on in a follow up")
def test_project_import_export(gl, project, temp_dir):
export = project.exports.create()
assert export.message == "202 Accepted"
Expand DownExpand Up@@ -68,6 +71,8 @@ def test_project_import_export(gl, project, temp_dir):
raise Exception("Project import taking too much time")


# https://github.com/python-gitlab/python-gitlab/pull/2790#pullrequestreview-1873617123
@pytest.mark.xfail(reason="test_project_remote_import to be worked on in a follow up")
def test_project_remote_import(gl):
with pytest.raises(gitlab.exceptions.GitlabImportError) as err_info:
gl.projects.remote_import(
Expand All@@ -80,6 +85,10 @@ def test_project_remote_import(gl):
)


# https://github.com/python-gitlab/python-gitlab/pull/2790#pullrequestreview-1873617123
@pytest.mark.xfail(
reason="test_project_remote_import_s3 to be worked on in a follow up"
)
def test_project_remote_import_s3(gl):
gl.features.set("import_project_from_remote_file_s3", True)
with pytest.raises(gitlab.exceptions.GitlabImportError) as err_info:
Expand Down
9 changes: 1 addition & 8 deletionstests/functional/api/test_issues.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,8 +18,6 @@ def test_create_issue(project):
assert issue in project.issues.list(state="opened")
assert issue2 in project.issues.list(state="closed")

assert isinstance(issue.user_agent_detail(), dict)
assert issue.user_agent_detail()["user_agent"]
assert issue.participants()
assert type(issue.closed_by()) == list
assert type(issue.related_merge_requests()) == list
Expand All@@ -33,10 +31,7 @@ def test_issue_notes(issue):
assert emoji in note.awardemojis.list()

emoji.delete()
assert emoji not in note.awardemojis.list()

note.delete()
assert note not in issue.notes.list()


def test_issue_labels(project, issue):
Expand All@@ -62,8 +57,8 @@ def test_issue_links(project, issue):
assert links

link_id = links[0].issue_link_id

issue.links.delete(link_id)
assert not issue.links.list()


def test_issue_label_events(issue):
Expand DownExpand Up@@ -114,5 +109,3 @@ def test_issue_discussions(issue):
assert discussion.attributes["notes"][-1]["body"] == "updated body"

d_note_from_get.delete()
discussion = issue.discussions.get(discussion.id)
assert len(discussion.attributes["notes"]) == 1
7 changes: 5 additions & 2 deletionstests/functional/api/test_lazy_objects.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
import time

import pytest

import gitlab
Expand DownExpand Up@@ -27,9 +29,10 @@ def test_save_after_lazy_get_with_path(project, lazy_project):
assert lazy_project.description == "A new description"


def test_delete_after_lazy_get_with_path(gl, group, wait_for_sidekiq):
def test_delete_after_lazy_get_with_path(gl, group):
project = gl.projects.create({"name": "lazy_project", "namespace_id": group.id})
wait_for_sidekiq(timeout=60)
# Pause to let GL catch up (happens on hosted too, sometimes takes a while for server to be ready to merge)
time.sleep(5)
lazy_project = gl.projects.get(project.path_with_namespace, lazy=True)
lazy_project.delete()

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp