Skip to content
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

👌 Improve and test github needservice directive #1113

Merged
merged 3 commits into from
Feb 16, 2024
Merged

Conversation

chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Feb 16, 2024

By codecov, this directive was completely untested in the current test suite, so I added a test and also improved some other things I noticed:

  • remove duplication of request mocking solutions in the test-suite (responses is more popular than requests-mock)
  • remove superfluous requests mocking in basic docs tests (that do not make any requests)
  • add test for github needservice directives
  • replace raisingNeedGithubServiceException with emitting needs.github warnings
  • pass the directive to the service.request method (in a non-breaking manner) so that it can be used to add the directive source location to the warnings
  • Replace remaining tests that used Sphinx with SphinxTestApp, which can be "cleaned" after running (otherwise later test were emitting warnings caused by global variables previously mutated by these earlier tests)

- remove duplication of request mocking solutions (responses is more popular than requests-mock)
- remove superfluous mocking in basic docs tests
- add test for github `needservice` directives
- replace raising`NeedGithubServiceException` with emitting `needs.github` warnings
- pass the directive to the service (in a non-breaking manner) so that it can be used to add the directive source location to the warnings
- Replace remaining tests that used `Sphinx` with `SphinxTestApp`, which can be "cleaned" after running (otherwise later test were emitting warnings due to these earlier tests)
@chrisjsewell chrisjsewell requested a review from danwos February 16, 2024 01:21
Copy link

codecov bot commented Feb 16, 2024

Codecov Report

Attention: 13 lines in your changes are missing coverage. Please review.

Comparison is base (84a5f72) 83.93% compared to head (dacae85) 85.81%.

Files Patch % Lines
sphinx_needs/services/github.py 69.76% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1113      +/-   ##
==========================================
+ Coverage   83.93%   85.81%   +1.88%     
==========================================
  Files          56       56              
  Lines        6462     6480      +18     
==========================================
+ Hits         5424     5561     +137     
+ Misses       1038      919     -119     
Flag Coverage Δ
pytests 85.81% <75.92%> (+1.88%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pytest.mark.parametrize(
"test_app", [{"buildername": "html", "srcdir": "doc_test/doc_basic"}], indirect=True
)
def test_build_html(test_app):
responses.add_callback(
Copy link
Member

Choose a reason for hiding this comment

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

Does removing this mean, our tests are firing now real requests to the GitHub API.
Or have I missed the locations, where this is still mocked?

Copy link
Member Author

@chrisjsewell chrisjsewell Feb 16, 2024

Choose a reason for hiding this comment

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

doc_test/doc_basic has no needservice directives in, i.e. there are no requests to make 😄

Copy link
Member

Choose a reason for hiding this comment

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

argh sure, thought these removals had some functional reason.
But now it makes all sense...

@chrisjsewell chrisjsewell requested a review from danwos February 16, 2024 11:44
@chrisjsewell chrisjsewell merged commit 9a626fa into master Feb 16, 2024
18 checks passed
@chrisjsewell chrisjsewell deleted the test-github branch February 16, 2024 12:34
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.

2 participants