|
@@ -11,7 +11,7 @@ project_root_path = os.path.realpath(os.path.join(__file__, '..', '..'))
|
|
test_data_path = os.path.join(project_root_path, 'tests', 'data')
|
|
test_data_path = os.path.join(project_root_path, 'tests', 'data')
|
|
|
|
|
|
def test_order_dict_repr():
|
|
def test_order_dict_repr():
|
|
-
|
|
+
|
|
order = dingguo.Order(
|
|
order = dingguo.Order(
|
|
platform = u'platform',
|
|
platform = u'platform',
|
|
order_id = u'id',
|
|
order_id = u'id',
|
|
@@ -28,7 +28,7 @@ def test_order_dict_repr():
|
|
order.discounts.append(discount_0)
|
|
order.discounts.append(discount_0)
|
|
discount_1 = dingguo.Discount(name = u'discount 1', amount = dingguo.Sum(4.0, u'EUR'))
|
|
discount_1 = dingguo.Discount(name = u'discount 1', amount = dingguo.Sum(4.0, u'EUR'))
|
|
order.discounts.append(discount_1)
|
|
order.discounts.append(discount_1)
|
|
-
|
|
+
|
|
assert order.dict_repr() == {
|
|
assert order.dict_repr() == {
|
|
'articles': [item_0, item_1],
|
|
'articles': [item_0, item_1],
|
|
'customer_id': u'customer',
|
|
'customer_id': u'customer',
|
|
@@ -37,3 +37,26 @@ def test_order_dict_repr():
|
|
'order_id': u'id',
|
|
'order_id': u'id',
|
|
'platform': u'platform',
|
|
'platform': u'platform',
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+def test_order_from_dict():
|
|
|
|
+
|
|
|
|
+ item_0 = dingguo.Item(name = u'item 0', price_brutto = dingguo.Sum(1.0, u'EUR'))
|
|
|
|
+ item_1 = dingguo.Item(name = u'item 1', price_brutto = dingguo.Sum(2.0, u'EUR'))
|
|
|
|
+ discount_0 = dingguo.Discount(name = u'discount 0', amount = dingguo.Sum(3.0, u'EUR'))
|
|
|
|
+ discount_1 = dingguo.Discount(name = u'discount 1', amount = dingguo.Sum(4.0, u'EUR'))
|
|
|
|
+
|
|
|
|
+ order = dingguo.Order.from_dict({
|
|
|
|
+ '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',
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ assert order.items == [item_0, item_1]
|
|
|
|
+ assert order.customer_id == u'customer'
|
|
|
|
+ assert order.discounts == [discount_0, discount_1]
|
|
|
|
+ assert order.order_date == datetime.date(2016, 5, 8)
|
|
|
|
+ assert order.order_id == u'id'
|
|
|
|
+ assert order.platform == u'platform'
|