Commit 3facf555e072d9d85d4bc44ada0c5c5280ea5820
1 parent
5f3fe40f
- added: changing tender data structure for filling form in more easiest way
Showing
2 changed files
with
53 additions
and
2 deletions
... | ... | @@ -55,9 +55,12 @@ Resource playtender_tende |
55 | 55 | [Arguments] ${user} ${tender_data} |
56 | 56 | [Documentation] Створити тендер з початковими даними tender_data. Повернути uaid створеного тендера. |
57 | 57 | |
58 | - config acceleration for new tender form ${tender_data['data']} | |
58 | + ${tender_prepared_data} = prepare tender data ${tender_data['data']} | |
59 | + log ${tender_prepared_data} | |
60 | + | |
61 | + config acceleration for new tender form ${tender_prepared_data} | |
59 | 62 | open new tender form |
60 | - fill tender form ${tender_data['data']} | |
63 | + fill tender form ${tender_prepared_data} | |
61 | 64 | submit form and check result ${plan_form_submit_btn_locator} ${plan_form_submit_success_msg} ${plan_created_checker_element_locator} |
62 | 65 | wait until page does not contain element with reloading ${plan_sync_element_locator} |
63 | 66 | ${plan_uaid} = get text ${plan_uaid_text_locator} | ... | ... |
... | ... | @@ -95,3 +95,51 @@ def convert_float_to_string(number): |
95 | 95 | def isodate_format(isodate, format): |
96 | 96 | iso_dt = parse_date(isodate) |
97 | 97 | return iso_dt.strftime(format) |
98 | + | |
99 | + | |
100 | +# prepares data for filling form in easiest way | |
101 | +def prepare_tender_data(data): | |
102 | + # check if data is for multilot | |
103 | + if 'lots' not in data: | |
104 | + return data | |
105 | + | |
106 | + # moves features to its related items | |
107 | + if 'features' in data: | |
108 | + for i, feature in enumerate(data['features']): | |
109 | + if feature['featureOf'] == 'lot': | |
110 | + for lot in data['lots']: | |
111 | + if lot['id'] == feature['relatedItem']: | |
112 | + if 'features' not in lot: | |
113 | + lot['features'] = [] | |
114 | + lot['features'].append(data['features'].pop(i)) | |
115 | + if feature['featureOf'] == 'item': | |
116 | + for item in data['items']: | |
117 | + if item['id'] == feature['relatedItem']: | |
118 | + if 'features' not in item: | |
119 | + item['features'] = [] | |
120 | + item['features'].append(data['features'].pop(i)) | |
121 | + | |
122 | + if len(data['features']) == 0: | |
123 | + del data['features'] | |
124 | + | |
125 | + # moves items to its related lots | |
126 | + for i, item in enumerate(data['items']): | |
127 | + for lot in data['lots']: | |
128 | + if lot['id'] == item['relatedLot']: | |
129 | + if 'items' not in lot: | |
130 | + lot['items'] = [] | |
131 | + lot['items'].append(data['items'].pop(i)) | |
132 | + | |
133 | + del data['items'] | |
134 | + | |
135 | + # moves milestones to its related lots | |
136 | + for i, milestone in enumerate(data['milestones']): | |
137 | + for lot in data['lots']: | |
138 | + if lot['id'] == milestone['relatedLot']: | |
139 | + if 'milestones' not in lot: | |
140 | + lot['milestones'] = [] | |
141 | + lot['milestones'].append(data['milestones'].pop(i)) | |
142 | + | |
143 | + del data['milestones'] | |
144 | + | |
145 | + return data | ... | ... |
Please
register
or
login
to post a comment