Commit a041ccc6c1c39c0556a4870726e9555fe9a839c4

Authored by selurvedu
1 parent 509b57b6

Deduplicate code: get_now

1 1 # -*- coding: utf-8 -
2   -from datetime import datetime, timedelta
  2 +from datetime import timedelta
3 3 from faker import Factory
4 4 from munch import munchify
5   -from pytz import timezone
6 5 from tempfile import NamedTemporaryFile
7   -import os
  6 +from .local_time import get_now
8 7
9 8 fake = Factory.create('uk_UA')
10 9 fake_ru = Factory.create('ru')
11 10 fake_en = Factory.create()
12 11
13   -TZ = timezone(os.environ['TZ'] if 'TZ' in os.environ else 'Europe/Kiev')
14   -
15   -
16   -def get_now():
17   - return datetime.now(TZ)
18   -
19 12
20 13 def create_fake_doc():
21 14 content = fake.text()
... ...
  1 +from datetime import datetime
  2 +from pytz import timezone
  3 +import os
  4 +TZ = timezone(os.environ['TZ'] if 'TZ' in os.environ else 'Europe/Kiev')
  5 +
  6 +
  7 +def get_now():
  8 + return datetime.now(TZ)
... ...
1 1 # -*- coding: utf-8 -
2   -from datetime import datetime, timedelta
  2 +from datetime import timedelta
3 3 from dateutil.parser import parse
4 4 from dpath.util import set as xpathset
5 5 from iso8601 import parse_date
6 6 from json import load
7 7 from jsonpath_rw import parse as parse_path
8 8 from munch import fromYAML, Munch, munchify
9   -from pytz import timezone
10 9 from robot.errors import HandlerExecutionFailed
11 10 from robot.libraries.BuiltIn import BuiltIn
12 11 from robot.output import LOGGER
... ... @@ -20,16 +19,10 @@ from .initial_data import (
20 19 test_complaint_reply_data, test_question_answer_data,
21 20 test_question_data, test_tender_data, test_tender_data_multiple_lots
22 21 )
  22 +from .local_time import get_now, TZ
23 23 import os
24 24
25 25
26   -TZ = timezone(os.environ['TZ'] if 'TZ' in os.environ else 'Europe/Kiev')
27   -
28   -
29   -def get_now():
30   - return datetime.now(TZ)
31   -
32   -
33 26 def get_date():
34 27 return get_now().isoformat()
35 28
... ... @@ -189,7 +182,7 @@ def merge_dicts(left, right):
189 182
190 183 # GUI Frontends common
191 184 def add_data_for_gui_frontends(tender_data):
192   - now = datetime.now()
  185 + now = get_now()
193 186 # tender_data.data.enquiryPeriod['startDate'] = (now + timedelta(minutes=2)).isoformat()
194 187 tender_data.data.enquiryPeriod['endDate'] = (now + timedelta(minutes=6)).isoformat()
195 188 tender_data.data.tenderPeriod['startDate'] = (now + timedelta(minutes=7)).isoformat()
... ...
Please register or login to post a comment