From: Ismaƫl Bouya Date: Fri, 22 Mar 2019 14:54:58 +0000 (+0100) Subject: Fix timezone in tests X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=8bbca32edc344c7ee2f5ea5db5448a4c4ff79684;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git Fix timezone in tests --- diff --git a/tests/helper.py b/tests/helper.py index a2f8a22..930d04a 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -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 diff --git a/tests/test_portfolio.py b/tests/test_portfolio.py index cad3095..f2f6394 100644 --- a/tests/test_portfolio.py +++ b/tests/test_portfolio.py @@ -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 = []