-
Notifications
You must be signed in to change notification settings - Fork 13
feat(worker): set MERGED state on successful uploads after merge #746
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,8 +129,8 @@ def update_uploads( | |
|
|
||
| if result["successful"]: | ||
| update = { | ||
| "state_id": UploadState.PROCESSED.db_id, | ||
| "state": "processed", | ||
| "state_id": UploadState.MERGED.db_id, | ||
| "state": "merged", | ||
| } | ||
| report = reports.get(upload_id) | ||
|
Comment on lines
+132
to
135
Contributor
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. Bug: A unit test was not updated after a change in Suggested FixUpdate the assertions in the test Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews.
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. Fixed: Test assertion updated to expect state='merged' and state_id=MERGED, matching the new update_uploads behavior. |
||
| if report is not None: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import pytest | ||
|
|
||
| from database.tests.factories.core import ( | ||
| CommitFactory, | ||
| ReportFactory, | ||
| RepositoryFactory, | ||
| UploadFactory, | ||
| ) | ||
| from services.processing.merging import update_uploads | ||
| from services.processing.types import MergeResult, ProcessingResult | ||
| from shared.reports.enums import UploadState | ||
| from shared.yaml import UserYaml | ||
|
|
||
|
|
||
| @pytest.mark.django_db(databases={"default"}) | ||
| class TestUpdateUploadsState: | ||
| def test_successful_uploads_set_to_merged(self, dbsession): | ||
| repository = RepositoryFactory.create() | ||
| commit = CommitFactory.create(repository=repository) | ||
| report = ReportFactory.create(commit=commit) | ||
| upload = UploadFactory.create( | ||
| report=report, | ||
| state="started", | ||
| state_id=UploadState.UPLOADED.db_id, | ||
| ) | ||
| dbsession.add_all([repository, commit, report, upload]) | ||
| dbsession.flush() | ||
|
|
||
| processing_results: list[ProcessingResult] = [ | ||
| {"upload_id": upload.id_, "successful": True, "arguments": {}}, | ||
| ] | ||
| merge_result = MergeResult( | ||
| session_mapping={upload.id_: 0}, deleted_sessions=set() | ||
| ) | ||
|
|
||
| update_uploads(dbsession, UserYaml({}), processing_results, [], merge_result) | ||
|
|
||
| dbsession.refresh(upload) | ||
| assert upload.state_id == UploadState.MERGED.db_id | ||
| assert upload.state == "merged" | ||
|
|
||
| def test_failed_uploads_set_to_error(self, dbsession): | ||
| repository = RepositoryFactory.create() | ||
| commit = CommitFactory.create(repository=repository) | ||
| report = ReportFactory.create(commit=commit) | ||
| upload = UploadFactory.create( | ||
| report=report, | ||
| state="started", | ||
| state_id=UploadState.UPLOADED.db_id, | ||
| ) | ||
| dbsession.add_all([repository, commit, report, upload]) | ||
| dbsession.flush() | ||
|
|
||
| processing_results: list[ProcessingResult] = [ | ||
| { | ||
| "upload_id": upload.id_, | ||
| "successful": False, | ||
| "arguments": {}, | ||
| "error": {"code": "report_empty", "params": {}}, | ||
| }, | ||
| ] | ||
| merge_result = MergeResult(session_mapping={}, deleted_sessions=set()) | ||
|
|
||
| update_uploads(dbsession, UserYaml({}), processing_results, [], merge_result) | ||
|
|
||
| dbsession.refresh(upload) | ||
| assert upload.state_id == UploadState.ERROR.db_id | ||
| assert upload.state == "error" |
Uh oh!
There was an error while loading. Please reload this page.