keywords.robot
11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
*** Settings ***
Resource resource.robot
Library op_robot_tests.tests_files.service_keywords
Library String
Library Collections
Library Selenium2Library
Library DateTime
Library DebugLibrary
*** Keywords ***
TestSuiteSetup
Set Selenium Implicit Wait 5 s
Set Selenium Timeout 10 s
Завантажуємо дані про користувачів і майданчики
Set Suite Variable With Default Value
[Arguments] ${suite_var} ${def_value}
${tmp}= Get Variable Value ${${suite_var}} ${def_value}
Set Suite Variable ${${suite_var}} ${tmp}
Завантажуємо дані про користувачів і майданчики
Log ${broker}
Log ${role}
${file_path}= Get Variable Value ${BROKERS_FILE} brokers.yaml
${BROKERS}= load_initial_data_from ${file_path}
log ${BROKERS}
Set Global Variable ${BROKERS}
${file_path}= Get Variable Value ${USERS_FILE} users.yaml
${USERS}= load_initial_data_from ${file_path}
Set Global Variable ${USERS}
Set Suite Variable With Default Value ${role} ${BROKERS['${broker}'].roles.${role}}
Set Suite Variable With Default Value tender_owner Tender_Owner
Set Suite Variable With Default Value provider Tender_User
Set Suite Variable With Default Value provider1 Tender_User1
Set Suite Variable With Default Value viewer Tender_Viewer
${active_users}= Create Dictionary tender_owner ${tender_owner} provider ${provider} provider1 ${provider1} viewer ${viewer}
${users_list}= Get Dictionary Items ${USERS.users}
:FOR ${username} ${user_data} IN @{users_list}
\ log ${active_users}
\ log ${username}
\ ${munch_dict}= munch_dict data=${True}
\ Log Many ${munch_dict}
\ ${status}= Run Keyword And Return Status Dictionary Should Contain Value ${active_users} ${username}
\ ${keywords_file}= Get Broker Property By Username ${username} keywords_file
\ Run Keyword If '${status}' == 'True' Завантажуємо бібліотеку з реалізацією для майданчика ${keywords_file}
\ Run Keyword If '${status}' == 'True' Викликати для учасника ${username} Підготувати клієнт для користувача
\ Run Keyword If '${status}' == 'True' Set To Dictionary ${USERS.users['${username}']} tender_data ${munch_dict}
Get Broker Property
[Arguments] ${broker_name} ${property}
[Documentation]
... This keyword returns a property of specified broker
... if that property exists, otherwise, it returns a
... default value.
${status}= Run Keyword And Return Status Should Contain ${BROKERS['${broker_name}']} ${property}
Return From Keyword If ${status} ${BROKERS['${broker_name}'].${property}}
# If broker doesn't have that property, fall back to default value
Should Contain ${BROKERS['Default']} ${property}
[return] ${BROKERS['Default'].${property}}
Get Broker Property By Username
[Documentation]
... This keyword gets the corresponding broker name
... for a specified username and then calls
... "Get Broker Property"
[Arguments] ${username} ${property}
${broker_name}= Get Variable Value ${USERS.users['${username}'].broker}
Run Keyword And Return Get Broker Property ${broker_name} ${property}
Підготовка початкових даних
@{QUESTIONS}= Create list
${question}= test question data
${question_lot}= test_lot_question_data ${question}
Append to list ${QUESTIONS} ${question} ${question_lot}
Set Global Variable @{QUESTIONS}
@{ANSWERS}= Create list
${answer}= test_question_answer_data
Append to list ${ANSWERS} ${answer}
Set Global Variable @{ANSWERS}
@{COMPLAINTS}= Create list
${complaint}= test_complaint_data
${complaint_lot}= test_lot_complaint_data ${complaint}
Append to list ${COMPLAINTS} ${complaint} ${complaint_lot}
Set Global Variable @{COMPLAINTS}
@{REPLIES}= Create list
${reply}= test_complaint_reply_data
Append to list ${REPLIES} ${reply}
Set Global Variable @{REPLIES}
${custom_intervals}= Get Broker Property By Username ${tender_owner} intervals
${default_intervals}= Get Broker Property Default intervals
${period_intervals}= merge_dicts ${default_intervals} ${custom_intervals}
${tender_data}= prepare_test_tender_data ${period_intervals} ${mode}
${TENDER}= Create Dictionary
Set Global Variable ${TENDER}
Log ${TENDER}
Log ${tender_data}
[return] ${tender_data}
Завантажуємо бібліотеку з реалізацією для майданчика ${keywords_file}
${bundled_st}= Run Keyword And Return Status Import Resource ${CURDIR}${/}brokers${/}${keywords_file}.robot
${external_st}= Run Keyword And Return Status Import Resource ${CURDIR}${/}..${/}..${/}src${/}robot_tests.broker.${keywords_file}${/}${keywords_file}.robot
Run Keyword If ${bundled_st} == ${external_st} == ${False} Fail Resource file ${keywords_file}.robot not found
Run Keyword If ${bundled_st} == ${external_st} == ${True} Fail Resource file ${keywords_file}.robot found in both brokers${/} and src${/}
Дочекатись синхронізації з майданчиком
[Arguments] ${username}
[Documentation]
... Find out how much time has passed since the procurement was modified
... and store the result in `delta`,
... then get `timeout_on_wait` for ``username``,
... then wait for `sleep` seconds, where:
...
... sleep = timeout_on_wait - delta
...
... Thus, when this keyword is executed several times in a row,
... it will wait for as long as really needed.
...
... Example:
...
... The procurement is modified.
... In 5 seconds, this keyword is called for `viewer`.
... Immediately, this keyword is called for `provider`.
... Timeout for `viewer` is 60.
... Timeout for `provider` is 300.
... First call (for `viewer`) will trigger `Sleep 55`.
... Second call (for `provider`) will trigger `Sleep 235`.
... As a result, the delay will end in 300 seconds
... since last modification date.
...
... Another example (a variation of previous one):
...
... Timeout for `viewer` is 120.
... Timeout for `provider` is 30.
... First call will trigger `Sleep 115`.
... Second call will trigger `Sleep 0`,
... since we have already slept for 120 seconds
... and there is no need to sleep any longer.
${now}= Get Current TZdate
${delta}= Subtract Date From Date ${now} ${TENDER['LAST_MODIFICATION_DATE']}
${timeout_on_wait}= Get Broker Property By Username ${username} timeout_on_wait
${sleep}= Subtract Time From Time ${timeout_on_wait} ${delta}
Run Keyword If ${sleep} > 0 Sleep ${sleep}
Звірити поле тендера
[Arguments] ${username} ${tender_data} ${field}
${left}= Get_From_Object ${tender_data.data} ${field}
Звірити поле тендера із значенням ${username} ${left} ${field}
Звірити поле тендера із значенням
[Arguments] ${username} ${left} ${field}
${right}= Викликати для учасника ${username} Отримати інформацію із тендера ${field}
Порівняти об'єкти ${left} ${right}
Set_To_Object ${USERS.users['${username}'].tender_data.data} ${field} ${left}
Порівняти об'єкти
[Arguments] ${left} ${right}
Should Not Be Equal ${left} ${None}
Should Not Be Equal ${right} ${None}
Should Be Equal ${left} ${right}
Звірити дату тендера
[Arguments] ${username} ${tender_data} ${field}
${left}= Get_From_Object ${tender_data.data} ${field}
Звірити дату тендера із значенням ${username} ${left} ${field}
Звірити дату тендера із значенням
[Arguments] ${username} ${left} ${field}
${right}= Викликати для учасника ${username} Отримати інформацію із тендера ${field}
Звірити дату ${left} ${right}
Set_To_Object ${USERS.users['${username}'].tender_data.data} ${field} ${left}
Звірити дату
[Arguments] ${left} ${right}
Should Not Be Equal ${left} ${None}
Should Not Be Equal ${right} ${None}
${status}= compare_date ${left} ${right}
Should Be True ${status}
Звірити поля предметів закупівлі багатопредметного тендера
[Arguments] ${username} ${tender_data} ${field}
Дочекатись синхронізації з майданчиком ${username}
@{items}= Get_From_Object ${tender_data.data} items
${len_of_items}= Get Length ${items}
:FOR ${index} IN RANGE ${len_of_items}
\ Log ${index}
\ Звірити поле тендера ${viewer} ${tender_data} items[${index}].${field}
Звірити дату предметів закупівлі багатопредметного тендера
[Arguments] ${username} ${tender_data} ${field}
Дочекатись синхронізації з майданчиком ${username}
@{items}= Get_From_Object ${tender_data.data} items
${len_of_items}= Get Length ${items}
:FOR ${index} IN RANGE ${len_of_items}
\ Log ${index}
\ Звірити дату тендера ${viewer} ${tender_data} items[${index}].${field}
Викликати для учасника
[Documentation]
... Cause sometimes keyword SHOULD fail to pass the testcase,
... this keyword takes "shouldfail" argument as first one in @{arguments}
... and switches the behaviour of keyword and "shouldfail"
[Arguments] ${username} ${command} @{arguments}
Log ${username}
Log ${command}
Log Many @{arguments}
${state}= change_state ${arguments}
Run Keyword And Return If '${state}' == 'shouldfail' SwitchState ${username} ${command} @{arguments}
Run Keyword And Return If '${state}' == 'pass' Normal ${username} ${command} @{arguments}
Normal
[Arguments] ${username} ${command} @{arguments}
Log ${username}
Log ${command}
Log Many @{arguments}
${keywords_file}= Get Broker Property By Username ${username} keywords_file
Run Keyword And Return ${keywords_file}.${command} ${username} @{arguments}
SwitchState
[Arguments] ${username} ${command} @{arguments}
Log ${username}
Log ${command}
Log Many @{arguments}
Remove From List ${arguments} 0
Log Many @{arguments}
${keywords_file}= Get Broker Property By Username ${username} keywords_file
${status} ${value}= run_keyword_and_ignore_keyword_definitions ${keywords_file}.${command} ${username} @{arguments}
Run keyword if '${status}' == 'PASS' Fail Користувач ${username} зміг виконати "${command}"
[return] ${value}
Дочекатись дати
[Arguments] ${date}
${wait_timeout}= wait_to_date ${date}
Run Keyword If ${wait_timeout}>0 Sleep ${wait_timeout}
Дочекатись дати початку прийому пропозицій
[Arguments] ${username}
log ${username}
Дочекатись дати ${USERS.users['${username}'].tender_data.data.tenderPeriod.startDate}
Дочекатись дати закінчення прийому пропозицій
[Arguments] ${username}
log ${username}
Дочекатись дати ${USERS.users['${username}'].tender_data.data.tenderPeriod.endDate}
Дочекатись дати початку аукціону
[Arguments] ${username}
log ${username}
Дочекатись дати ${USERS.users['${username}'].tender_data.data.auctionPeriod.startDate}
Дочекатись дати закінчення аукціону
[Arguments] ${username}
log ${username}
Дочекатись дати ${USERS.users['${username}'].tender_data.data.auctionPeriod.endDate}