Commit 4e4f59ffdc4951357dedbf3b330da870a2e7d2d3
Merge pull request #500 from selurvedu/submissionMethodDetails
New variable for submissionMethodDetails
Showing
3 changed files
with
38 additions
and
26 deletions
1 | # -*- coding: utf-8 - | 1 | # -*- coding: utf-8 - |
2 | +import os | ||
3 | +import random | ||
2 | from datetime import timedelta | 4 | from datetime import timedelta |
5 | +from tempfile import NamedTemporaryFile | ||
6 | +from uuid import uuid4 | ||
3 | from faker import Factory | 7 | from faker import Factory |
4 | from faker.providers.company.en_US import Provider as CompanyProviderEnUs | 8 | from faker.providers.company.en_US import Provider as CompanyProviderEnUs |
5 | from faker.providers.company.ru_RU import Provider as CompanyProviderRuRu | 9 | from faker.providers.company.ru_RU import Provider as CompanyProviderRuRu |
6 | from munch import munchify | 10 | from munch import munchify |
7 | -from uuid import uuid4 | ||
8 | -from tempfile import NamedTemporaryFile | ||
9 | -from .local_time import get_now | ||
10 | from op_faker import OP_Provider | 11 | from op_faker import OP_Provider |
11 | -import os | ||
12 | -import random | 12 | +from .local_time import get_now |
13 | 13 | ||
14 | 14 | ||
15 | fake_en = Factory.create(locale='en_US') | 15 | fake_en = Factory.create(locale='en_US') |
@@ -56,12 +56,16 @@ def create_fake_doc(): | @@ -56,12 +56,16 @@ def create_fake_doc(): | ||
56 | return tf.name.replace('\\', '\\\\'), os.path.basename(tf.name), content | 56 | return tf.name.replace('\\', '\\\\'), os.path.basename(tf.name), content |
57 | 57 | ||
58 | 58 | ||
59 | -def test_tender_data(params, periods=("enquiry", "tender")): | 59 | +def test_tender_data(params, |
60 | + periods=("enquiry", "tender"), | ||
61 | + submissionMethodDetails=None): | ||
62 | + submissionMethodDetails = submissionMethodDetails \ | ||
63 | + if submissionMethodDetails else "quick" | ||
60 | now = get_now() | 64 | now = get_now() |
61 | value_amount = round(random.uniform(3000, 99999999999.99), 2) # max value equals to budget of Ukraine in hryvnias | 65 | value_amount = round(random.uniform(3000, 99999999999.99), 2) # max value equals to budget of Ukraine in hryvnias |
62 | data = { | 66 | data = { |
63 | "mode": "test", | 67 | "mode": "test", |
64 | - "submissionMethodDetails": "quick", | 68 | + "submissionMethodDetails": submissionMethodDetails, |
65 | "description": fake.description(), | 69 | "description": fake.description(), |
66 | "description_en": fake_en.sentence(nb_words=10, variable_nb_words=True), | 70 | "description_en": fake_en.sentence(nb_words=10, variable_nb_words=True), |
67 | "description_ru": fake_ru.sentence(nb_words=10, variable_nb_words=True), | 71 | "description_ru": fake_ru.sentence(nb_words=10, variable_nb_words=True), |
@@ -116,7 +120,7 @@ def test_tender_data(params, periods=("enquiry", "tender")): | @@ -116,7 +120,7 @@ def test_tender_data(params, periods=("enquiry", "tender")): | ||
116 | if params.get('lot_meat'): | 120 | if params.get('lot_meat'): |
117 | new_feature = test_feature_data() | 121 | new_feature = test_feature_data() |
118 | new_feature['featureOf'] = "lot" | 122 | new_feature['featureOf'] = "lot" |
119 | - data['lots'][0]['id'] = data['lots'][0].get('id', uuid4().hex) | 123 | + data['lots'][0]['id'] = data['lots'][0].get('id', uuid4().hex) |
120 | new_feature['relatedItem'] = data['lots'][0]['id'] | 124 | new_feature['relatedItem'] = data['lots'][0]['id'] |
121 | data['features'].append(new_feature) | 125 | data['features'].append(new_feature) |
122 | else: | 126 | else: |
@@ -130,7 +134,7 @@ def test_tender_data(params, periods=("enquiry", "tender")): | @@ -130,7 +134,7 @@ def test_tender_data(params, periods=("enquiry", "tender")): | ||
130 | if params.get('item_meat'): | 134 | if params.get('item_meat'): |
131 | new_feature = test_feature_data() | 135 | new_feature = test_feature_data() |
132 | new_feature['featureOf'] = "item" | 136 | new_feature['featureOf'] = "item" |
133 | - data['items'][0]['id'] = data['items'][0].get('id', uuid4().hex) | 137 | + data['items'][0]['id'] = data['items'][0].get('id', uuid4().hex) |
134 | new_feature['relatedItem'] = data['items'][0]['id'] | 138 | new_feature['relatedItem'] = data['items'][0]['id'] |
135 | data['features'].append(new_feature) | 139 | data['features'].append(new_feature) |
136 | if not data['features']: | 140 | if not data['features']: |
@@ -315,9 +319,9 @@ def test_item_data(cpv=None): | @@ -315,9 +319,9 @@ def test_item_data(cpv=None): | ||
315 | data["description_ru"] = field_with_id("i", data["description_ru"]) | 319 | data["description_ru"] = field_with_id("i", data["description_ru"]) |
316 | days = fake.random_int(min=1, max=30) | 320 | days = fake.random_int(min=1, max=30) |
317 | data["deliveryDate"] = { | 321 | data["deliveryDate"] = { |
318 | - "startDate":(get_now() + timedelta(days=days)).isoformat(), | ||
319 | - "endDate":(get_now() + timedelta(days=days)).isoformat() | ||
320 | - } | 322 | + "startDate": (get_now() + timedelta(days=days)).isoformat(), |
323 | + "endDate": (get_now() + timedelta(days=days)).isoformat() | ||
324 | + } | ||
321 | data["deliveryAddress"]["countryName_en"] = translate_country_en(data["deliveryAddress"]["countryName"]) | 325 | data["deliveryAddress"]["countryName_en"] = translate_country_en(data["deliveryAddress"]["countryName"]) |
322 | data["deliveryAddress"]["countryName_ru"] = translate_country_ru(data["deliveryAddress"]["countryName"]) | 326 | data["deliveryAddress"]["countryName_ru"] = translate_country_ru(data["deliveryAddress"]["countryName"]) |
323 | return munchify(data) | 327 | return munchify(data) |
@@ -371,22 +375,21 @@ def test_lot_document_data(document, lot_id): | @@ -371,22 +375,21 @@ def test_lot_document_data(document, lot_id): | ||
371 | return munchify(document) | 375 | return munchify(document) |
372 | 376 | ||
373 | 377 | ||
374 | - | ||
375 | -def test_tender_data_openua(params): | 378 | +def test_tender_data_openua(params, submissionMethodDetails): |
376 | # We should not provide any values for `enquiryPeriod` when creating | 379 | # We should not provide any values for `enquiryPeriod` when creating |
377 | # an openUA or openEU procedure. That field should not be present at all. | 380 | # an openUA or openEU procedure. That field should not be present at all. |
378 | # Therefore, we pass a nondefault list of periods to `test_tender_data()`. | 381 | # Therefore, we pass a nondefault list of periods to `test_tender_data()`. |
379 | - data = test_tender_data(params, ('tender',)) | 382 | + data = test_tender_data(params, ('tender',), submissionMethodDetails) |
380 | data['procurementMethodType'] = 'aboveThresholdUA' | 383 | data['procurementMethodType'] = 'aboveThresholdUA' |
381 | data['procuringEntity']['kind'] = 'general' | 384 | data['procuringEntity']['kind'] = 'general' |
382 | return data | 385 | return data |
383 | 386 | ||
384 | 387 | ||
385 | -def test_tender_data_openeu(params): | 388 | +def test_tender_data_openeu(params, submissionMethodDetails): |
386 | # We should not provide any values for `enquiryPeriod` when creating | 389 | # We should not provide any values for `enquiryPeriod` when creating |
387 | # an openUA or openEU procedure. That field should not be present at all. | 390 | # an openUA or openEU procedure. That field should not be present at all. |
388 | # Therefore, we pass a nondefault list of periods to `test_tender_data()`. | 391 | # Therefore, we pass a nondefault list of periods to `test_tender_data()`. |
389 | - data = test_tender_data(params, ('tender',)) | 392 | + data = test_tender_data(params, ('tender',), submissionMethodDetails) |
390 | data['procurementMethodType'] = 'aboveThresholdEU' | 393 | data['procurementMethodType'] = 'aboveThresholdEU' |
391 | data['title_en'] = "[TESTING]" | 394 | data['title_en'] = "[TESTING]" |
392 | for item_number, item in enumerate(data['items']): | 395 | for item_number, item in enumerate(data['items']): |
@@ -399,11 +402,11 @@ def test_tender_data_openeu(params): | @@ -399,11 +402,11 @@ def test_tender_data_openeu(params): | ||
399 | return data | 402 | return data |
400 | 403 | ||
401 | 404 | ||
402 | -def test_tender_data_competitive_dialogue(params): | 405 | +def test_tender_data_competitive_dialogue(params, submissionMethodDetails): |
403 | # We should not provide any values for `enquiryPeriod` when creating | 406 | # We should not provide any values for `enquiryPeriod` when creating |
404 | # an openUA or openEU procedure. That field should not be present at all. | 407 | # an openUA or openEU procedure. That field should not be present at all. |
405 | # Therefore, we pass a nondefault list of periods to `test_tender_data()`. | 408 | # Therefore, we pass a nondefault list of periods to `test_tender_data()`. |
406 | - data = test_tender_data(params, ('tender',)) | 409 | + data = test_tender_data(params, ('tender',), submissionMethodDetails) |
407 | if params.get('dialogue_type') == 'UA': | 410 | if params.get('dialogue_type') == 'UA': |
408 | data['procurementMethodType'] = 'competitiveDialogueUA' | 411 | data['procurementMethodType'] = 'competitiveDialogueUA' |
409 | else: | 412 | else: |
@@ -204,7 +204,8 @@ Get Broker Property By Username | @@ -204,7 +204,8 @@ Get Broker Property By Username | ||
204 | Підготувати дані для створення тендера | 204 | Підготувати дані для створення тендера |
205 | [Arguments] ${tender_parameters} | 205 | [Arguments] ${tender_parameters} |
206 | ${period_intervals}= compute_intrs ${BROKERS} ${used_brokers} | 206 | ${period_intervals}= compute_intrs ${BROKERS} ${used_brokers} |
207 | - ${tender_data}= prepare_test_tender_data ${period_intervals} ${tender_parameters} | 207 | + ${submissionMethodDetails}= Get Variable Value ${submissionMethodDetails} |
208 | + ${tender_data}= prepare_test_tender_data ${period_intervals} ${tender_parameters} ${submissionMethodDetails} | ||
208 | ${TENDER}= Create Dictionary | 209 | ${TENDER}= Create Dictionary |
209 | Set Global Variable ${TENDER} | 210 | Set Global Variable ${TENDER} |
210 | Log ${tender_data} | 211 | Log ${tender_data} |
@@ -6,7 +6,6 @@ from datetime import timedelta | @@ -6,7 +6,6 @@ from datetime import timedelta | ||
6 | from dateutil.parser import parse | 6 | from dateutil.parser import parse |
7 | from dpath.util import new as xpathnew | 7 | from dpath.util import new as xpathnew |
8 | from haversine import haversine | 8 | from haversine import haversine |
9 | -from iso8601 import parse_date | ||
10 | from json import load, loads | 9 | from json import load, loads |
11 | from jsonpath_rw import parse as parse_path | 10 | from jsonpath_rw import parse as parse_path |
12 | from munch import Munch, munchify | 11 | from munch import Munch, munchify |
@@ -275,7 +274,9 @@ def compute_intrs(brokers_data, used_brokers): | @@ -275,7 +274,9 @@ def compute_intrs(brokers_data, used_brokers): | ||
275 | return result | 274 | return result |
276 | 275 | ||
277 | 276 | ||
278 | -def prepare_test_tender_data(procedure_intervals, tender_parameters): | 277 | +def prepare_test_tender_data(procedure_intervals, |
278 | + tender_parameters, | ||
279 | + submissionMethodDetails): | ||
279 | # Get actual intervals by mode name | 280 | # Get actual intervals by mode name |
280 | mode = tender_parameters['mode'] | 281 | mode = tender_parameters['mode'] |
281 | if mode in procedure_intervals: | 282 | if mode in procedure_intervals: |
@@ -296,15 +297,22 @@ def prepare_test_tender_data(procedure_intervals, tender_parameters): | @@ -296,15 +297,22 @@ def prepare_test_tender_data(procedure_intervals, tender_parameters): | ||
296 | elif mode == 'negotiation.quick': | 297 | elif mode == 'negotiation.quick': |
297 | return munchify({'data': test_tender_data_limited(tender_parameters)}) | 298 | return munchify({'data': test_tender_data_limited(tender_parameters)}) |
298 | elif mode == 'openeu': | 299 | elif mode == 'openeu': |
299 | - return munchify({'data': test_tender_data_openeu(tender_parameters)}) | 300 | + return munchify({'data': test_tender_data_openeu( |
301 | + tender_parameters, submissionMethodDetails)}) | ||
300 | elif mode == 'openua': | 302 | elif mode == 'openua': |
301 | - return munchify({'data': test_tender_data_openua(tender_parameters)}) | 303 | + return munchify({'data': test_tender_data_openua( |
304 | + tender_parameters, submissionMethodDetails)}) | ||
302 | elif mode == 'open_competitive_dialogue': | 305 | elif mode == 'open_competitive_dialogue': |
303 | - return munchify({'data': test_tender_data_competitive_dialogue(tender_parameters)}) | 306 | + return munchify({'data': test_tender_data_competitive_dialogue( |
307 | + tender_parameters, submissionMethodDetails)}) | ||
304 | elif mode == 'reporting': | 308 | elif mode == 'reporting': |
305 | return munchify({'data': test_tender_data_limited(tender_parameters)}) | 309 | return munchify({'data': test_tender_data_limited(tender_parameters)}) |
306 | elif mode == 'belowThreshold': | 310 | elif mode == 'belowThreshold': |
307 | - return munchify({'data': test_tender_data(tender_parameters)}) | 311 | + return munchify({'data': test_tender_data( |
312 | + tender_parameters, | ||
313 | + submissionMethodDetails=submissionMethodDetails)}) | ||
314 | + # The previous line needs an explicit keyword argument because, | ||
315 | + # unlike previous functions, this one has three arguments. | ||
308 | raise ValueError("Invalid mode for prepare_test_tender_data") | 316 | raise ValueError("Invalid mode for prepare_test_tender_data") |
309 | 317 | ||
310 | 318 |
Please
register
or
login
to post a comment