Commit 4e4f59ffdc4951357dedbf3b330da870a2e7d2d3

Authored by selurvedu
2 parents c6648759 15779a26

Merge pull request #500 from selurvedu/submissionMethodDetails

New variable for submissionMethodDetails
1 1 # -*- coding: utf-8 -
  2 +import os
  3 +import random
2 4 from datetime import timedelta
  5 +from tempfile import NamedTemporaryFile
  6 +from uuid import uuid4
3 7 from faker import Factory
4 8 from faker.providers.company.en_US import Provider as CompanyProviderEnUs
5 9 from faker.providers.company.ru_RU import Provider as CompanyProviderRuRu
6 10 from munch import munchify
7   -from uuid import uuid4
8   -from tempfile import NamedTemporaryFile
9   -from .local_time import get_now
10 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 15 fake_en = Factory.create(locale='en_US')
... ... @@ -56,12 +56,16 @@ def create_fake_doc():
56 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 64 now = get_now()
61 65 value_amount = round(random.uniform(3000, 99999999999.99), 2) # max value equals to budget of Ukraine in hryvnias
62 66 data = {
63 67 "mode": "test",
64   - "submissionMethodDetails": "quick",
  68 + "submissionMethodDetails": submissionMethodDetails,
65 69 "description": fake.description(),
66 70 "description_en": fake_en.sentence(nb_words=10, variable_nb_words=True),
67 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 120 if params.get('lot_meat'):
117 121 new_feature = test_feature_data()
118 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 124 new_feature['relatedItem'] = data['lots'][0]['id']
121 125 data['features'].append(new_feature)
122 126 else:
... ... @@ -130,7 +134,7 @@ def test_tender_data(params, periods=("enquiry", "tender")):
130 134 if params.get('item_meat'):
131 135 new_feature = test_feature_data()
132 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 138 new_feature['relatedItem'] = data['items'][0]['id']
135 139 data['features'].append(new_feature)
136 140 if not data['features']:
... ... @@ -315,9 +319,9 @@ def test_item_data(cpv=None):
315 319 data["description_ru"] = field_with_id("i", data["description_ru"])
316 320 days = fake.random_int(min=1, max=30)
317 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 325 data["deliveryAddress"]["countryName_en"] = translate_country_en(data["deliveryAddress"]["countryName"])
322 326 data["deliveryAddress"]["countryName_ru"] = translate_country_ru(data["deliveryAddress"]["countryName"])
323 327 return munchify(data)
... ... @@ -371,22 +375,21 @@ def test_lot_document_data(document, lot_id):
371 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 379 # We should not provide any values for `enquiryPeriod` when creating
377 380 # an openUA or openEU procedure. That field should not be present at all.
378 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 383 data['procurementMethodType'] = 'aboveThresholdUA'
381 384 data['procuringEntity']['kind'] = 'general'
382 385 return data
383 386
384 387
385   -def test_tender_data_openeu(params):
  388 +def test_tender_data_openeu(params, submissionMethodDetails):
386 389 # We should not provide any values for `enquiryPeriod` when creating
387 390 # an openUA or openEU procedure. That field should not be present at all.
388 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 393 data['procurementMethodType'] = 'aboveThresholdEU'
391 394 data['title_en'] = "[TESTING]"
392 395 for item_number, item in enumerate(data['items']):
... ... @@ -399,11 +402,11 @@ def test_tender_data_openeu(params):
399 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 406 # We should not provide any values for `enquiryPeriod` when creating
404 407 # an openUA or openEU procedure. That field should not be present at all.
405 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 410 if params.get('dialogue_type') == 'UA':
408 411 data['procurementMethodType'] = 'competitiveDialogueUA'
409 412 else:
... ...
... ... @@ -204,7 +204,8 @@ Get Broker Property By Username
204 204 Підготувати дані для створення тендера
205 205 [Arguments] ${tender_parameters}
206 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 209 ${TENDER}= Create Dictionary
209 210 Set Global Variable ${TENDER}
210 211 Log ${tender_data}
... ...
... ... @@ -6,7 +6,6 @@ from datetime import timedelta
6 6 from dateutil.parser import parse
7 7 from dpath.util import new as xpathnew
8 8 from haversine import haversine
9   -from iso8601 import parse_date
10 9 from json import load, loads
11 10 from jsonpath_rw import parse as parse_path
12 11 from munch import Munch, munchify
... ... @@ -275,7 +274,9 @@ def compute_intrs(brokers_data, used_brokers):
275 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 280 # Get actual intervals by mode name
280 281 mode = tender_parameters['mode']
281 282 if mode in procedure_intervals:
... ... @@ -296,15 +297,22 @@ def prepare_test_tender_data(procedure_intervals, tender_parameters):
296 297 elif mode == 'negotiation.quick':
297 298 return munchify({'data': test_tender_data_limited(tender_parameters)})
298 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 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 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 308 elif mode == 'reporting':
305 309 return munchify({'data': test_tender_data_limited(tender_parameters)})
306 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 316 raise ValueError("Invalid mode for prepare_test_tender_data")
309 317
310 318
... ...
Please register or login to post a comment