Commit 853234bcdfe523ee5862bbf76e5d648999792e64

Authored by Volodymyr Cherepanyak
1 parent 03026108

tests timezone fixed

1 # -*- coding: utf-8 - 1 # -*- coding: utf-8 -
  2 +import os
  3 +from pytz import timezone
2 from datetime import datetime, timedelta 4 from datetime import datetime, timedelta
3 -now = datetime.now()  
4 from munch import munchify 5 from munch import munchify
5 from faker import Factory 6 from faker import Factory
  7 +from tempfile import NamedTemporaryFile
  8 +
6 fake = Factory.create('uk_UA') 9 fake = Factory.create('uk_UA')
7 fake_ru = Factory.create('ru') 10 fake_ru = Factory.create('ru')
8 fake_en = Factory.create() 11 fake_en = Factory.create()
9 -from tempfile import NamedTemporaryFile 12 +
  13 +TZ = timezone(os.environ['TZ'] if 'TZ' in os.environ else 'Europe/Kiev')
  14 +
  15 +def get_now():
  16 + return datetime.now(TZ)
  17 +
10 18
11 def create_fake_doc(): 19 def create_fake_doc():
12 content = fake.text() 20 content = fake.text()
@@ -16,7 +24,7 @@ def create_fake_doc(): @@ -16,7 +24,7 @@ def create_fake_doc():
16 return tf.name 24 return tf.name
17 25
18 def test_tender_data(period_interval=2): 26 def test_tender_data(period_interval=2):
19 - now = datetime.now() 27 + now = get_now()
20 return { 28 return {
21 "title": u"[ТЕСТУВАННЯ] " + fake.catch_phrase(), 29 "title": u"[ТЕСТУВАННЯ] " + fake.catch_phrase(),
22 "mode": "test", 30 "mode": "test",
@@ -100,7 +108,7 @@ def test_tender_data(period_interval=2): @@ -100,7 +108,7 @@ def test_tender_data(period_interval=2):
100 } 108 }
101 109
102 def prom_test_tender_data(): 110 def prom_test_tender_data():
103 - now = datetime.now() 111 + now = get_now()
104 return { 112 return {
105 "title": fake.catch_phrase(), 113 "title": fake.catch_phrase(),
106 "mode": "test", 114 "mode": "test",
@@ -185,7 +193,7 @@ def prom_test_tender_data(): @@ -185,7 +193,7 @@ def prom_test_tender_data():
185 } 193 }
186 194
187 def test_tender_data_multiple_lots(period_interval=2): 195 def test_tender_data_multiple_lots(period_interval=2):
188 - now = datetime.now() 196 + now = get_now()
189 return { 197 return {
190 "title": fake.catch_phrase(), 198 "title": fake.catch_phrase(),
191 "mode": "test", 199 "mode": "test",
Please register or login to post a comment