Commit 92a01eee7c5206192a3605d921abfff5b37e10eb
Committed by
mykhaly
1 parent
b3d83111
Add/update ability to work with meat features
Replace `intervals`, `number_of_items`, `number_of_lots` and `meat` with `params` in arguments of corresponding functions/keywords Add test_feature_data function
Showing
5 changed files
with
87 additions
and
62 deletions
... | ... | @@ -9,8 +9,17 @@ Resource resource.robot |
9 | 9 | Можливість оголосити тендер |
10 | 10 | ${number_of_lots}= Convert To Integer ${number_of_lots} |
11 | 11 | ${number_of_items}= Convert To Integer ${number_of_items} |
12 | - ${meat}= Convert To Integer ${meat} | |
13 | - ${tender_data}= Підготувати дані для створення тендера ${number_of_items} ${number_of_lots} ${meat} | |
12 | + ${tender_meat}= Convert To Integer ${tender_meat} | |
13 | + ${lot_meat}= Convert To Integer ${lot_meat} | |
14 | + ${item_meat}= Convert To Integer ${item_meat} | |
15 | + ${tender_parameters}= Create Dictionary | |
16 | + ... mode=${mode} | |
17 | + ... number_of_items=${number_of_items} | |
18 | + ... number_of_lots=${number_of_lots} | |
19 | + ... tender_meat=${tender_meat} | |
20 | + ... lot_meat=${lot_meat} | |
21 | + ... item_meat=${item_meat} | |
22 | + ${tender_data}= Підготувати дані для створення тендера ${tender_parameters} | |
14 | 23 | ${adapted_data}= Адаптувати дані для оголошення тендера ${tender_owner} ${tender_data} |
15 | 24 | ${TENDER_UAID}= Run As ${tender_owner} Створити тендер ${adapted_data} |
16 | 25 | Set To Dictionary ${USERS.users['${tender_owner}']} initial_data=${adapted_data} | ... | ... |
... | ... | @@ -47,7 +47,7 @@ def create_fake_doc(): |
47 | 47 | return tf.name |
48 | 48 | |
49 | 49 | |
50 | -def test_tender_data(intervals, periods=("enquiry", "tender"), number_of_items=1, number_of_lots=0, meat=False): | |
50 | +def test_tender_data(params, periods=("enquiry", "tender")): | |
51 | 51 | now = get_now() |
52 | 52 | value_amount = round(random.uniform(3000, 99999999999.99), 2) # max value equals to budget of Ukraine in hryvnias |
53 | 53 | data = { |
... | ... | @@ -69,7 +69,8 @@ def test_tender_data(intervals, periods=("enquiry", "tender"), number_of_items=1 |
69 | 69 | "amount": round(random.uniform(0.005, 0.03) * value_amount, 2), |
70 | 70 | "currency": u"UAH" |
71 | 71 | }, |
72 | - "items": [] | |
72 | + "items": [], | |
73 | + "features": [] | |
73 | 74 | } |
74 | 75 | data["procuringEntity"]["kind"] = "other" |
75 | 76 | if data.get("mode") == "test": |
... | ... | @@ -81,19 +82,18 @@ def test_tender_data(intervals, periods=("enquiry", "tender"), number_of_items=1 |
81 | 82 | for period_name in periods: |
82 | 83 | period_dict[period_name + "Period"] = {} |
83 | 84 | for i, j in zip(range(2), ("start", "end")): |
84 | - inc_dt += timedelta(minutes=intervals[period_name][i]) | |
85 | + inc_dt += timedelta(minutes=params['intervals'][period_name][i]) | |
85 | 86 | period_dict[period_name + "Period"][j + "Date"] = inc_dt.isoformat() |
86 | 87 | data.update(period_dict) |
87 | - number_of_lots = int(number_of_lots) | |
88 | 88 | cpv_group = fake.cpv()[:3] |
89 | - if number_of_lots: | |
89 | + if params['number_of_lots']: | |
90 | 90 | data['lots'] = [] |
91 | - for lot_number in range(number_of_lots): | |
91 | + for lot_number in range(params['number_of_lots']): | |
92 | 92 | lot_id = uuid4().hex |
93 | 93 | new_lot = test_lot_data(data['value']['amount']) |
94 | 94 | data['lots'].append(new_lot) |
95 | 95 | data['lots'][lot_number]['id'] = lot_id |
96 | - for i in range(number_of_items): | |
96 | + for i in range(params['number_of_items']): | |
97 | 97 | new_item = test_item_data(cpv_group) |
98 | 98 | data['items'].append(new_item) |
99 | 99 | data['items'][lot_number]['relatedLot'] = lot_id |
... | ... | @@ -102,48 +102,37 @@ def test_tender_data(intervals, periods=("enquiry", "tender"), number_of_items=1 |
102 | 102 | data['value']['amount'] = value_amount |
103 | 103 | data['minimalStep']['amount'] = minimalStep |
104 | 104 | else: |
105 | - for i in range(number_of_items): | |
105 | + for i in range(params['number_of_items']): | |
106 | 106 | new_item = test_item_data(cpv_group) |
107 | 107 | data['items'].append(new_item) |
108 | - if meat: | |
109 | - data['features'] = [ | |
110 | - { | |
111 | - "code": uuid4().hex, | |
112 | - "featureOf": "tenderer", | |
113 | - "title": field_with_id("f", fake.title()), | |
114 | - "description": fake.description(), | |
115 | - "enum": [ | |
116 | - { | |
117 | - "value": 0.15, | |
118 | - "title": fake.word() | |
119 | - }, | |
120 | - { | |
121 | - "value": 0.10, | |
122 | - "title": fake.word() | |
123 | - }, | |
124 | - { | |
125 | - "value": 0.05, | |
126 | - "title": fake.word() | |
127 | - }, | |
128 | - { | |
129 | - "value": 0, | |
130 | - "title": fake.word() | |
131 | - } | |
132 | - ] | |
133 | - } | |
134 | - ] | |
108 | + if params['tender_meat']: | |
109 | + new_feature = test_feature_data() | |
110 | + new_feature.featureOf = "tenderer" | |
111 | + data['features'].append(new_feature) | |
112 | + if params['lot_meat'] and params['number_of_lots']: | |
113 | + new_feature = test_feature_data() | |
114 | + new_feature['featureOf'] = "lot" | |
115 | + data['lots'][0]['id'] = data['lots'][0].get('id', uuid4().hex) | |
116 | + new_feature['relatedItem'] = data['lots'][0]['id'] | |
117 | + data['features'].append(new_feature) | |
118 | + if params['item_meat'] and params['number_of_items']: | |
119 | + new_feature = test_feature_data() | |
120 | + new_feature['featureOf'] = "item" | |
121 | + data['items'][0]['id'] = data['items'][0].get('id', uuid4().hex) | |
122 | + new_feature['relatedItem'] = data['items'][0]['id'] | |
123 | + data['features'].append(new_feature) | |
135 | 124 | return munchify(data) |
136 | 125 | |
137 | 126 | |
138 | -def test_tender_data_limited(intervals, procurement_method_type): | |
139 | - data = test_tender_data(intervals) | |
127 | +def test_tender_data_limited(params): | |
128 | + data = test_tender_data(params) | |
140 | 129 | del data["submissionMethodDetails"] |
141 | 130 | del data["minimalStep"] |
142 | 131 | del data["enquiryPeriod"] |
143 | 132 | del data["tenderPeriod"] |
144 | 133 | data["procuringEntity"]["kind"] = "general" |
145 | - data.update({"procurementMethodType": procurement_method_type, "procurementMethod": "limited"}) | |
146 | - if procurement_method_type == "negotiation": | |
134 | + data.update({"procurementMethodType": params['mode'], "procurementMethod": "limited"}) | |
135 | + if params['mode'] == "negotiation": | |
147 | 136 | cause_variants = ( |
148 | 137 | "artContestIP", |
149 | 138 | "noCompetition", |
... | ... | @@ -154,11 +143,11 @@ def test_tender_data_limited(intervals, procurement_method_type): |
154 | 143 | ) |
155 | 144 | cause = fake.random_element(cause_variants) |
156 | 145 | data.update({"cause": cause}) |
157 | - if procurement_method_type == "negotiation.quick": | |
146 | + if params['mode'] == "negotiation.quick": | |
158 | 147 | cause_variants = ('quick',) |
159 | 148 | cause = fake.random_element(cause_variants) |
160 | 149 | data.update({"cause": cause}) |
161 | - if procurement_method_type in ("negotiation", "negotiation.quick"): | |
150 | + if params['mode'] in ("negotiation", "negotiation.quick"): | |
162 | 151 | data.update({ |
163 | 152 | "procurementMethodDetails": "quick, accelerator=1440", |
164 | 153 | "causeDescription": fake.description() |
... | ... | @@ -166,6 +155,28 @@ def test_tender_data_limited(intervals, procurement_method_type): |
166 | 155 | return munchify(data) |
167 | 156 | |
168 | 157 | |
158 | +def test_feature_data(): | |
159 | + return munchify({ | |
160 | + "code": uuid4().hex, | |
161 | + "title": field_with_id("f", fake.title()), | |
162 | + "description": fake.description(), | |
163 | + "enum": [ | |
164 | + { | |
165 | + "value": 0.05, | |
166 | + "title": fake.word() | |
167 | + }, | |
168 | + { | |
169 | + "value": 0.01, | |
170 | + "title": fake.word() | |
171 | + }, | |
172 | + { | |
173 | + "value": 0, | |
174 | + "title": fake.word() | |
175 | + } | |
176 | + ] | |
177 | + }) | |
178 | + | |
179 | + | |
169 | 180 | def test_question_data(): |
170 | 181 | return munchify({ |
171 | 182 | "data": { |
... | ... | @@ -341,15 +352,15 @@ def test_lot_complaint_data(complaint, lot_id): |
341 | 352 | return munchify(complaint) |
342 | 353 | |
343 | 354 | |
344 | -def test_tender_data_openua(intervals, number_of_items, number_of_lots, meat): | |
345 | - accelerator = intervals['accelerator'] | |
355 | +def test_tender_data_openua(params): | |
356 | + accelerator = params['intervals']['accelerator'] | |
346 | 357 | # Since `accelerator` field is not really a list containing timings |
347 | 358 | # for a period called `acceleratorPeriod`, let's remove it :) |
348 | - del intervals['accelerator'] | |
359 | + del params['intervals']['accelerator'] | |
349 | 360 | # We should not provide any values for `enquiryPeriod` when creating |
350 | 361 | # an openUA or openEU procedure. That field should not be present at all. |
351 | 362 | # Therefore, we pass a nondefault list of periods to `test_tender_data()`. |
352 | - data = test_tender_data(intervals, ('tender',), number_of_items, number_of_lots, meat) | |
363 | + data = test_tender_data(params, ('tender',)) | |
353 | 364 | data['procurementMethodType'] = 'aboveThresholdUA' |
354 | 365 | data['procurementMethodDetails'] = 'quick, ' \ |
355 | 366 | 'accelerator={}'.format(accelerator) |
... | ... | @@ -357,15 +368,15 @@ def test_tender_data_openua(intervals, number_of_items, number_of_lots, meat): |
357 | 368 | return data |
358 | 369 | |
359 | 370 | |
360 | -def test_tender_data_openeu(intervals, number_of_items, number_of_lots, meat): | |
361 | - accelerator = intervals['accelerator'] | |
371 | +def test_tender_data_openeu(params): | |
372 | + accelerator = params['intervals']['accelerator'] | |
362 | 373 | # Since `accelerator` field is not really a list containing timings |
363 | 374 | # for a period called `acceleratorPeriod`, let's remove it :) |
364 | - del intervals['accelerator'] | |
375 | + del params['intervals']['accelerator'] | |
365 | 376 | # We should not provide any values for `enquiryPeriod` when creating |
366 | 377 | # an openUA or openEU procedure. That field should not be present at all. |
367 | 378 | # Therefore, we pass a nondefault list of periods to `test_tender_data()`. |
368 | - data = test_tender_data(intervals, ('tender',), number_of_items, number_of_lots, meat) | |
379 | + data = test_tender_data(params, ('tender',)) | |
369 | 380 | data['procurementMethodType'] = 'aboveThresholdEU' |
370 | 381 | data['procurementMethodDetails'] = 'quick, ' \ |
371 | 382 | 'accelerator={}'.format(accelerator) | ... | ... |
... | ... | @@ -197,9 +197,9 @@ Get Broker Property By Username |
197 | 197 | |
198 | 198 | |
199 | 199 | Підготувати дані для створення тендера |
200 | - [Arguments] ${number_of_items}=1 ${number_of_lots}=0 ${meat}=${False} | |
200 | + [Arguments] ${tender_parameters} | |
201 | 201 | ${period_intervals}= compute_intrs ${BROKERS} ${used_brokers} |
202 | - ${tender_data}= prepare_test_tender_data ${period_intervals} ${mode} ${number_of_items} ${number_of_lots} ${meat} | |
202 | + ${tender_data}= prepare_test_tender_data ${period_intervals} ${tender_parameters} | |
203 | 203 | ${TENDER}= Create Dictionary |
204 | 204 | Set Global Variable ${TENDER} |
205 | 205 | Log ${tender_data} | ... | ... |
... | ... | @@ -258,13 +258,15 @@ def compute_intrs(brokers_data, used_brokers): |
258 | 258 | return result |
259 | 259 | |
260 | 260 | |
261 | -def prepare_test_tender_data(procedure_intervals, mode, number_of_items=1, number_of_lots=0, meat=False): | |
261 | +def prepare_test_tender_data(procedure_intervals, tender_parameters): | |
262 | 262 | # Get actual intervals by mode name |
263 | + mode = tender_parameters['mode'] | |
263 | 264 | if mode in procedure_intervals: |
264 | 265 | intervals = procedure_intervals[mode] |
265 | 266 | else: |
266 | 267 | intervals = procedure_intervals['default'] |
267 | 268 | LOGGER.log_message(Message(intervals)) |
269 | + tender_parameters['intervals'] = intervals | |
268 | 270 | |
269 | 271 | # Set acceleration value for certain modes |
270 | 272 | if mode in ['openua', 'openeu']: |
... | ... | @@ -276,18 +278,19 @@ def prepare_test_tender_data(procedure_intervals, mode, number_of_items=1, numbe |
276 | 278 | else: |
277 | 279 | assert 'accelerator' not in intervals.keys(), \ |
278 | 280 | "Accelerator is not available for mode '{0}'".format(mode) |
281 | + | |
279 | 282 | if mode == 'negotiation': |
280 | - return munchify({'data': test_tender_data_limited(intervals, 'negotiation')}) | |
283 | + return munchify({'data': test_tender_data_limited(tender_parameters)}) | |
281 | 284 | elif mode == 'negotiation.quick': |
282 | - return munchify({'data': test_tender_data_limited(intervals, 'negotiation.quick')}) | |
285 | + return munchify({'data': test_tender_data_limited(tender_parameters)}) | |
283 | 286 | elif mode == 'openeu': |
284 | - return munchify({'data': test_tender_data_openeu(intervals, number_of_items, number_of_lots, meat)}) | |
287 | + return munchify({'data': test_tender_data_openeu(tender_parameters)}) | |
285 | 288 | elif mode == 'openua': |
286 | - return munchify({'data': test_tender_data_openua(intervals, number_of_items, number_of_lots, meat)}) | |
289 | + return munchify({'data': test_tender_data_openua(tender_parameters)}) | |
287 | 290 | elif mode == 'reporting': |
288 | - return munchify({'data': test_tender_data_limited(intervals, 'reporting')}) | |
291 | + return munchify({'data': test_tender_data_limited(tender_parameters)}) | |
289 | 292 | elif mode == 'belowThreshold': |
290 | - return munchify({'data': test_tender_data(intervals, number_of_items=number_of_items, number_of_lots=number_of_lots, meat=meat)}) | |
293 | + return munchify({'data': test_tender_data(tender_parameters)}) | |
291 | 294 | raise ValueError("Invalid mode for prepare_test_tender_data") |
292 | 295 | |
293 | 296 | |
... | ... | @@ -456,7 +459,7 @@ def generate_test_bid_data(tender_data): |
456 | 459 | if 'features' in tender_data: |
457 | 460 | bid.data.parameters = [] |
458 | 461 | for feature in tender_data['features']: |
459 | - parameter = {"value": fake.random_element(elements=(0.15, 0.1, 0.05, 0)), "code": feature.get('code', '')} | |
462 | + parameter = {"value": fake.random_element(elements=(0.05, 0.01, 0)), "code": feature.get('code', '')} | |
460 | 463 | bid.data.parameters.append(parameter) |
461 | 464 | return bid |
462 | 465 | ... | ... |
Please
register
or
login
to post a comment