Browse Source

tests/test_yaml.py: inserted some newlines

Fabian Peter Hammerle 7 years ago
parent
commit
2c28b4dcc8
2 changed files with 33 additions and 1 deletions
  1. 1 1
      setup.py
  2. 32 0
      tests/test_yaml.py

+ 1 - 1
setup.py

@@ -4,7 +4,7 @@ import glob
 
 setup(
     name = 'finoex',
-    version = '0.8.0',
+    version = '0.9.0',
     # description = '',
     author = 'Fabian Peter Hammerle',
     author_email = 'fabian.hammerle@gmail.com',

+ 32 - 0
tests/test_yaml.py

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