Skip to content

fix(api): delete invalid 'project-runner get' command #1628

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
Oct 17, 2021
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
9 changes: 5 additions & 4 deletions gitlab/v4/objects/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from gitlab import types
from gitlab.base import RequiredOptional, RESTManager, RESTObject
from gitlab.mixins import (
CreateMixin,
CRUDMixin,
DeleteMixin,
ListMixin,
NoUpdateMixin,
ObjectDeleteMixin,
SaveMixin,
)
Expand Down Expand Up @@ -114,11 +115,11 @@ def verify(self, token, **kwargs):
self.gitlab.http_post(path, post_data=post_data, **kwargs)


class GroupRunner(ObjectDeleteMixin, RESTObject):
class GroupRunner(RESTObject):
pass


class GroupRunnerManager(NoUpdateMixin, RESTManager):
class GroupRunnerManager(ListMixin, RESTManager):
_path = "/groups/%(group_id)s/runners"
_obj_cls = GroupRunner
_from_parent_attrs = {"group_id": "id"}
Expand All @@ -131,7 +132,7 @@ class ProjectRunner(ObjectDeleteMixin, RESTObject):
pass


class ProjectRunnerManager(NoUpdateMixin, RESTManager):
class ProjectRunnerManager(CreateMixin, DeleteMixin, ListMixin, RESTManager):
_path = "/projects/%(project_id)s/runners"
_obj_cls = ProjectRunner
_from_parent_attrs = {"project_id": "id"}
Expand Down
15 changes: 2 additions & 13 deletions tests/unit/objects/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def resp_runner_register():
@pytest.fixture
def resp_runner_enable():
with responses.RequestsMock() as rsps:
pattern = re.compile(r".*?(projects|groups)/1/runners")
pattern = re.compile(r".*?projects/1/runners")
rsps.add(
method=responses.POST,
url=pattern,
Expand Down Expand Up @@ -176,7 +176,7 @@ def resp_runner_delete():
@pytest.fixture
def resp_runner_disable():
with responses.RequestsMock() as rsps:
pattern = re.compile(r".*?/(groups|projects)/1/runners/6")
pattern = re.compile(r".*?/projects/1/runners/6")
rsps.add(
method=responses.DELETE,
url=pattern,
Expand Down Expand Up @@ -252,24 +252,13 @@ def test_disable_project_runner(gl: gitlab.Gitlab, resp_runner_disable):
gl.projects.get(1, lazy=True).runners.delete(6)


def test_disable_group_runner(gl: gitlab.Gitlab, resp_runner_disable):
gl.groups.get(1, lazy=True).runners.delete(6)


def test_enable_project_runner(gl: gitlab.Gitlab, resp_runner_enable):
runner = gl.projects.get(1, lazy=True).runners.create({"runner_id": 6})
assert runner.active is True
assert runner.id == 6
assert runner.name == "test-name"


def test_enable_group_runner(gl: gitlab.Gitlab, resp_runner_enable):
runner = gl.groups.get(1, lazy=True).runners.create({"runner_id": 6})
assert runner.active is True
assert runner.id == 6
assert runner.name == "test-name"


def test_verify_runner(gl: gitlab.Gitlab, resp_runner_verify):
gl.runners.verify("token")

Expand Down