-
Notifications
You must be signed in to change notification settings - Fork 2
Serialize CompletedWork flags in CompletedWorkSerializer #553
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 1 commit
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 |
---|---|---|
|
@@ -227,7 +227,12 @@ def test_delivery_progress_endpoint( | |
status=VisitValidationStatus.pending, | ||
opportunity_access=access, | ||
completed_work=completed_work, | ||
flag_reason={"flags": [("duration", "The form was completed too quickly.")]}, | ||
flag_reason={ | ||
"flags": [ | ||
["duration", "The form was completed too quickly."], | ||
["attachment_missing", "Form was submitted without attachments."], | ||
] | ||
}, | ||
) | ||
api_client.force_authenticate(mobile_user_with_connect_link) | ||
response = api_client.get(f"/api/opportunity/{opportunity.id}/delivery_progress") | ||
|
@@ -237,6 +242,10 @@ def test_delivery_progress_endpoint( | |
assert len(response.data["deliveries"]) == 1 | ||
assert len(response.data["payments"]) == 0 | ||
assert response.data["deliveries"][0].keys() == CompletedWorkSerializer().get_fields().keys() | ||
assert response.data["deliveries"][0]["flags"] == [ | ||
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. Now that I think about it, is this the expected format? Would it not make more sense to have it like this:
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. @calellowitz Actually, I'm going to update it as above. Feel free to let me know if that's not in fact what was envisioned. So now a single visit's flags will be consolidated into this one dictionary structure. See c384c9e 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. Oops yes. This is definitely what was intended. Thanks for the fix (and one more benefit of tests, making this stuff explicit). 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. Actually, shouldn't this not be a list at all. If this is always a list with a single dict, I think it can just be a dict. 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. |
||
{"duration": "The form was completed too quickly."}, | ||
{"attachment_missing": "Form was submitted without attachments."}, | ||
] | ||
|
||
Payment.objects.create(amount=10, date_paid=datetime.date.today(), opportunity_access=access) | ||
response = api_client.get(f"/api/opportunity/{opportunity.id}/delivery_progress") | ||
|
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 is a good catch. It was orginally like that because we switched serializers and wanted to ensure compatibility, but I agree that now that we are making additions, we should use the correct one. That said, I am not sure this assertion is buying us much, and would prefer the test to check expected values of keys we care about in the fields rather than just the presence of the keys.
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.
True true. I'll update!