|
@@ -32,6 +32,18 @@ def get_item_b():
|
|
price_brutto = get_sum_b(),
|
|
price_brutto = get_sum_b(),
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+def get_discount_a():
|
|
|
|
+ return dingguo.Discount(
|
|
|
|
+ name = u'discount a',
|
|
|
|
+ amount = get_sum_a(),
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+def get_discount_b():
|
|
|
|
+ return dingguo.Discount(
|
|
|
|
+ name = u'discount β',
|
|
|
|
+ amount = get_sum_b(),
|
|
|
|
+ )
|
|
|
|
+
|
|
def get_order_a():
|
|
def get_order_a():
|
|
order = dingguo.Order(
|
|
order = dingguo.Order(
|
|
platform = u'platformπ',
|
|
platform = u'platformπ',
|
|
@@ -41,6 +53,8 @@ def get_order_a():
|
|
)
|
|
)
|
|
order.items.append(get_item_a())
|
|
order.items.append(get_item_a())
|
|
order.items.append(get_item_b())
|
|
order.items.append(get_item_b())
|
|
|
|
+ order.discounts.append(get_discount_a())
|
|
|
|
+ order.discounts.append(get_discount_b())
|
|
return order
|
|
return order
|
|
|
|
|
|
def to_yaml(data):
|
|
def to_yaml(data):
|
|
@@ -115,10 +129,40 @@ name: item β
|
|
price_brutto: !sum 'EUR 20.45'
|
|
price_brutto: !sum 'EUR 20.45'
|
|
""")
|
|
""")
|
|
|
|
|
|
|
|
+def test_discount_to_yaml_a():
|
|
|
|
+ assert to_yaml(get_discount_a()) == u"""!discount
|
|
|
|
+amount: !sum 'EUR 1.23'
|
|
|
|
+name: discount a
|
|
|
|
+"""
|
|
|
|
+
|
|
|
|
+def test_discount_to_yaml_b():
|
|
|
|
+ assert to_yaml(get_discount_b()) == u"""!discount
|
|
|
|
+amount: !sum 'EUR 20.45'
|
|
|
|
+name: discount β
|
|
|
|
+"""
|
|
|
|
+
|
|
|
|
+def test_discount_from_yaml_a():
|
|
|
|
+ assert get_discount_a() == yaml.load(u"""!discount
|
|
|
|
+name: discount a
|
|
|
|
+amount: !sum 'EUR 1.23'
|
|
|
|
+""")
|
|
|
|
+
|
|
|
|
+def test_discount_from_yaml_b():
|
|
|
|
+ assert get_discount_b() == yaml.load(u"""!discount
|
|
|
|
+name: discount β
|
|
|
|
+amount: !sum 'EUR 20.45'
|
|
|
|
+""")
|
|
|
|
+
|
|
def test_order_to_yaml():
|
|
def test_order_to_yaml():
|
|
assert to_yaml(get_order_a()) == u"""!order
|
|
assert to_yaml(get_order_a()) == u"""!order
|
|
customer_id: customer
|
|
customer_id: customer
|
|
-discounts: []
|
|
|
|
|
|
+discounts:
|
|
|
|
+- !discount
|
|
|
|
+ amount: !sum 'EUR 1.23'
|
|
|
|
+ name: discount a
|
|
|
|
+- !discount
|
|
|
|
+ amount: !sum 'EUR 20.45'
|
|
|
|
+ name: discount β
|
|
items:
|
|
items:
|
|
- !item
|
|
- !item
|
|
name: item a
|
|
name: item a
|
|
@@ -134,7 +178,13 @@ platform: platformπ
|
|
def test_order_from_yaml():
|
|
def test_order_from_yaml():
|
|
order_loaded = yaml.load(u"""!order
|
|
order_loaded = yaml.load(u"""!order
|
|
customer_id: customer
|
|
customer_id: customer
|
|
-discounts: []
|
|
|
|
|
|
+discounts:
|
|
|
|
+- !discount
|
|
|
|
+ amount: !sum 'EUR 1.23'
|
|
|
|
+ name: discount a
|
|
|
|
+- !discount
|
|
|
|
+ amount: !sum 'EUR 20.45'
|
|
|
|
+ name: discount β
|
|
items:
|
|
items:
|
|
- !item
|
|
- !item
|
|
name: item a
|
|
name: item a
|