-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from MITLibraries/TIMX-441-v2-transform-command
TIMX 441 - support v2 transform command
- Loading branch information
Showing
6 changed files
with
133 additions
and
16 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
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# ruff: noqa: FBT003 | ||
|
||
from lambdas import commands | ||
|
||
# NOTE: FEATURE FLAG: this file can be FULLY removed after v2 work is complete | ||
|
||
|
||
def test_generate_transform_commands_required_input_fields(run_id): | ||
input_data = { | ||
"next-step": "transform", | ||
"run-date": "2022-01-02T12:13:14Z", | ||
"run-type": "full", | ||
"source": "testsource", | ||
} | ||
extract_output_files = [ | ||
"testsource/testsource-2022-01-02-full-extracted-records-to-index.xml" | ||
] | ||
assert commands.generate_transform_commands( | ||
extract_output_files, input_data, "2022-01-02", "test-timdex-bucket", run_id | ||
) == { | ||
"files-to-transform": [ | ||
{ | ||
"transform-command": [ | ||
"--input-file=s3://test-timdex-bucket/testsource/" | ||
"testsource-2022-01-02-full-extracted-records-to-index.xml", | ||
"--output-file=s3://test-timdex-bucket/testsource/" | ||
"testsource-2022-01-02-full-transformed-records-to-index.json", | ||
"--source=testsource", | ||
] | ||
} | ||
] | ||
} | ||
|
||
|
||
def test_generate_transform_commands_all_input_fields(run_id): | ||
input_data = { | ||
"next-step": "transform", | ||
"run-date": "2022-01-02T12:13:14Z", | ||
"run-type": "daily", | ||
"source": "testsource", | ||
} | ||
extract_output_files = [ | ||
"testsource/testsource-2022-01-02-daily-extracted-records-to-index_01.xml", | ||
"testsource/testsource-2022-01-02-daily-extracted-records-to-index_02.xml", | ||
"testsource/testsource-2022-01-02-daily-extracted-records-to-delete.xml", | ||
] | ||
assert commands.generate_transform_commands( | ||
extract_output_files, input_data, "2022-01-02", "test-timdex-bucket", run_id | ||
) == { | ||
"files-to-transform": [ | ||
{ | ||
"transform-command": [ | ||
"--input-file=s3://test-timdex-bucket/testsource/" | ||
"testsource-2022-01-02-daily-extracted-records-to-index_01.xml", | ||
"--output-file=s3://test-timdex-bucket/testsource/" | ||
"testsource-2022-01-02-daily-transformed-records-to-index_01.json", | ||
"--source=testsource", | ||
] | ||
}, | ||
{ | ||
"transform-command": [ | ||
"--input-file=s3://test-timdex-bucket/testsource/" | ||
"testsource-2022-01-02-daily-extracted-records-to-index_02.xml", | ||
"--output-file=s3://test-timdex-bucket/testsource/" | ||
"testsource-2022-01-02-daily-transformed-records-to-index_02.json", | ||
"--source=testsource", | ||
] | ||
}, | ||
{ | ||
"transform-command": [ | ||
"--input-file=s3://test-timdex-bucket/testsource/" | ||
"testsource-2022-01-02-daily-extracted-records-to-delete.xml", | ||
"--output-file=s3://test-timdex-bucket/testsource/" | ||
"testsource-2022-01-02-daily-transformed-records-to-delete.txt", | ||
"--source=testsource", | ||
] | ||
}, | ||
] | ||
} |