Commit 6889683ce138c56e3faeda175bd95ca6225aaad8

Authored by selurvedu
1 parent a5bef35d

Update data preparation code to support openUA

@@ -19,7 +19,7 @@ def create_fake_doc(): @@ -19,7 +19,7 @@ def create_fake_doc():
19 return tf.name 19 return tf.name
20 20
21 21
22 -def test_tender_data(intervals): 22 +def test_tender_data(intervals, periods=("enquiry", "tender")):
23 now = get_now() 23 now = get_now()
24 t_data = { 24 t_data = {
25 "title": u"[ТЕСТУВАННЯ] " + fake.catch_phrase(), 25 "title": u"[ТЕСТУВАННЯ] " + fake.catch_phrase(),
@@ -104,7 +104,7 @@ def test_tender_data(intervals): @@ -104,7 +104,7 @@ def test_tender_data(intervals):
104 } 104 }
105 period_dict = {} 105 period_dict = {}
106 inc_dt = now 106 inc_dt = now
107 - for period_name in ("enquiry", "tender"): 107 + for period_name in periods:
108 period_dict[period_name + "Period"] = {} 108 period_dict[period_name + "Period"] = {}
109 for i, j in zip(range(2), ("start", "end")): 109 for i, j in zip(range(2), ("start", "end")):
110 inc_dt += timedelta(minutes=intervals[period_name][i]) 110 inc_dt += timedelta(minutes=intervals[period_name][i])
@@ -166,7 +166,6 @@ def test_tender_data_limited(intervals): @@ -166,7 +166,6 @@ def test_tender_data_limited(intervals):
166 166
167 167
168 def test_tender_data_multiple_items(intervals): 168 def test_tender_data_multiple_items(intervals):
169 - now = get_now()  
170 t_data = test_tender_data(intervals) 169 t_data = test_tender_data(intervals)
171 for _ in range(4): 170 for _ in range(4):
172 new_item = test_item_data() 171 new_item = test_item_data()
@@ -581,14 +580,16 @@ def test_lot_complaint_data(complaint, lot_id="3c8f387879de4c38957402dbdb8b31af" @@ -581,14 +580,16 @@ def test_lot_complaint_data(complaint, lot_id="3c8f387879de4c38957402dbdb8b31af"
581 return munchify({"data": lot_complaint}) 580 return munchify({"data": lot_complaint})
582 581
583 582
584 -def test_tender_data_openua(intervals, accelerator=0):  
585 - t_data = test_tender_data(intervals)  
586 - now = get_now() 583 +def test_tender_data_openua(intervals):
  584 + accelerator = intervals['accelerator']
  585 + # Since `accelerator` field is not really a list containing timings
  586 + # for a period called `acceleratorPeriod`, let's remove it :)
  587 + del intervals['accelerator']
  588 + # We should not provide any values for `enquiryPeriod` when creating
  589 + # an openUA or openEU procedure. That field should not be present at all.
  590 + # Therefore, we pass a nondefault list of periods to `test_tender_data()`.
  591 + t_data = test_tender_data(intervals, periods=('tender',))
587 t_data['procurementMethodType'] = 'aboveThresholdUA' 592 t_data['procurementMethodType'] = 'aboveThresholdUA'
588 - t_data['procurementMethodDetails'] = 'quick, accelerator={}'.format(accelerator)  
589 - t_data["tenderPeriod"] = {  
590 - "startDate": (now).isoformat(),  
591 - "endDate": (now + timedelta(minutes=15)).isoformat()  
592 - }  
593 - del t_data["enquiryPeriod"] 593 + t_data['procurementMethodDetails'] = 'quick, ' \
  594 + 'accelerator={}'.format(accelerator)
594 return t_data 595 return t_data
@@ -107,14 +107,34 @@ def load_initial_data_from(file_name): @@ -107,14 +107,34 @@ def load_initial_data_from(file_name):
107 return fromYAML(file_obj) 107 return fromYAML(file_obj)
108 108
109 109
110 -def prepare_test_tender_data(period_intervals, mode): 110 +def prepare_test_tender_data(procedure_intervals, mode):
  111 + # Get actual intervals by mode name
  112 + if mode in procedure_intervals:
  113 + intervals = procedure_intervals[mode]
  114 + else:
  115 + intervals = procedure_intervals['default']
  116 + LOGGER.log_message(Message(intervals))
  117 +
  118 + # Set acceleration value for certain modes
  119 + if mode in ['openua', 'openeu']:
  120 + assert isinstance(intervals['accelerator'], int), \
  121 + "Accelerator should be an 'int', " \
  122 + "not '{}'".format(type(intervals['accelerator']).__name__)
  123 + assert intervals['accelerator'] >= 0, \
  124 + "Accelerator should not be less than 0"
  125 + else:
  126 + assert 'accelerator' not in intervals.keys(), \
  127 + "Accelerator is not available for mode '{0}'".format(mode)
  128 +
111 if mode == 'single': 129 if mode == 'single':
112 - return munchify({'data': test_tender_data(period_intervals)}) 130 + return munchify({'data': test_tender_data(intervals)})
113 elif mode == 'multi': 131 elif mode == 'multi':
114 - return munchify({'data': test_tender_data_multiple_items(period_intervals)}) 132 + return munchify({'data': test_tender_data_multiple_items(intervals)})
115 elif mode == 'limited': 133 elif mode == 'limited':
116 - return munchify({'data': test_tender_data_limited(period_intervals)})  
117 - raise ValueError('Invalid mode for test_tender_data') 134 + return munchify({'data': test_tender_data_limited(intervals)})
  135 + elif mode == 'openua':
  136 + return munchify({'data': test_tender_data_openua(intervals)})
  137 + raise ValueError("Invalid mode for prepare_test_tender_data")
118 138
119 139
120 def run_keyword_and_ignore_keyword_definitions(name, *args): 140 def run_keyword_and_ignore_keyword_definitions(name, *args):
Please register or login to post a comment