Showing
3 changed files
with
13 additions
and
19 deletions
1 | # -*- coding: utf-8 - | 1 | # -*- coding: utf-8 - |
2 | -from datetime import datetime, timedelta | 2 | +from datetime import timedelta |
3 | from faker import Factory | 3 | from faker import Factory |
4 | from munch import munchify | 4 | from munch import munchify |
5 | -from pytz import timezone | ||
6 | from tempfile import NamedTemporaryFile | 5 | from tempfile import NamedTemporaryFile |
7 | -import os | 6 | +from .local_time import get_now |
8 | 7 | ||
9 | fake = Factory.create('uk_UA') | 8 | fake = Factory.create('uk_UA') |
10 | fake_ru = Factory.create('ru') | 9 | fake_ru = Factory.create('ru') |
11 | fake_en = Factory.create() | 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 | def create_fake_doc(): | 13 | def create_fake_doc(): |
21 | content = fake.text() | 14 | content = fake.text() |
op_robot_tests/tests_files/local_time.py
0 → 100644
1 | # -*- coding: utf-8 - | 1 | # -*- coding: utf-8 - |
2 | -from datetime import datetime, timedelta | 2 | +from datetime import timedelta |
3 | from dateutil.parser import parse | 3 | from dateutil.parser import parse |
4 | from dpath.util import set as xpathset | 4 | from dpath.util import set as xpathset |
5 | from iso8601 import parse_date | 5 | from iso8601 import parse_date |
6 | from json import load | 6 | from json import load |
7 | from jsonpath_rw import parse as parse_path | 7 | from jsonpath_rw import parse as parse_path |
8 | from munch import fromYAML, Munch, munchify | 8 | from munch import fromYAML, Munch, munchify |
9 | -from pytz import timezone | ||
10 | from robot.errors import HandlerExecutionFailed | 9 | from robot.errors import HandlerExecutionFailed |
11 | from robot.libraries.BuiltIn import BuiltIn | 10 | from robot.libraries.BuiltIn import BuiltIn |
12 | from robot.output import LOGGER | 11 | from robot.output import LOGGER |
@@ -20,16 +19,10 @@ from .initial_data import ( | @@ -20,16 +19,10 @@ from .initial_data import ( | ||
20 | test_complaint_reply_data, test_question_answer_data, | 19 | test_complaint_reply_data, test_question_answer_data, |
21 | test_question_data, test_tender_data, test_tender_data_multiple_lots | 20 | test_question_data, test_tender_data, test_tender_data_multiple_lots |
22 | ) | 21 | ) |
22 | +from .local_time import get_now, TZ | ||
23 | import os | 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 | def get_date(): | 26 | def get_date(): |
34 | return get_now().isoformat() | 27 | return get_now().isoformat() |
35 | 28 | ||
@@ -189,7 +182,7 @@ def merge_dicts(left, right): | @@ -189,7 +182,7 @@ def merge_dicts(left, right): | ||
189 | 182 | ||
190 | # GUI Frontends common | 183 | # GUI Frontends common |
191 | def add_data_for_gui_frontends(tender_data): | 184 | def add_data_for_gui_frontends(tender_data): |
192 | - now = datetime.now() | 185 | + now = get_now() |
193 | # tender_data.data.enquiryPeriod['startDate'] = (now + timedelta(minutes=2)).isoformat() | 186 | # tender_data.data.enquiryPeriod['startDate'] = (now + timedelta(minutes=2)).isoformat() |
194 | tender_data.data.enquiryPeriod['endDate'] = (now + timedelta(minutes=6)).isoformat() | 187 | tender_data.data.enquiryPeriod['endDate'] = (now + timedelta(minutes=6)).isoformat() |
195 | tender_data.data.tenderPeriod['startDate'] = (now + timedelta(minutes=7)).isoformat() | 188 | tender_data.data.tenderPeriod['startDate'] = (now + timedelta(minutes=7)).isoformat() |
Please
register
or
login
to post a comment