123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- # -*- coding: utf-8 -*-
- import pytest
- import datetime
- import dingguo
- import yaml
- import os
- def get_item_a():
- return dingguo.Item(
- name = u'item',
- price_brutto = dingguo.Sum(1.0, u'EUR'),
- )
- def get_item_b():
- return dingguo.Item(
- name = u'item',
- price_brutto = dingguo.Sum(2.0, u'EUR'),
- )
- def get_discount_a():
- return dingguo.Discount(
- name = u'discount',
- amount = dingguo.Sum(1.0, u'EUR'),
- )
- def get_discount_b():
- return dingguo.Discount(
- name = u'discount',
- amount = dingguo.Sum(2.0, u'EUR'),
- )
- def get_order_a(items = True):
- order = dingguo.Order(
- platform = u'platform',
- order_id = u'id',
- order_date = datetime.datetime(2016, 5, 8, 0, 18, 17),
- customer_id = u'customer',
- )
- if items:
- order.items.append(get_item_a())
- order.items.append(get_item_b())
- order.discounts.append(get_discount_a())
- order.discounts.append(get_discount_b())
- return order
- def get_order_b():
- order = dingguo.Order(
- platform = u'platform',
- order_id = u'id',
- order_date = datetime.datetime(2016, 5, 8, 0, 18, 17),
- )
- order.items.append(get_item_a())
- order.items.append(get_item_b())
- order.discounts.append(get_discount_a())
- order.discounts.append(get_discount_b())
- return order
- def get_order_c():
- order = dingguo.Order(
- platform = u'platform',
- order_id = u'id',
- order_date = datetime.datetime(2016, 5, 8, 0, 18, 17),
- )
- 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
- def test_figure_eq():
- assert dingguo.Figure(1, u'mm') == dingguo.Figure(1, u'mm')
- def test_figure_eq_inverted():
- assert not dingguo.Figure(1, u'mm') == dingguo.Figure(2, u'mm')
- def test_figure_ne():
- assert dingguo.Figure(1, u'mm') != dingguo.Figure(2, u'mm')
- def test_figure_ne_inverted():
- assert not dingguo.Figure(1, u'mm') != dingguo.Figure(1, u'mm')
- def test_item_eq():
- assert get_item_a() == get_item_a()
- assert get_item_b() == get_item_b()
- def test_item_eq_inverted():
- assert not get_item_a() == get_item_b()
- def test_item_ne():
- assert get_item_a() != get_item_b()
- def test_item_ne_inverted():
- assert not get_item_a() != get_item_a()
- assert not get_item_b() != get_item_b()
- def test_discount_eq():
- assert get_discount_a() == get_discount_a()
- assert get_discount_b() == get_discount_b()
- def test_discount_eq_inverted():
- assert not get_discount_a() == get_discount_b()
- def test_discount_ne():
- assert get_discount_a() != get_discount_b()
- def test_discount_ne_inverted():
- assert not get_discount_a() != get_discount_a()
- assert not get_discount_b() != get_discount_b()
- def test_order_eq():
- assert get_order_a() == get_order_a()
- assert get_order_b() == get_order_b()
- assert get_order_c() == get_order_c()
- def test_order_eq_inverted():
- assert not get_order_a() == get_order_c()
- assert not get_order_b() == get_order_a()
- assert not get_order_c() == get_order_b()
- def test_order_ne():
- assert get_order_a() != get_order_c()
- assert get_order_b() != get_order_a()
- assert get_order_c() != get_order_b()
- def test_order_ne_inverted():
- assert not get_order_a() != get_order_a()
- assert not get_order_b() != get_order_b()
- assert not get_order_c() != get_order_c()
- def test_order_ne_items():
- assert get_order_a() != get_order_a(items = False)
- def test_order_ne_items_reversed():
- order = get_order_a()
- order.items = order.items[::-1]
- assert get_order_a() != order
|