Skip to content

Commit 8ab6fff

Browse files
committed
Add test for run-timestamp not provided as event arg
1 parent 2c1b76b commit 8ab6fff

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/test_format_input.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,52 @@ def test_lambda_handler_with_next_step_transform_alma_files_present(run_timestam
125125
}
126126

127127

128+
def test_lambda_handler_with_next_step_transform_auto_generated_timestamp(s3_client):
129+
s3_client.put_object(
130+
Bucket="test-timdex-bucket",
131+
Key="testsource/testsource-2022-01-02-daily-extracted-records-to-index.xml",
132+
Body="I am a file",
133+
)
134+
event = {
135+
"run-date": "2022-01-02T12:13:14Z",
136+
"run-type": "daily",
137+
"next-step": "transform",
138+
"source": "testsource",
139+
"run-id": "run-abc-123",
140+
"verbose": "true",
141+
}
142+
143+
with patch("lambdas.format_input.datetime") as mock_datetime:
144+
mock_datetime.now.return_value.isoformat.return_value = (
145+
"2025-06-18T12:34:56.789000"
146+
)
147+
mock_datetime.UTC = format_input.datetime.UTC
148+
149+
result = format_input.lambda_handler(event, {})
150+
151+
assert result == {
152+
"run-date": "2022-01-02",
153+
"run-type": "daily",
154+
"source": "testsource",
155+
"verbose": True,
156+
"next-step": "load",
157+
"transform": {
158+
"files-to-transform": [
159+
{
160+
"transform-command": [
161+
"--input-file=s3://test-timdex-bucket/testsource/"
162+
"testsource-2022-01-02-daily-extracted-records-to-index.xml",
163+
"--output-location=s3://test-timdex-bucket/dataset",
164+
"--source=testsource",
165+
"--run-id=run-abc-123",
166+
"--run-timestamp=2025-06-18T12:34:56.789000",
167+
]
168+
}
169+
]
170+
},
171+
}
172+
173+
128174
def test_lambda_handler_with_next_step_transform_no_files_present_alma():
129175
event = {
130176
"run-date": "2022-01-02",

0 commit comments

Comments
 (0)