...
|
...
|
@@ -54,36 +54,80 @@ Set Suite Variable With Default Value |
54
|
54
|
Завантажуємо дані про користувачів і майданчики
|
55
|
55
|
Log ${broker}
|
56
|
56
|
Log ${role}
|
|
57
|
+ # Suite variable; should be present in every test suite
|
|
58
|
+ # in `*** Variables ***` section
|
|
59
|
+ Log Many @{used_roles}
|
57
|
60
|
|
|
61
|
+ # Load brokers data
|
58
|
62
|
${file_path}= Get Variable Value ${BROKERS_FILE} brokers.yaml
|
59
|
|
- ${BROKERS}= load_initial_data_from ${file_path}
|
|
63
|
+ ${BROKERS}= load_data_from ${file_path} mode=brokers
|
60
|
64
|
Log ${BROKERS}
|
61
|
65
|
Set Suite Variable ${BROKERS}
|
|
66
|
+ # List of currently used brokers
|
|
67
|
+ ${used_brokers}= Create List
|
62
|
68
|
|
|
69
|
+ # Load users data
|
63
|
70
|
${file_path}= Get Variable Value ${USERS_FILE} users.yaml
|
64
|
|
- ${USERS}= load_initial_data_from ${file_path}
|
65
|
|
- Set Global Variable ${USERS}
|
66
|
|
-
|
67
|
|
- Set Suite Variable With Default Value ${role} ${BROKERS['${broker}'].roles.${role}}
|
68
|
|
- Set Suite Variable With Default Value tender_owner Tender_Owner
|
69
|
|
- Set Suite Variable With Default Value provider Tender_User
|
70
|
|
- Set Suite Variable With Default Value provider1 Tender_User1
|
71
|
|
- Set Suite Variable With Default Value viewer Tender_Viewer
|
72
|
|
- ${active_users}= Create Dictionary tender_owner=${tender_owner} provider=${provider} provider1=${provider1} viewer=${viewer}
|
73
|
|
-
|
74
|
|
- ${users_list}= Get Dictionary Items ${USERS.users}
|
75
|
|
- :FOR ${username} ${user_data} IN @{users_list}
|
76
|
|
- \ Log ${active_users}
|
77
|
|
- \ Log ${username}
|
|
71
|
+ ${USERS}= load_data_from ${file_path}
|
|
72
|
+ Log ${USERS.users}
|
|
73
|
+ Set Suite Variable ${USERS}
|
|
74
|
+ # List of currently used users
|
|
75
|
+ ${used_users}= Create List
|
|
76
|
+
|
|
77
|
+ # Handle `-v role:something`
|
|
78
|
+ Run Keyword Unless '${role}' in @{used_roles}
|
|
79
|
+ ... Log
|
|
80
|
+ ... Role ${role} is not used in this test suite.
|
|
81
|
+ ... WARN
|
|
82
|
+ Set Suite Variable With Default Value
|
|
83
|
+ ... ${role}
|
|
84
|
+ ... ${BROKERS['${broker}'].roles.${role}}
|
|
85
|
+
|
|
86
|
+ # Set default value for each role if it is not set yet;
|
|
87
|
+ # fill `used_users`;
|
|
88
|
+ # fill `used_brokers`.
|
|
89
|
+ #
|
|
90
|
+ # Don't even ask how this works!
|
|
91
|
+ :FOR ${tmp_role} IN @{used_roles}
|
|
92
|
+ \ Set Suite Variable With Default Value
|
|
93
|
+ \ ... ${tmp_role}
|
|
94
|
+ \ ... ${BROKERS['Quinta'].roles.${tmp_role}}
|
|
95
|
+ \ Append To List ${used_users} ${${tmp_role}}
|
|
96
|
+ \ Append To List ${used_brokers} ${USERS.users.${${tmp_role}}.broker}
|
|
97
|
+ # Since `@{used_roles}` is already a suite variable,
|
|
98
|
+ # let's make `@{used_brokers}` alike.
|
|
99
|
+ ${used_brokers}= Remove Duplicates ${used_brokers}
|
|
100
|
+ Set Suite Variable ${used_brokers}
|
|
101
|
+ # We need to create two lists since Robot Framework doesn't support
|
|
102
|
+ # dicts in `:FOR` loops.
|
|
103
|
+ Log Many @{used_users}
|
|
104
|
+ Log Many @{used_brokers}
|
|
105
|
+
|
|
106
|
+ # A list of all users in users file
|
|
107
|
+ ${known_users}= Get Dictionary Keys ${USERS.users}
|
|
108
|
+
|
|
109
|
+ # Check whether users file contains an entry for each
|
|
110
|
+ # selected user before preparing any clients
|
|
111
|
+ :FOR ${username} IN @{used_users}
|
|
112
|
+ \ List Should Contain Value
|
|
113
|
+ \ ... ${known_users}
|
|
114
|
+ \ ... ${username}
|
|
115
|
+ \ ... msg=User ${username} not found in users file!
|
|
116
|
+
|
|
117
|
+ # Prepare a client for each user
|
|
118
|
+ :FOR ${username} IN @{used_users}
|
78
|
119
|
\ ${munch_dict}= munch_dict data=${True}
|
79
|
|
- \ Log Many ${munch_dict}
|
80
|
|
- \ ${status}= Run Keyword And Return Status Dictionary Should Contain Value ${active_users} ${username}
|
81
|
|
- \ ${keywords_file}= Get Broker Property By Username ${username} keywords_file
|
82
|
|
- \ Run Keyword If ${status} Завантажуємо бібліотеку з реалізацією для майданчика ${keywords_file}
|
83
|
|
- \ Run Keyword If ${status} Викликати для учасника ${username} Підготувати клієнт для користувача
|
84
|
|
- \ Run Keyword If ${status} Set To Dictionary ${USERS.users['${username}']} tender_data=${munch_dict}
|
|
120
|
+ \ ${keywords_file}= Get Broker Property ${USERS.users.${username}.broker} keywords_file
|
|
121
|
+ \ Завантажуємо бібліотеку з реалізацією для майданчика ${keywords_file}
|
|
122
|
+ \ Run As ${username} Підготувати клієнт для користувача
|
85
|
123
|
\ ${LAST_REFRESH_DATE}= Get Current TZdate
|
86
|
|
- \ Set To Dictionary ${USERS.users['${username}']} LAST_REFRESH_DATE ${LAST_REFRESH_DATE}
|
|
124
|
+ \ Set To Dictionary ${USERS} ${username}=${USERS.users.${username}}
|
|
125
|
+ \ Set To Dictionary ${USERS.${username}} tender_data=${munch_dict}
|
|
126
|
+ \ Set To Dictionary ${USERS.${username}} LAST_REFRESH_DATE ${LAST_REFRESH_DATE}
|
|
127
|
+
|
|
128
|
+ # Drop all unused users
|
|
129
|
+ Keep In Dictionary ${USERS.users} @{used_users}
|
|
130
|
+ Log Many @{USERS}
|
87
|
131
|
|
88
|
132
|
|
89
|
133
|
Get Broker Property
|
...
|
...
|
@@ -92,11 +136,9 @@ Get Broker Property |
92
|
136
|
... This keyword returns a property of specified broker
|
93
|
137
|
... if that property exists, otherwise, it returns a
|
94
|
138
|
... default value.
|
95
|
|
- ${status}= Run Keyword And Return Status Should Contain ${BROKERS['${broker_name}']} ${property}
|
96
|
|
- Return From Keyword If ${status} ${BROKERS['${broker_name}'].${property}}
|
97
|
|
- # If broker doesn't have that property, fall back to default value
|
98
|
|
- Should Contain ${BROKERS['Default']} ${property}
|
99
|
|
- [return] ${BROKERS['Default'].${property}}
|
|
139
|
+ Run Keyword If '${broker_name}'=='${None}' Fail \${broker_name} is NoneType
|
|
140
|
+ Should Contain ${BROKERS['${broker_name}']} ${property}
|
|
141
|
+ Return From Keyword ${BROKERS['${broker_name}'].${property}}
|
100
|
142
|
|
101
|
143
|
|
102
|
144
|
Get Broker Property By Username
|
...
|
...
|
@@ -126,7 +168,7 @@ Get Broker Property By Username |
126
|
168
|
|
127
|
169
|
Завантажити дані про тендер
|
128
|
170
|
${file_path}= Get Variable Value ${ARTIFACT_FILE} artifact.yaml
|
129
|
|
- ${ARTIFACT}= load_initial_data_from ${file_path}
|
|
171
|
+ ${ARTIFACT}= load_data_from ${file_path}
|
130
|
172
|
Run Keyword If '${USERS.users['${tender_owner}'].broker}' == 'Quinta'
|
131
|
173
|
... Set To Dictionary ${USERS.users['${tender_owner}']} access_token=${ARTIFACT.access_token}
|
132
|
174
|
${TENDER}= Create Dictionary
|
...
|
...
|
@@ -137,9 +179,7 @@ Get Broker Property By Username |
137
|
179
|
|
138
|
180
|
|
139
|
181
|
Підготовка даних для створення тендера
|
140
|
|
- ${custom_intervals}= Get Broker Property By Username ${tender_owner} intervals
|
141
|
|
- ${default_intervals}= Get Broker Property Default intervals
|
142
|
|
- ${period_intervals}= merge_dicts ${default_intervals} ${custom_intervals}
|
|
182
|
+ ${period_intervals}= compute_intrs ${BROKERS} ${used_brokers}
|
143
|
183
|
${tender_data}= prepare_test_tender_data ${period_intervals} ${mode}
|
144
|
184
|
${TENDER}= Create Dictionary
|
145
|
185
|
Set Global Variable ${TENDER}
|
...
|
...
|
|