Commit c432f57fe1dbc85df3833b989afed2456a5b5eae

Authored by Volodymyr Cherepanyak
1 parent 853234bc

further timezone fixes

@@ -26,7 +26,7 @@ ${question_id} 0 @@ -26,7 +26,7 @@ ${question_id} 0
26 [Arguments] @{ARGUMENTS} 26 [Arguments] @{ARGUMENTS}
27 [Documentation] Відкрити брaвзер, створити обєкт api wrapper, тощо 27 [Documentation] Відкрити брaвзер, створити обєкт api wrapper, тощо
28 ${api_wrapper}= prepare_api_wrapper ${USERS.users['${ARGUMENTS[0]}'].api_key} ${API_HOST_URL} ${api_version} 28 ${api_wrapper}= prepare_api_wrapper ${USERS.users['${ARGUMENTS[0]}'].api_key} ${API_HOST_URL} ${api_version}
29 - ${creation_date} = get_date 29 + ${creation_date} = get_now
30 Set To Dictionary ${USERS.users['${ARGUMENTS[0]}']} creation_date ${creation_date} 30 Set To Dictionary ${USERS.users['${ARGUMENTS[0]}']} creation_date ${creation_date}
31 Set To Dictionary ${USERS.users['${ARGUMENTS[0]}']} client ${api_wrapper} 31 Set To Dictionary ${USERS.users['${ARGUMENTS[0]}']} client ${api_wrapper}
32 Log Variables 32 Log Variables
@@ -20,16 +20,16 @@ from .initial_data import ( @@ -20,16 +20,16 @@ from .initial_data import (
20 auction_bid, prom_test_tender_data, create_fake_doc 20 auction_bid, prom_test_tender_data, create_fake_doc
21 ) 21 )
22 22
23 -TIMEZONE = timezone('Europe/Kiev')  
24 23
  24 +TZ = timezone(os.environ['TZ'] if 'TZ' in os.environ else 'Europe/Kiev')
  25 +
  26 +def get_now():
  27 + return datetime.now(TZ)
25 28
26 def get_file_contents(path): 29 def get_file_contents(path):
27 with open(path, 'r') as f: 30 with open(path, 'r') as f:
28 return unicode(f.read()) or u'' 31 return unicode(f.read()) or u''
29 32
30 -def get_date():  
31 - return datetime.now().isoformat()  
32 -  
33 def change_state(arguments): 33 def change_state(arguments):
34 try: 34 try:
35 if arguments[0] == "shouldfail": 35 if arguments[0] == "shouldfail":
@@ -45,9 +45,9 @@ def compare_date(data1, data2): @@ -45,9 +45,9 @@ def compare_date(data1, data2):
45 data1=parse(data1) 45 data1=parse(data1)
46 data2=parse(data2) 46 data2=parse(data2)
47 if data1.tzinfo is None: 47 if data1.tzinfo is None:
48 - data1 = TIMEZONE.localize(data1) 48 + data1 = TZ.localize(data1)
49 if data2.tzinfo is None: 49 if data2.tzinfo is None:
50 - data2 = TIMEZONE.localize(data2) 50 + data2 = TZ.localize(data2)
51 51
52 delta = (data1-data2).total_seconds() 52 delta = (data1-data2).total_seconds()
53 if abs(delta) > 60: 53 if abs(delta) > 60:
@@ -116,7 +116,7 @@ def run_keyword_and_ignore_keyword_definitions(name, *args): @@ -116,7 +116,7 @@ def run_keyword_and_ignore_keyword_definitions(name, *args):
116 116
117 117
118 def set_tender_periods(tender): 118 def set_tender_periods(tender):
119 - now = datetime.now() 119 + now = get_now()
120 tender.data.enquiryPeriod.endDate = (now + timedelta(minutes=2)).isoformat() 120 tender.data.enquiryPeriod.endDate = (now + timedelta(minutes=2)).isoformat()
121 tender.data.tenderPeriod.startDate = (now + timedelta(minutes=2)).isoformat() 121 tender.data.tenderPeriod.startDate = (now + timedelta(minutes=2)).isoformat()
122 tender.data.tenderPeriod.endDate = (now + timedelta(minutes=4)).isoformat() 122 tender.data.tenderPeriod.endDate = (now + timedelta(minutes=4)).isoformat()
@@ -145,7 +145,7 @@ def get_from_object(obj, attribute): @@ -145,7 +145,7 @@ def get_from_object(obj, attribute):
145 def wait_to_date(date_stamp): 145 def wait_to_date(date_stamp):
146 date = parse(date_stamp) 146 date = parse(date_stamp)
147 LOGGER.log_message(Message("date: {}".format(date.isoformat()), "INFO")) 147 LOGGER.log_message(Message("date: {}".format(date.isoformat()), "INFO"))
148 - now = datetime.now(tzlocal()) 148 + now = get_now()
149 LOGGER.log_message(Message("now: {}".format(now.isoformat()), "INFO")) 149 LOGGER.log_message(Message("now: {}".format(now.isoformat()), "INFO"))
150 wait_seconds = (date - now).total_seconds() 150 wait_seconds = (date - now).total_seconds()
151 wait_seconds += 2 151 wait_seconds += 2
Please register or login to post a comment