Browse Source

moved attr 'arrival_time' from TaxiRide to Transportation

Fabian Peter Hammerle 7 years ago
parent
commit
f20cbc2d44
3 changed files with 24 additions and 18 deletions
  1. 4 3
      finoex/__init__.py
  2. 1 1
      setup.py
  3. 19 14
      tests/test_yaml.py

+ 4 - 3
finoex/__init__.py

@@ -447,6 +447,7 @@ class Transportation(Item):
     yaml_tag = u'!transportation'
 
     def __init__(self,
+                 arrival_time=None,
                  departure_point=None,
                  destination_point=None,
                  distance=None,
@@ -459,6 +460,9 @@ class Transportation(Item):
                  **kwargs
                  ):
         super(Transportation, self).__init__(**kwargs)
+        if arrival_time is not None:
+            assert isinstance(arrival_time, datetime.datetime)
+            self.arrival_time = arrival_time
         if departure_point is not None:
             assert type(departure_point) is str
             self.departure_point = departure_point
@@ -511,7 +515,6 @@ class TaxiRide(Transportation):
     yaml_tag = u'!taxi-ride'
 
     def __init__(self,
-                 arrival_time=None,
                  departure_time=None,
                  driver=None,
                  name=None,
@@ -522,8 +525,6 @@ class TaxiRide(Transportation):
         super(TaxiRide, self).__init__(name=name, **kwargs)
         assert type(driver) is str
         self.driver = driver
-        assert arrival_time is None or type(arrival_time) is datetime.datetime
-        self.arrival_time = arrival_time
         assert departure_time is None or type(
             departure_time) is datetime.datetime
         self.departure_time = departure_time

+ 1 - 1
setup.py

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

+ 19 - 14
tests/test_yaml.py

@@ -150,20 +150,23 @@ def get_article():
 
 def get_transportation():
     return finoex.Transportation(
-            name = u'ticket',
-            price_brutto = get_sum_a(),
-            departure_point = u'home',
-            destination_point = u'city',
-            distance = finoex.Distance(3.21, u'km'),
-            passenger = get_person_a(),
-            valid_from = datetime.datetime(2016, 7, 14, 13, 50, 4, 0, tzinfo = pytz.timezone('Europe/Vienna')),
-            valid_until = datetime.datetime(2016, 7, 14, 18, 50, 4, 0, tzinfo = pytz.utc),
-            ticket_url = u'https://www.example.com',
-            estimated_arrival_time = ioex.datetimeex.Period(
-                start = pytz.timezone('Europe/Vienna').localize(datetime.datetime(2016, 7, 24, 23, 47, 2)),
-                end = pytz.utc.localize(datetime.datetime(2016, 7, 24, 23, 48, 5)),
-                ),
-            )
+        name = u'ticket',
+        price_brutto = get_sum_a(),
+        departure_point = u'home',
+        destination_point = u'city',
+        distance = finoex.Distance(3.21, u'km'),
+        passenger = get_person_a(),
+        valid_from = datetime.datetime(2016, 7, 14, 13, 50, 4, 0, tzinfo = pytz.timezone('Europe/Vienna')),
+        valid_until = datetime.datetime(2016, 7, 14, 18, 50, 4, 0, tzinfo = pytz.utc),
+        ticket_url = u'https://www.example.com',
+        estimated_arrival_time = ioex.datetimeex.Period(
+            start = pytz.timezone('Europe/Vienna').localize(datetime.datetime(2016, 7, 24, 23, 47, 2)),
+            end = pytz.utc.localize(datetime.datetime(2016, 7, 24, 23, 48, 5)),
+            ),
+        arrival_time = pytz.timezone('Europe/Vienna').localize(
+            datetime.datetime(2016, 7, 24, 23, 47, 35)
+        ),
+    )
 
 
 def get_shipping():
@@ -416,6 +419,7 @@ state: goood
 width: !distance '1.23 m'
 """],
     [get_transportation(), u"""!transportation
+arrival_time: 2016-07-24 23:47:35+02:00
 departure_point: home
 destination_point: city
 distance: !distance '3.21 km'
@@ -559,6 +563,7 @@ reward: product
   first_name: 名字
   last_name: 贵姓"""],
     [get_transportation(), u"""!transportation
+arrival_time: 2016-07-24 23:47:35+02:00
 departure_point: home
 destination_point: city
 distance: !distance '3.21 km'