Browse Source

added test for Order.dict_repr()

Fabian Peter Hammerle 8 years ago
parent
commit
a25fe66a35
1 changed files with 39 additions and 0 deletions
  1. 39 0
      tests/test_.py

+ 39 - 0
tests/test_.py

@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+
+import pytest
+
+import datetime
+import dingguo
+import yaml
+import os
+
+project_root_path = os.path.realpath(os.path.join(__file__, '..', '..'))
+test_data_path = os.path.join(project_root_path, 'tests', 'data')
+
+def test_order_dict_repr():
+    
+    order = dingguo.Order(
+            platform = u'platform',
+            order_id = u'id',
+            order_date = datetime.datetime(2016, 5, 8, 0, 18, 17),
+            customer_id = u'customer',
+            )
+
+    item_0 = dingguo.Item(name = u'item 0', price_brutto = dingguo.Sum(1.0, u'EUR'))
+    order.items.append(item_0)
+    item_1 = dingguo.Item(name = u'item 1', price_brutto = dingguo.Sum(2.0, u'EUR'))
+    order.items.append(item_1)
+
+    discount_0 = dingguo.Discount(name = u'discount 0', amount = dingguo.Sum(3.0, u'EUR'))
+    order.discounts.append(discount_0)
+    discount_1 = dingguo.Discount(name = u'discount 1', amount = dingguo.Sum(4.0, u'EUR'))
+    order.discounts.append(discount_1)
+    
+    assert order.dict_repr() == {
+            'articles': [item_0, item_1],
+            'customer_id': u'customer',
+            'discounts': [discount_0, discount_1],
+            'order_date': u'2016-05-08',
+            'order_id': u'id',
+            'platform': u'platform',
+            }