Skip to content

Commit

Permalink
DynamoDB: Compress transformation tests into single one. Naming things.
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Sep 1, 2024
1 parent 4ca7b87 commit d5a6432
Showing 1 changed file with 25 additions and 39 deletions.
64 changes: 25 additions & 39 deletions tests/transform/test_dynamodb_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,7 @@
"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"}}},
"string_set": {"SS": ["location_1"]},
"number_set": {"NS": [1, 2, 3, 0.34]},
"binary_set": {"BS": ["U3Vubnk="]},
"somemap": {
"M": {
"test": {"N": 1},
"test2": {"N": 2},
}
},
"list_varied": {"L": [{"M": {"a": {"N": 1}}}, {"N": 2}, {"S": "Three"}]},
}

RECORD_UTM = {
"utmTags": {
"list_of_objects": {
"L": [
{
"M": {
Expand All @@ -30,7 +17,17 @@
}
}
]
}
},
"list_of_varied": {"L": [{"M": {"a": {"N": 1}}}, {"N": 2}, {"S": "Three"}]},
"map_of_numbers": {
"M": {
"test": {"N": 1},
"test2": {"N": 2},
}
},
"set_of_binaries": {"BS": ["U3Vubnk="]},
"set_of_numbers": {"NS": [1, 2, 3, 0.34]},
"set_of_strings": {"SS": ["location_1"]},
}


Expand All @@ -49,37 +46,26 @@ def test_to_sql_all_types():
"id": "5F9E-Fsadd41C-4C92-A8C1-70BF3FFB9266",
"data": {"temperature": 42.42, "humidity": 84.84},
"meta": {"timestamp": "2024-07-12T01:17:42", "device": "foo"},
"string_set": ["location_1"],
"number_set": [0.34, 1.0, 2.0, 3.0],
"binary_set": ["U3Vubnk="],
"somemap": {"test": 1.0, "test2": 2.0},
},
"untyped": {
"list_varied": [
{"a": 1.0},
2.0,
"Three",
],
},
},
)


def test_to_sql_list_of_objects():
assert DynamoDBFullLoadTranslator(table_name="foo").to_sql(RECORD_UTM) == SQLOperation(
statement="INSERT INTO foo (data, aux) VALUES (:typed, :untyped);",
parameters={
"typed": {
"utmTags": [
"list_of_objects": [
{
"date": "2024-08-28T20:05:42.603Z",
"utm_adgroup": ["", ""],
"utm_campaign": "34374686341",
"utm_medium": "foobar",
"utm_source": "google",
}
]
],
"map_of_numbers": {"test": 1.0, "test2": 2.0},
"set_of_binaries": ["U3Vubnk="],
"set_of_numbers": [0.34, 1.0, 2.0, 3.0],
"set_of_strings": ["location_1"],
},
"untyped": {
"list_of_varied": [
{"a": 1.0},
2.0,
"Three",
],
},
"untyped": {},
},
)

0 comments on commit d5a6432

Please sign in to comment.