diff --git a/tests/transform/test_dynamodb_full.py b/tests/transform/test_dynamodb_full.py index ca33738..cfac06f 100644 --- a/tests/transform/test_dynamodb_full.py +++ b/tests/transform/test_dynamodb_full.py @@ -1,7 +1,7 @@ from commons_codec.model import SQLOperation from commons_codec.transform.dynamodb import DynamoDBFullLoadTranslator -RECORD = { +RECORD_ALL_TYPES = { "id": {"S": "5F9E-Fsadd41C-4C92-A8C1-70BF3FFB9266"}, "data": {"M": {"temperature": {"N": "42.42"}, "humidity": {"N": "84.84"}}}, "meta": {"M": {"timestamp": {"S": "2024-07-12T01:17:42"}, "device": {"S": "foo"}}}, @@ -16,6 +16,22 @@ }, } +RECORD_UTM = { + "utmTags": { + "L": [ + { + "M": { + "date": {"S": "2024-08-28T20:05:42.603Z"}, + "utm_adgroup": {"L": [{"S": ""}, {"S": ""}]}, + "utm_campaign": {"S": "34374686341"}, + "utm_medium": {"S": "foobar"}, + "utm_source": {"S": "google"}, + } + } + ] + } +} + def test_sql_ddl(): assert ( @@ -24,8 +40,8 @@ def test_sql_ddl(): ) -def test_to_sql(): - assert DynamoDBFullLoadTranslator(table_name="foo").to_sql(RECORD) == SQLOperation( +def test_to_sql_all_types(): + assert DynamoDBFullLoadTranslator(table_name="foo").to_sql(RECORD_ALL_TYPES) == SQLOperation( statement='INSERT INTO "foo" (data) VALUES (:record);', parameters={ "record": { @@ -39,3 +55,22 @@ def test_to_sql(): } }, ) + + +def test_to_sql_list_of_objects(): + assert DynamoDBFullLoadTranslator(table_name="foo").to_sql(RECORD_UTM) == SQLOperation( + statement='INSERT INTO "foo" (data) VALUES (:record);', + parameters={ + "record": { + "utmTags": [ + { + "date": "2024-08-28T20:05:42.603Z", + "utm_adgroup": ["", ""], + "utm_campaign": "34374686341", + "utm_medium": "foobar", + "utm_source": "google", + } + ] + } + }, + )