-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Send upload size to upload request and cli version with API req… #121
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
Open
calvin-codecov
wants to merge
2
commits into
main
Choose a base branch
from
cy/more_metrics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,19 +52,51 @@ | |
| "ci_service": "ci_service", | ||
| "git_service": "github", | ||
| } | ||
|
|
||
|
|
||
| def _upload_ingest_post_json_base(*, file_not_found: bool) -> dict: | ||
| return { | ||
| "ci_service": "ci_service", | ||
| "ci_url": "build_url", | ||
| "cli_args": None, | ||
| "env": {}, | ||
| "flags": "flags", | ||
| "job_code": "job_code", | ||
| "name": "name", | ||
| "version": codecov_cli_version, | ||
| "file_not_found": file_not_found, | ||
| } | ||
|
|
||
|
|
||
| _report_payload_bytes_coverage = len( | ||
| UploadSender()._generate_payload( | ||
| upload_collection, {}, ReportType.COVERAGE | ||
| ) | ||
| ) | ||
|
|
||
| request_data = { | ||
| "ci_service": "ci_service", | ||
| "ci_url": "build_url", | ||
| "cli_args": None, | ||
| "env": {}, | ||
| "flags": "flags", | ||
| "job_code": "job_code", | ||
| "name": "name", | ||
| "version": codecov_cli_version, | ||
| "file_not_found": False, | ||
| **_upload_ingest_post_json_base(file_not_found=False), | ||
| "report_payload_bytes": _report_payload_bytes_coverage, | ||
| } | ||
|
|
||
|
|
||
| def _test_results_ingest_post_json( | ||
| upload_data: UploadCollectionResult, *, file_not_found: bool | ||
| ) -> dict: | ||
| return { | ||
| **_upload_ingest_post_json_base(file_not_found=file_not_found), | ||
| "slug": encode_slug("org/repo"), | ||
| "branch": "branch", | ||
| "commit": random_sha, | ||
| "service": "github", | ||
| "report_payload_bytes": len( | ||
| UploadSender()._generate_payload( | ||
| upload_data, {}, ReportType.TEST_RESULTS | ||
| ) | ||
| ), | ||
| } | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mocked_responses(): | ||
| with responses.RequestsMock() as rsps: | ||
|
|
@@ -266,18 +298,22 @@ def test_upload_sender_post_called_with_right_parameters_test_results( | |
| ): | ||
| headers = {"Authorization": f"token {random_token}"} | ||
|
|
||
| mocked_legacy_upload_endpoint.match = [ | ||
| matchers.json_params_matcher(request_data), | ||
| matchers.header_matcher(headers), | ||
| ] | ||
|
Comment on lines
-269
to
-272
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like it was incorrectly using the mocked_legacy_upload_endpoint even though this is a different endpoint. I think we want the mocked_test_results_endpoint (newly added below) which would match with the argument at line 295 and with the url designated in this function |
||
|
|
||
| ta_upload_collection = deepcopy(upload_collection) | ||
|
|
||
| test_path = tmp_path / "test_results.xml" | ||
| test_path.write_bytes(b"test_data") | ||
|
|
||
| ta_upload_collection.files = [UploadCollectionResultFile(test_path)] | ||
|
|
||
| mocked_test_results_endpoint.match = [ | ||
| matchers.json_params_matcher( | ||
| _test_results_ingest_post_json( | ||
| ta_upload_collection, file_not_found=False | ||
| ) | ||
| ), | ||
| matchers.header_matcher(headers), | ||
| ] | ||
|
|
||
| sending_result = UploadSender().send_upload_data( | ||
| ta_upload_collection, | ||
| random_sha, | ||
|
|
@@ -309,10 +345,11 @@ def test_upload_sender_post_called_with_right_parameters_test_results_file_not_f | |
| ): | ||
| headers = {"Authorization": f"token {random_token}"} | ||
|
|
||
| req_data = deepcopy(request_data) | ||
| req_data["file_not_found"] = True | ||
| req_data = _test_results_ingest_post_json( | ||
| upload_collection, file_not_found=True | ||
| ) | ||
|
|
||
| mocked_legacy_upload_endpoint.match = [ | ||
| mocked_test_results_endpoint_file_not_found.match = [ | ||
| matchers.json_params_matcher(req_data), | ||
| matchers.header_matcher(headers), | ||
| ] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed like a missed line from before. We weren't passing in the
file_not_foundvalue that is defined higher up at line 59/61 andself.get_url_and_possibly_update_data()takes it in with a default value of "False" so it would always just set `data['file_not_found'] to FalseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review this in particular ^