]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/commitdiff
Fix timezone in tests
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 22 Mar 2019 14:54:58 +0000 (15:54 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 22 Mar 2019 15:03:12 +0000 (16:03 +0100)
tests/helper.py
tests/test_portfolio.py

index a2f8a2243c5e6966a96ccda794741291970d201a..930d04a4cc17f86fbe945794a2716834f07f332e 100644 (file)
@@ -5,9 +5,10 @@ from unittest import mock
 import requests_mock
 from io import StringIO
 import portfolio, market, main, store, dbs
+import datetime
 
 __all__ = ["limits", "unittest", "WebMockTestCase", "mock", "D",
-        "StringIO"]
+        "StringIO", "tz"]
 
 limits = ["acceptance", "unit"]
 for test_type in limits:
@@ -19,6 +20,9 @@ for test_type in limits:
         limits = [test_type]
         break
 
+def tz(hours):
+    return datetime.timezone(datetime.timedelta(hours=hours))
+
 class WebMockTestCase(unittest.TestCase):
     import time
 
index cad3095a34eb2bfd0f42ef1b398d6ad878b86a6c..f2f639470c0bbf880916d16f5d0583b59392357e 100644 (file)
@@ -1361,7 +1361,7 @@ class OrderTest(WebMockTestCase):
         with self.subTest(similar_open_order=True):
             order = portfolio.Order("buy", portfolio.Amount("ETH", "0.001"),
                     D("0.1"), "BTC", "long", self.m, "trade")
-            order.start_date = datetime.datetime(2018, 3, 25, 15, 15, 55)
+            order.start_date = datetime.datetime(2018, 3, 25, 15, 15, 55, 0, tz(2))
 
             self.m.ccxt.order_precision.return_value = 8
             self.m.ccxt.fetch_orders.return_value = [
@@ -1471,7 +1471,7 @@ class OrderTest(WebMockTestCase):
         with self.subTest(similar_open_order=False, past_trades=True):
             order = portfolio.Order("buy", portfolio.Amount("ETH", "0.001"),
                     D("0.1"), "BTC", "long", self.m, "trade")
-            order.start_date = datetime.datetime(2018, 3, 25, 15, 15, 55)
+            order.start_date = datetime.datetime(2018, 3, 25, 15, 15, 55, 0, tz(2))
 
             self.m.ccxt.order_precision.return_value = 8
             self.m.ccxt.fetch_orders.return_value = []