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.
- Loading branch information
Showing
5 changed files
with
84 additions
and
53 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
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
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 |
---|---|---|
|
@@ -3,11 +3,7 @@ | |
from sqlalchemy.ext.asyncio import AsyncSession, AsyncEngine | ||
from sqlalchemy import select, func | ||
|
||
from entities.models import ( | ||
SubmissionDAO, | ||
ValidationResultDAO, | ||
RecordDAO | ||
) | ||
from entities.models import SubmissionDAO, ValidationResultDAO, RecordDAO | ||
from entities.repos import submission_repo as repo | ||
|
||
|
||
|
@@ -17,13 +13,11 @@ async def setup( | |
self, | ||
transaction_session: AsyncSession, | ||
): | ||
submission = SubmissionDAO(submission_id="12345", | ||
submitter="[email protected]", | ||
lei="1234567890ABCDEFGHIJ") | ||
submission = SubmissionDAO(submission_id="12345", submitter="[email protected]", lei="1234567890ABCDEFGHIJ") | ||
results = [] | ||
result1 = ValidationResultDAO(validation_id="E0123", field_name="uid", severity="error") | ||
records = [] | ||
record1a = RecordDAO(record=1,data="empty") | ||
record1a = RecordDAO(record=1, data="empty") | ||
records.append(record1a) | ||
result1.records = records | ||
results.append(result1) | ||
|
@@ -41,22 +35,61 @@ async def test_get_submission(self, query_session: AsyncSession): | |
assert len(res.results[0].records) == 1 | ||
assert res.results[0].validation_id == "E0123" | ||
assert res.results[0].records[0].data == "empty" | ||
|
||
async def test_add_submission(self, transaction_session: AsyncSession): | ||
df_columns = ["record_no", "field_name", "field_value", "validation_severity", "validation_id", "validation_name", "validation_desc"] | ||
df_data = [[0, "uid", "BADUID0", "error", "E0001", "id.invalid_text_length", "'Unique identifier' must be at least 21 characters in length."], | ||
[0, "uid", "BADTEXTLENGTH", "error", "E0100", "ct_credit_product_ff.invalid_text_length", "'Free-form text field for other credit products' must not exceed 300 characters in length."], | ||
[1, "uid", "BADUID1", "error", "E0001", "id.invalid_text_length", "'Unique identifier' must be at least 21 characters in length."]] | ||
df_columns = [ | ||
"record_no", | ||
"field_name", | ||
"field_value", | ||
"validation_severity", | ||
"validation_id", | ||
"validation_name", | ||
"validation_desc", | ||
] | ||
df_data = [ | ||
[ | ||
0, | ||
"uid", | ||
"BADUID0", | ||
"error", | ||
"E0001", | ||
"id.invalid_text_length", | ||
"'Unique identifier' must be at least 21 characters in length.", | ||
], | ||
[ | ||
0, | ||
"uid", | ||
"BADTEXTLENGTH", | ||
"error", | ||
"E0100", | ||
"ct_credit_product_ff.invalid_text_length", | ||
"'Free-form text field for other credit products' must not exceed 300 characters in length.", | ||
], | ||
[ | ||
1, | ||
"uid", | ||
"BADUID1", | ||
"error", | ||
"E0001", | ||
"id.invalid_text_length", | ||
"'Unique identifier' must be at least 21 characters in length.", | ||
], | ||
] | ||
error_df = pd.DataFrame(df_data, columns=df_columns) | ||
print(f"Data Frame: {error_df}") | ||
res = await repo.add_submission(transaction_session, submission_id="12346", submitter="[email protected]", lei="1234567890ABCDEFGHIJ", results=error_df) | ||
res = await repo.add_submission( | ||
transaction_session, | ||
submission_id="12346", | ||
submitter="[email protected]", | ||
lei="1234567890ABCDEFGHIJ", | ||
results=error_df, | ||
) | ||
assert res.submission_id == "12346" | ||
assert res.submitter == "[email protected]" | ||
assert res.lei == "1234567890ABCDEFGHIJ" | ||
assert len(res.results) == 2 # Two error codes, 3 records total | ||
assert len(res.results) == 2 # Two error codes, 3 records total | ||
assert len(res.results[0].records) == 2 | ||
assert len(res.results[1].records) == 1 | ||
assert res.results[0].validation_id == "E0001" | ||
assert res.results[1].validation_id == "E0100" | ||
assert res.results[0].records[0].data == "BADUID0" | ||
|