Skip to content

feat(api): add group hooks #1533

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 2 commits into from
Jun 27, 2021
Merged

feat(api): add group hooks #1533

merged 2 commits into from
Jun 27, 2021

Conversation

sugonyak
Copy link
Contributor

@sugonyak sugonyak commented Jun 25, 2021

Resolves #1496

@sugonyak
Copy link
Contributor Author

sugonyak commented Jun 25, 2021

Got a few questions:

  • Not quite sure if I should change something in CLI part, could someone advise?
  • Also, tried to use pre-commit checks and mypy gives me a lot of errors in files not affected by my changes, is it normal?
  • I see that tests for project hooks are not implemented, should I implement some for group hooks?

@codecov-commenter
Copy link

codecov-commenter commented Jun 25, 2021

Codecov Report

Merging #1533 (953f207) into master (af7aae7) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1533      +/-   ##
==========================================
+ Coverage   91.13%   91.15%   +0.02%     
==========================================
  Files          74       74              
  Lines        4162     4172      +10     
==========================================
+ Hits         3793     3803      +10     
  Misses        369      369              
Flag Coverage Δ
cli_func_v4 80.77% <100.00%> (+0.04%) ⬆️
py_func_v4 80.08% <100.00%> (+0.04%) ⬆️
unit 82.33% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
gitlab/v4/objects/groups.py 83.83% <100.00%> (+0.16%) ⬆️
gitlab/v4/objects/hooks.py 100.00% <100.00%> (ø)
gitlab/v4/objects/releases.py 100.00% <0.00%> (ø)
gitlab/v4/objects/merge_requests.py 83.92% <0.00%> (ø)

Copy link
Member

@nejch nejch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @sugonyak! Looks good. Just a few comments and to answer your questions:

Not quite sure if I should change something in CLI part, could someone advise?

Since you only use standard methods, the CLI part should be auto-generated including docs and nothing extra is needed here.

Also, tried to use pre-commit checks and mypy gives me a lot of errors in files not affected by my changes, is it normal?

Sorry about that, looks like the mypy pre-commit does not respect the file list from mypy's config, I need to check. If tox -e mypy is happy then for now just bypass it, I'll try to fix it asap.

I see that tests for project hooks are not implemented, should I implement some for group hooks?

I've suggested factoring them out into a common file, then it should be easier to add tests and maybe reuse fixtures. But even if you just add group tests that's fine, just maybe really put them into test_hooks.py for easier reuse. Thanks!

Comment on lines 156 to 180


@pytest.mark.skip(reason="missing test")
def test_list_group_hooks(gl):
pass


@pytest.mark.skip(reason="missing test")
def test_get_group_hook(gl):
pass


@pytest.mark.skip(reason="missing test")
def test_create_group_hook(gl):
pass


@pytest.mark.skip(reason="missing test")
def test_update_group_hook(gl):
pass


@pytest.mark.skip(reason="missing test")
def test_delete_group_hook(gl):
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could factor this (and project hooks from test_projects.py) out into tests/unit/objects/test_hooks.py and they could share most of the fixture/setup?

See for example the issues statistics test that shares between project/group/instance endpoints:
https://github.com/python-gitlab/python-gitlab/blob/master/tests/unit/objects/test_issues.py#L44-L58

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, seems like a good idea.

@sugonyak sugonyak marked this pull request as ready for review June 25, 2021 23:02
@sugonyak sugonyak changed the title [WIP] feat(api): Add group hooks feat(api): Add group hooks Jun 25, 2021
@sugonyak sugonyak changed the title feat(api): Add group hooks feat(api): add group hooks Jun 25, 2021
Copy link
Member

@nejch nejch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for adding all the unit tests even for other endpoints.

We'll just need to skip the functional test for now unfortunately as we only run them against the gitlab-ce container in CI.

@nejch nejch merged commit 6abf13a into python-gitlab:master Jun 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Group Hooks API not supported
3 participants