|
@@ -11,30 +11,37 @@ import os
|
|
import pytz
|
|
import pytz
|
|
yaml = pytest.importorskip('yaml')
|
|
yaml = pytest.importorskip('yaml')
|
|
|
|
|
|
|
|
+
|
|
def get_figure_a():
|
|
def get_figure_a():
|
|
return ioex.calcex.Figure(12.3, u'km')
|
|
return ioex.calcex.Figure(12.3, u'km')
|
|
|
|
|
|
|
|
+
|
|
def get_figure_b():
|
|
def get_figure_b():
|
|
return ioex.calcex.Figure(12300, u'米')
|
|
return ioex.calcex.Figure(12300, u'米')
|
|
|
|
|
|
|
|
+
|
|
def get_sum_a():
|
|
def get_sum_a():
|
|
return finoex.Sum(1.23, u'EUR')
|
|
return finoex.Sum(1.23, u'EUR')
|
|
|
|
|
|
|
|
+
|
|
def get_sum_b():
|
|
def get_sum_b():
|
|
return finoex.Sum(20.45, u'€')
|
|
return finoex.Sum(20.45, u'€')
|
|
|
|
|
|
|
|
+
|
|
def get_item_a():
|
|
def get_item_a():
|
|
return finoex.Item(
|
|
return finoex.Item(
|
|
name = u'item a',
|
|
name = u'item a',
|
|
price_brutto = get_sum_a(),
|
|
price_brutto = get_sum_a(),
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_item_b():
|
|
def get_item_b():
|
|
return finoex.Item(
|
|
return finoex.Item(
|
|
name = u'item β',
|
|
name = u'item β',
|
|
price_brutto = get_sum_b(),
|
|
price_brutto = get_sum_b(),
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_service_a():
|
|
def get_service_a():
|
|
return finoex.Service(
|
|
return finoex.Service(
|
|
duration = ioex.datetimeex.Duration(years = 2),
|
|
duration = ioex.datetimeex.Duration(years = 2),
|
|
@@ -45,6 +52,7 @@ def get_service_a():
|
|
state = 'success',
|
|
state = 'success',
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_hosting_service():
|
|
def get_hosting_service():
|
|
return finoex.HostingService(
|
|
return finoex.HostingService(
|
|
duration = ioex.datetimeex.Duration(years = 2),
|
|
duration = ioex.datetimeex.Duration(years = 2),
|
|
@@ -56,6 +64,7 @@ def get_hosting_service():
|
|
state = 'running',
|
|
state = 'running',
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_cloud_mining():
|
|
def get_cloud_mining():
|
|
return finoex.CloudMining(
|
|
return finoex.CloudMining(
|
|
hashrate = ioex.calcex.Figure(8, u'TH/s'),
|
|
hashrate = ioex.calcex.Figure(8, u'TH/s'),
|
|
@@ -63,6 +72,7 @@ def get_cloud_mining():
|
|
price_brutto = finoex.Sum(1.0, u'EUR'),
|
|
price_brutto = finoex.Sum(1.0, u'EUR'),
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_service_b():
|
|
def get_service_b():
|
|
return finoex.Service(
|
|
return finoex.Service(
|
|
name = u'service',
|
|
name = u'service',
|
|
@@ -73,18 +83,21 @@ def get_service_b():
|
|
),
|
|
),
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_person_a():
|
|
def get_person_a():
|
|
return finoex.Person(
|
|
return finoex.Person(
|
|
first_name = u'Fabian Peter',
|
|
first_name = u'Fabian Peter',
|
|
last_name = u'Hammerle',
|
|
last_name = u'Hammerle',
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_person_b():
|
|
def get_person_b():
|
|
return finoex.Person(
|
|
return finoex.Person(
|
|
first_name = u'名字',
|
|
first_name = u'名字',
|
|
last_name = u'贵姓',
|
|
last_name = u'贵姓',
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_campaign_a():
|
|
def get_campaign_a():
|
|
return finoex.Campaign(
|
|
return finoex.Campaign(
|
|
name = u'campaign a',
|
|
name = u'campaign a',
|
|
@@ -92,6 +105,7 @@ def get_campaign_a():
|
|
end = datetime.datetime(2016, 7, 23, 9, 23, 17, tzinfo = pytz.timezone('Europe/Vienna')),
|
|
end = datetime.datetime(2016, 7, 23, 9, 23, 17, tzinfo = pytz.timezone('Europe/Vienna')),
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_campaign_b():
|
|
def get_campaign_b():
|
|
return finoex.Campaign(
|
|
return finoex.Campaign(
|
|
founder = u'company',
|
|
founder = u'company',
|
|
@@ -99,6 +113,7 @@ def get_campaign_b():
|
|
website_url = u'http://campaign.com',
|
|
website_url = u'http://campaign.com',
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_pledge():
|
|
def get_pledge():
|
|
return finoex.Pledge(
|
|
return finoex.Pledge(
|
|
campaign = get_campaign_a(),
|
|
campaign = get_campaign_a(),
|
|
@@ -106,6 +121,7 @@ def get_pledge():
|
|
reward = u'great',
|
|
reward = u'great',
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_contribution():
|
|
def get_contribution():
|
|
return finoex.Contribution(
|
|
return finoex.Contribution(
|
|
campaign = get_campaign_a(),
|
|
campaign = get_campaign_a(),
|
|
@@ -113,6 +129,7 @@ def get_contribution():
|
|
reward = u'product',
|
|
reward = u'product',
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_article():
|
|
def get_article():
|
|
return finoex.Article(
|
|
return finoex.Article(
|
|
authors = ['a', 'b'],
|
|
authors = ['a', 'b'],
|
|
@@ -130,6 +147,7 @@ def get_article():
|
|
width = finoex.Distance(1.23, u'm'),
|
|
width = finoex.Distance(1.23, u'm'),
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_transportation():
|
|
def get_transportation():
|
|
return finoex.Transportation(
|
|
return finoex.Transportation(
|
|
name = u'ticket',
|
|
name = u'ticket',
|
|
@@ -147,6 +165,7 @@ def get_transportation():
|
|
),
|
|
),
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_shipping():
|
|
def get_shipping():
|
|
return finoex.Shipping(
|
|
return finoex.Shipping(
|
|
price_brutto = get_sum_a(),
|
|
price_brutto = get_sum_a(),
|
|
@@ -154,6 +173,7 @@ def get_shipping():
|
|
tracking_number = 'LX123456789CN',
|
|
tracking_number = 'LX123456789CN',
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_taxi_ride():
|
|
def get_taxi_ride():
|
|
return finoex.TaxiRide(
|
|
return finoex.TaxiRide(
|
|
name = u'taxi ride',
|
|
name = u'taxi ride',
|
|
@@ -166,18 +186,21 @@ def get_taxi_ride():
|
|
departure_time = datetime.datetime(2016, 5, 2, 18, 25, tzinfo = pytz.timezone('Europe/Vienna')),
|
|
departure_time = datetime.datetime(2016, 5, 2, 18, 25, tzinfo = pytz.timezone('Europe/Vienna')),
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_discount_a():
|
|
def get_discount_a():
|
|
return finoex.Discount(
|
|
return finoex.Discount(
|
|
name = u'discount a',
|
|
name = u'discount a',
|
|
amount = get_sum_a(),
|
|
amount = get_sum_a(),
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_discount_b():
|
|
def get_discount_b():
|
|
return finoex.Discount(
|
|
return finoex.Discount(
|
|
name = u'discount β',
|
|
name = u'discount β',
|
|
amount = get_sum_b(),
|
|
amount = get_sum_b(),
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_discount_c():
|
|
def get_discount_c():
|
|
return finoex.Discount(
|
|
return finoex.Discount(
|
|
amount = get_sum_b(),
|
|
amount = get_sum_b(),
|
|
@@ -185,6 +208,7 @@ def get_discount_c():
|
|
name = u'discount c',
|
|
name = u'discount c',
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def get_order_a(items = True, discounts = True):
|
|
def get_order_a(items = True, discounts = True):
|
|
order = finoex.Order(
|
|
order = finoex.Order(
|
|
platform = u'platformπ',
|
|
platform = u'platformπ',
|
|
@@ -200,6 +224,7 @@ def get_order_a(items = True, discounts = True):
|
|
order.discounts.append(get_discount_b())
|
|
order.discounts.append(get_discount_b())
|
|
return order
|
|
return order
|
|
|
|
|
|
|
|
+
|
|
def get_order_b():
|
|
def get_order_b():
|
|
order = finoex.Order(
|
|
order = finoex.Order(
|
|
platform = u'platformπ',
|
|
platform = u'platformπ',
|
|
@@ -208,6 +233,7 @@ def get_order_b():
|
|
)
|
|
)
|
|
return order
|
|
return order
|
|
|
|
|
|
|
|
+
|
|
def get_order_c():
|
|
def get_order_c():
|
|
order = finoex.Order(
|
|
order = finoex.Order(
|
|
platform = u'γάμμα',
|
|
platform = u'γάμμα',
|
|
@@ -217,6 +243,7 @@ def get_order_c():
|
|
)
|
|
)
|
|
return order
|
|
return order
|
|
|
|
|
|
|
|
+
|
|
def get_invoice(items = True, discounts = True):
|
|
def get_invoice(items = True, discounts = True):
|
|
inv = finoex.Invoice(
|
|
inv = finoex.Invoice(
|
|
creditor = u'platformπ',
|
|
creditor = u'platformπ',
|
|
@@ -231,9 +258,11 @@ def get_invoice(items = True, discounts = True):
|
|
inv.discounts.append(get_discount_a())
|
|
inv.discounts.append(get_discount_a())
|
|
return inv
|
|
return inv
|
|
|
|
|
|
|
|
+
|
|
def get_distance():
|
|
def get_distance():
|
|
return finoex.Distance(2.4142, u'km')
|
|
return finoex.Distance(2.4142, u'km')
|
|
|
|
|
|
|
|
+
|
|
def to_yaml(data):
|
|
def to_yaml(data):
|
|
class Dumper(yaml.Dumper):
|
|
class Dumper(yaml.Dumper):
|
|
pass
|
|
pass
|
|
@@ -249,12 +278,14 @@ def to_yaml(data):
|
|
Dumper = Dumper,
|
|
Dumper = Dumper,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
def yaml_diff(a, b):
|
|
def yaml_diff(a, b):
|
|
return '\n'.join(difflib.ndiff(
|
|
return '\n'.join(difflib.ndiff(
|
|
to_yaml(a).split('\n'),
|
|
to_yaml(a).split('\n'),
|
|
to_yaml(b).split('\n'),
|
|
to_yaml(b).split('\n'),
|
|
))
|
|
))
|
|
|
|
|
|
|
|
+
|
|
@pytest.mark.parametrize('source_object,expected_yaml', [
|
|
@pytest.mark.parametrize('source_object,expected_yaml', [
|
|
[datetime.datetime(2016, 7, 14, 13, 50, 4, 0), '2016-07-14 13:50:04\n...\n'],
|
|
[datetime.datetime(2016, 7, 14, 13, 50, 4, 0), '2016-07-14 13:50:04\n...\n'],
|
|
[datetime.datetime(2016, 7, 14, 13, 50, 4, 0, tzinfo = pytz.timezone('Europe/Vienna')), '2016-07-14 13:50:04+01:05\n...\n'],
|
|
[datetime.datetime(2016, 7, 14, 13, 50, 4, 0, tzinfo = pytz.timezone('Europe/Vienna')), '2016-07-14 13:50:04+01:05\n...\n'],
|
|
@@ -436,6 +467,7 @@ items:
|
|
def test_to_yaml(source_object, expected_yaml):
|
|
def test_to_yaml(source_object, expected_yaml):
|
|
assert expected_yaml == to_yaml(source_object)
|
|
assert expected_yaml == to_yaml(source_object)
|
|
|
|
|
|
|
|
+
|
|
@pytest.mark.parametrize('expected_object,source_yaml', [
|
|
@pytest.mark.parametrize('expected_object,source_yaml', [
|
|
[datetime.datetime(2016, 7, 14, 13, 50, 4, 0), '2016-07-14 13:50:04'],
|
|
[datetime.datetime(2016, 7, 14, 13, 50, 4, 0), '2016-07-14 13:50:04'],
|
|
[datetime.datetime(2016, 7, 14, 13, 50, 4, 0, tzinfo = pytz.timezone('Europe/Vienna')), '2016-07-14 13:50:04+01:05'],
|
|
[datetime.datetime(2016, 7, 14, 13, 50, 4, 0, tzinfo = pytz.timezone('Europe/Vienna')), '2016-07-14 13:50:04+01:05'],
|