Showing
2 changed files
with
0 additions
and
122 deletions
!playtender.robot
deleted
100644 → 0
This diff could not be displayed because it is too large.
!playtender_service.py
deleted
100644 → 0
1 | -# -*- coding: utf-8 - | |
2 | -from iso8601 import parse_date | |
3 | -from datetime import datetime | |
4 | -from robot.libraries.BuiltIn import BuiltIn | |
5 | -from robot.output import librarylogger | |
6 | -import urllib | |
7 | -import urllib3 | |
8 | - | |
9 | -def get_library(): | |
10 | - return BuiltIn().get_library_instance('Selenium2Library') | |
11 | - | |
12 | - | |
13 | -def get_webdriver_instance(): | |
14 | - return get_library()._current_browser() | |
15 | - | |
16 | - | |
17 | -def convert_datetime_for_delivery(isodate): | |
18 | - iso_dt = parse_date(isodate) | |
19 | - date_string = iso_dt.strftime("%Y-%m-%d %H:%M") | |
20 | - return date_string | |
21 | - | |
22 | -def convert_isodate_to_site_date(isodate): | |
23 | - iso_dt = parse_date(isodate) | |
24 | - date_string = iso_dt.strftime("%d.%m.%Y") | |
25 | - return date_string | |
26 | - | |
27 | -def convert_isodate_to_site_datetime(isodate): | |
28 | - iso_dt = parse_date(isodate) | |
29 | - date_string = iso_dt.strftime("%d.%m.%Y %H:%M") | |
30 | - return date_string | |
31 | - | |
32 | -def convert_date_for_compare(datestr): | |
33 | - return datetime.strptime(datestr, "%d.%m.%Y %H:%M").strftime("%Y-%m-%d %H:%M") | |
34 | - | |
35 | - | |
36 | -def procuring_entity_name(tender_data): | |
37 | - tender_data.data.procuringEntity['name'] = u"ТОВ \"ПлейТендер\"" | |
38 | - tender_data.data.procuringEntity['name_en'] = u"TOV \"playtender\"" | |
39 | - tender_data.data.procuringEntity.identifier['id'] = u"1234567890-playtender" | |
40 | - tender_data.data.procuringEntity.identifier['legalName'] = u"ТОВ \"ПлейТендер\"" | |
41 | - tender_data.data.procuringEntity.identifier['legalName_en'] = u"TOV \"playtender\"" | |
42 | - if 'address' in tender_data.data.procuringEntity: | |
43 | - tender_data.data.procuringEntity.address['region'] = u"Житомирська область" | |
44 | - tender_data.data.procuringEntity.address['postalCode'] = u"123123" | |
45 | - tender_data.data.procuringEntity.address['locality'] = u"населений пункт" | |
46 | - tender_data.data.procuringEntity.address['streetAddress'] = u"адреса" | |
47 | - if 'contactPoint' in tender_data.data.procuringEntity: | |
48 | - tender_data.data.procuringEntity.contactPoint['name'] = u"Замовник Тест" | |
49 | - tender_data.data.procuringEntity.contactPoint['name_en'] = u"Test" | |
50 | - tender_data.data.procuringEntity.contactPoint['email'] = u"chuzhin@mail.ua" | |
51 | - tender_data.data.procuringEntity.contactPoint['telephone'] = u"+3801111111111" | |
52 | - tender_data.data.procuringEntity.contactPoint['url'] = u"http://playtender.com.ua" | |
53 | - return tender_data | |
54 | - | |
55 | -def split_take_item(value, separator, index): | |
56 | - librarylogger.console('split_take_item') | |
57 | - librarylogger.console(value) | |
58 | - librarylogger.console(separator) | |
59 | - librarylogger.console(index) | |
60 | - return value.split(separator)[int(index)] | |
61 | - | |
62 | - | |
63 | -def split_take_slice(value, separator, _from=None, to=None): | |
64 | - librarylogger.console(value) | |
65 | - librarylogger.console(separator) | |
66 | - librarylogger.console(_from) | |
67 | - librarylogger.console(to) | |
68 | - l = value.split(separator) | |
69 | - if to: | |
70 | - l = l[:int(to)] | |
71 | - if _from: | |
72 | - l = l[int(_from):] | |
73 | - return l | |
74 | - | |
75 | -def split_take_slice_from(value, separator, _from): | |
76 | - librarylogger.console('split_take_slice_from') | |
77 | - return split_take_slice(value, separator, _from) | |
78 | - | |
79 | -def split_take_slice_to(value, separator, to): | |
80 | - librarylogger.console('split_take_slice_to') | |
81 | - return split_take_slice(value, separator, to=to) | |
82 | - | |
83 | -def join(l, separator): | |
84 | - librarylogger.console('join') | |
85 | - librarylogger.console(l) | |
86 | - return separator.join(l) | |
87 | - | |
88 | - | |
89 | -def get_invisible_text(locator): | |
90 | - element = get_library()._element_find(locator, False, True) | |
91 | - text = get_webdriver_instance().execute_script('return jQuery(arguments[0]).text();', element) | |
92 | - return text | |
93 | - | |
94 | - | |
95 | -def get_text_excluding_children(locator): | |
96 | - element = get_library()._element_find(locator, False, True) | |
97 | - text = get_webdriver_instance().execute_script(""" | |
98 | - return jQuery(arguments[0]).contents().filter(function() { | |
99 | - return this.nodeType == Node.TEXT_NODE; | |
100 | - }).text(); | |
101 | - """, element) | |
102 | - return text.strip() | |
103 | - | |
104 | -def convert_float_to_string(number): | |
105 | - return format(number, '.2f') | |
106 | - | |
107 | -def convert_date_for_compare_ex(datestr): | |
108 | - return datetime.strptime(datestr, "%d.%m.%Y %H:%M").strftime("%Y-%m-%d %H:%M+02:00") | |
109 | - | |
110 | -def convert_date_for_compare_ex2(datestr): | |
111 | - return datetime.strptime(datestr, "%d.%m.%Y %H:%M").strftime("%Y-%m-%d %H:%M+02:00") | |
112 | - | |
113 | -def download_file(url, file_name, output_dir): | |
114 | - urllib.urlretrieve(url, ('{}/{}'.format(output_dir, file_name))) | |
115 | - | |
116 | -def multiply_hundred(number): | |
117 | - return number*100 | |
118 | - | |
119 | -def inject_urllib3(): | |
120 | - import urllib3.contrib.pyopenssl | |
121 | - urllib3.contrib.pyopenssl.inject_into_urllib3() | |
122 | - |
Please
register
or
login
to post a comment