Commit 25546930 authored by Manuel's avatar Manuel

extended unittest and fixed UniqueID issue

bugifx: an exception was thrown when an int is passed as a UniqueID field -> now converted to string
parent b4d3f717
......@@ -90,6 +90,10 @@ class MessageHandler:
transaction - Required: dictionary, that is arbitrarily deep nested
mappings - Required: contains string->path mappings, describing how the flattened object is built
'''
print("TRANSACTION: "+str(transaction))
print("MAPPINGS: "+str(mappings))
flattened = {}
# iterate over schema mappings and resolve paths
......@@ -111,7 +115,7 @@ class MessageHandler:
flattened[mapping] = final_value
flattened["UniqueID"] = hashlib.sha256(flattened["UniqueID"].encode("utf-8")).hexdigest()
flattened["UniqueID"] = hashlib.sha256(str(flattened["UniqueID"]).encode("utf-8")).hexdigest()
return flattened
......
......@@ -48,6 +48,22 @@ class Test_MessageHandler(unittest.TestCase):
}
return json.dumps(message_values)
def _get_order_message(self) -> str:
message_values = \
{
'type': 'blockchain-transaction',
'content':
{
"ApplicationType": "debug",
"docType": "order",
"orderId": 1,
"pizza": 1,
"price": 12.0,
"restaurant": 1,
}
}
return json.dumps(message_values)
def _get_pizza_message(self) -> str:
message_values = \
{
......@@ -56,21 +72,27 @@ class Test_MessageHandler(unittest.TestCase):
{
"ApplicationType": "debug",
"docType": "pizza",
"name": "Margherita",
"id": 1,
"name": "Diavolo",
"dough": {
"type": "wheat",
"cheese": False,
"spinach": False
},
"sauces": [
"toppings": [
{
"name": "tomato",
"sugarcontent": 0.0,
"name": "cheese",
"price": 0.50,
},
{
"name": "caramel",
"sugarcontent": 1.0,
"name": "peppers",
"price": 1.00,
},
{
"name": "chilli-oil",
"price": 0.1,
}
]
],
}
}
return json.dumps(message_values)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment