Skip to content

Commit

Permalink
Merge branch '0_7_17' into docme
Browse files Browse the repository at this point in the history
  • Loading branch information
ngr committed Jul 22, 2019
2 parents 80d6b76 + b94bb92 commit 2d41f98
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions sosw/components/test/unit/test_dynamo_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class dynamodb_client_UnitTestCase(unittest.TestCase):
'some_counter': 'N',
'some_bool': 'BOOL',
'some_bool2': 'BOOL',
'some_map': 'M'
'some_map': 'M',
'some_list': 'L'
},
'required_fields': ['lambda_name'],
'table_name': 'autotest_dynamo_db'
Expand Down Expand Up @@ -58,23 +59,25 @@ def tearDown(self):

def test_dict_to_dynamo_strict(self):
dict_row = {'lambda_name': 'test_name', 'invocation_id': 'test_id', 'en_time': 123456, 'some_bool': True,
'some_bool2': 'True', 'some_map': {'a': 1, 'b': 'b1', 'c': {'test': True}}}
'some_bool2': 'True', 'some_map': {'a': 1, 'b': 'b1', 'c': {'test': True}}, 'some_list': ['x', 'y']}
dynamo_row = self.dynamo_client.dict_to_dynamo(dict_row)
expected = {
'lambda_name': {'S': 'test_name'}, 'invocation_id': {'S': 'test_id'}, 'en_time': {'N': '123456'},
'some_bool': {'BOOL': True}, 'some_bool2': {'BOOL': True},
'some_map': {'M': {'a': {'N': '1'}, 'b': {'S': 'b1'}, 'c': {'M': {'test': {'BOOL': True}}}}}
'some_map': {'M': {'a': {'N': '1'}, 'b': {'S': 'b1'}, 'c': {'M': {'test': {'BOOL': True}}}}},
'some_list': {'L': [{'S': 'x'}, {'S': 'y'}]}
}
for key in expected.keys():
self.assertDictEqual(expected[key], dynamo_row[key])


def test_dict_to_dynamo_not_strict(self):
dict_row = {'name': 'cat', 'age': 3, 'other_bool': False, 'other_bool2': 'False',
'other_map': {'a': 1, 'b': 'b1', 'c': {'test': True}}}
'other_map': {'a': 1, 'b': 'b1', 'c': {'test': True}}, 'some_list': ['x', 'y']}
dynamo_row = self.dynamo_client.dict_to_dynamo(dict_row, strict=False)
expected = {'name': {'S': 'cat'}, 'age': {'N': '3'}, 'other_bool': {'BOOL': False},
'other_map': {'M': {'a': {'N': '1'}, 'b': {'S': 'b1'}, 'c': {'M': {'test': {'BOOL': True}}}}}}
'other_map': {'M': {'a': {'N': '1'}, 'b': {'S': 'b1'}, 'c': {'M': {'test': {'BOOL': True}}}}},
'some_list': {'L': [{'S': 'x'}, {'S': 'y'}]}}
for key in expected.keys():
self.assertDictEqual(expected[key], dynamo_row[key])

Expand All @@ -91,11 +94,12 @@ def test_dynamo_to_dict(self):
dynamo_row = {
'lambda_name': {'S': 'test_name'}, 'invocation_id': {'S': 'test_id'}, 'en_time': {'N': '123456'},
'extra_key': {'N': '42'}, 'some_bool': {'BOOL': False},
'some_map': {'M': {'a': {'N': '1'}, 'b': {'S': 'b1'}, 'c': {'M': {'test': {'BOOL': True}}}}}
'some_map': {'M': {'a': {'N': '1'}, 'b': {'S': 'b1'}, 'c': {'M': {'test': {'BOOL': True}}}}},
'some_list': {'L': [{'S': 'x'}, {'S': 'y'}]}
}
dict_row = self.dynamo_client.dynamo_to_dict(dynamo_row)
expected = {'lambda_name': 'test_name', 'invocation_id': 'test_id', 'en_time': 123456, 'some_bool': False,
'some_map': {'a': 1, 'b': 'b1', 'c': {'test': True}}}
'some_map': {'a': 1, 'b': 'b1', 'c': {'test': True}}, 'some_list': ['x', 'y']}
self.assertDictEqual(expected, dict_row)


Expand Down

0 comments on commit 2d41f98

Please sign in to comment.