-
Notifications
You must be signed in to change notification settings - Fork 0
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
Persist submitting user metadata #563
Conversation
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 functionality is going to require a unit test in which a mocked json containing this metadata from the frontend hits the /ingest endpoint.
At the very least, save_submission_file_name_and_user_metadata
is going to require a unit test.
db/migrations/versions/2024_05_01_1700-4a0c70f02342_added_submitting_account_id_submitting_.py
Outdated
Show resolved
Hide resolved
b9b0d10
to
baba43a
Compare
Unit test has been added to make sure that new field values are saved to submission model from submission json. |
97576b6
to
92c416f
Compare
submitting_account_id = sqla.Column(sqla.String()) | ||
submitting_user_email = sqla.Column(sqla.String()) |
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.
We may want to think about whether we can backfill these columns and make them non-nullable in the future. Could you make a ticket for this and put it in the refinement bucket of one of the boards please (probably submit's board)? :)
60bf6d7
to
d924fc0
Compare
6c9a4d8
to
2d4f0c7
Compare
) | ||
|
||
# Check that submitting_account_id and submitting_user_email are saved on the Submission | ||
sub = Submission.query.filter_by(submission_id="S-PF-R01-1").first() |
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.
consider changing first() to one() - it's better practice as:
- If you are only expecting one row, one() explicitly gets this, or throws an error.
- If something changes in the future and there ends up being more than one row returned by that query (due to test fixture leakage, or badly defined test setup, or some regressive code change) then first() may give arbitrary, difficult to debug error messages, whereas one() will explicitly say it only expects one result
|
||
assert response.status_code == 200, f"{response.json}" | ||
|
||
sub = Submission.query.filter_by(submission_id="S-PF-R01-1").first() |
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.
as per other comment, switch to use one()
099aac2
to
bde4b12
Compare
assert sub.submitting_user_email == "testuser@levellingup.gov.uk" | ||
|
||
|
||
def test_save_submission_file_name_and_user_metadata(): |
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 needs to use a test fixture that resets the changes, made within the test, otherwise there's a big risk of the data leaking into another test (probably in a separate module, or if someone extends this one). I think in this case the changes are not committed to the DB (from what I can tell by quickly reading it) so the appropriate fixture is probably seeded_test_client_rollback
9e6d9ee
to
4238299
Compare
4238299
to
88f949a
Compare
Ticket:
https://dluhcdigital.atlassian.net/browse/FMD-251
Description:
Adds two new fields to Submission model in data-store.
Saves submitting user's account_id and email to these fields passed in from post-award-submit.
PR for this:
communitiesuk/funding-service-design-post-award-submit#160
Test:
Tested locally and in dev environment.