generated from cfpb/open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed upsert function in favor of just add (since we don't need spe…
…cific update functions as validation processing can directly update the attached DAO), and simplified pytests to remove the upsert functions
- Loading branch information
Showing
2 changed files
with
21 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -89,7 +89,7 @@ async def test_get_submissions(self, query_session: AsyncSession): | |
assert {SubmissionState.SUBMISSION_UPLOADED} == set([s.state for s in res]) | ||
|
||
async def test_add_submission(self, transaction_session: AsyncSession): | ||
res = await repo.upsert_submission(transaction_session, SubmissionDTO(submitter="[email protected]", filing=1)) | ||
res = await repo.add_submission(transaction_session, SubmissionDTO(submitter="[email protected]", filing=1)) | ||
assert res.submission_id == 4 | ||
assert res.submitter == "[email protected]" | ||
assert res.filing == 1 | ||
|
@@ -99,50 +99,29 @@ async def test_add_submission(self, transaction_session: AsyncSession): | |
# This tests directly updating the attached DAO in a session. Since | ||
# once we add a Submission we'll have reference to that attached object, | ||
# validation should be able to directly update the DAO state and validation | ||
# json without having to call repo.upsert | ||
async def test_update_submission(self, query_session: AsyncSession): | ||
res = await repo.get_submission(query_session, submission_id=1) | ||
# json without having to call updates on the object | ||
async def test_update_submission(self, transaction_session: AsyncSession): | ||
res = await repo.add_submission(transaction_session, SubmissionDTO(submitter="[email protected]", filing=2)) | ||
res.state = SubmissionState.VALIDATION_IN_PROGRESS | ||
|
||
stmt = select(SubmissionDAO).filter(SubmissionDAO.submission_id == 1) | ||
new_res1 = await query_session.scalar(stmt) | ||
assert new_res1.submission_id == 1 | ||
assert new_res1.filing == 1 | ||
stmt = select(SubmissionDAO).filter(SubmissionDAO.submission_id == 4) | ||
new_res1 = await transaction_session.scalar(stmt) | ||
assert new_res1.submission_id == 4 | ||
assert new_res1.filing == 2 | ||
assert new_res1.state == SubmissionState.VALIDATION_IN_PROGRESS | ||
|
||
validation_json = self.get_error_json() | ||
res.validation_json = validation_json | ||
res.state = SubmissionState.VALIDATION_WITH_ERRORS | ||
|
||
stmt = select(SubmissionDAO).filter(SubmissionDAO.submission_id == 1) | ||
new_res2 = await query_session.scalar(stmt) | ||
assert new_res2.submission_id == 1 | ||
stmt = select(SubmissionDAO).filter(SubmissionDAO.submission_id == 4) | ||
new_res2 = await transaction_session.scalar(stmt) | ||
|
||
assert new_res2.submission_id == 4 | ||
assert new_res2.filing == 1 | ||
assert new_res2.state == SubmissionState.VALIDATION_WITH_ERRORS | ||
assert new_res2.validation_json == validation_json | ||
|
||
# This tests the upsert merge function instead of directly updating | ||
# the attached DAO in the session. This is in case it's preferred to | ||
# call upsert on each DAO update. Depends on if the plan is to pass around | ||
# the session or get a new one on each update. | ||
async def test_upsert_submission(self, transaction_session: AsyncSession): | ||
updated_sub = SubmissionDAO( | ||
submission_id=1, | ||
validation_json={}, | ||
submitter="[email protected]", | ||
filing=1, | ||
state=SubmissionState.SUBMISSION_SIGNED, | ||
validation_ruleset_version="v1", | ||
) | ||
await repo.upsert_submission(transaction_session, updated_sub) | ||
|
||
stmt = select(SubmissionDAO).filter(SubmissionDAO.submission_id == 1) | ||
new_res2 = await transaction_session.scalar(stmt) | ||
assert new_res2.submission_id == 1 | ||
assert new_res2.filing == 1 | ||
assert new_res2.state == SubmissionState.SUBMISSION_SIGNED | ||
assert new_res2.validation_json == {} | ||
|
||
def get_error_json(self): | ||
df_columns = [ | ||
"record_no", | ||
|