Commit b9e159c16694bbd2c1a847b4cc181b71182fa0e6
1 parent
717a1ec6
keywords and function for test case 'Можливість створити план закупівлі'
Showing
3 changed files
with
60 additions
and
1 deletions
... | ... | @@ -37,6 +37,25 @@ Resource resource.robot |
37 | 37 | \ Should Match Regexp ${document_url} ^https?:\/\/public.docs(?:-sandbox)?\.openprocurement\.org\/get\/([0-9A-Fa-f]{32}) msg=Not a Document Service Upload |
38 | 38 | |
39 | 39 | |
40 | +Можливість створити план закупівлі | |
41 | + ${NUMBER_OF_LOTS}= Convert To Integer ${NUMBER_OF_LOTS} | |
42 | + ${NUMBER_OF_ITEMS}= Convert To Integer ${NUMBER_OF_ITEMS} | |
43 | + ${tender_parameters}= Create Dictionary | |
44 | + ... mode=${MODE} | |
45 | + ... number_of_items=${NUMBER_OF_ITEMS} | |
46 | + ... number_of_lots=${NUMBER_OF_LOTS} | |
47 | + ... tender_meat=${${TENDER_MEAT}} | |
48 | + ... lot_meat=${${LOT_MEAT}} | |
49 | + ... item_meat=${${ITEM_MEAT}} | |
50 | + ${DIALOGUE_TYPE}= Get Variable Value ${DIALOGUE_TYPE} | |
51 | + Run keyword if '${DIALOGUE_TYPE}' != '${None}' Set to dictionary ${tender_parameters} dialogue_type=${DIALOGUE_TYPE} | |
52 | + ${tender_data}= Підготувати дані для створення тендера ${tender_parameters} | |
53 | + ${adapted_data}= Адаптувати дані для оголошення тендера ${tender_data} | |
54 | + ${TENDER_UAID}= Run As ${tender_owner} Створити план ${adapted_data} | |
55 | + Set To Dictionary ${USERS.users['${tender_owner}']} initial_data=${adapted_data} | |
56 | + Set To Dictionary ${TENDER} TENDER_UAID=${TENDER_UAID} | |
57 | + | |
58 | + | |
40 | 59 | Можливість знайти тендер по ідентифікатору для усіх користувачів |
41 | 60 | :FOR ${username} IN ${tender_owner} ${provider} ${provider1} ${viewer} |
42 | 61 | \ Можливість знайти тендер по ідентифікатору для користувача ${username} | ... | ... |
... | ... | @@ -17,6 +17,19 @@ Library openprocurement_client.utils |
17 | 17 | [return] ${tender_id} |
18 | 18 | |
19 | 19 | |
20 | +Отримати internal id плану по UAid | |
21 | + [Arguments] ${username} ${tender_uaid} | |
22 | + Log ${username} | |
23 | + Log ${tender_uaid} | |
24 | + Log Many ${USERS.users['${username}'].id_map} | |
25 | + ${status}= Run Keyword And Return Status Dictionary Should Contain Key ${USERS.users['${username}'].id_map} ${tender_uaid} | |
26 | + Run Keyword And Return If ${status} Get From Dictionary ${USERS.users['${username}'].id_map} ${tender_uaid} | |
27 | + Call Method ${USERS.users['${username}'].client} get_plans | |
28 | + ${tender_id}= Wait Until Keyword Succeeds 5x 30 sec get_plan_id_by_uaid ${tender_uaid} ${USERS.users['${username}'].client} | |
29 | + Set To Dictionary ${USERS.users['${username}'].id_map} ${tender_uaid} ${tender_id} | |
30 | + [return] ${tender_id} | |
31 | + | |
32 | + | |
20 | 33 | Підготувати клієнт для користувача |
21 | 34 | [Arguments] ${username} |
22 | 35 | [Documentation] Відкрити браузер, створити об’єкти api wrapper і |
... | ... | @@ -32,7 +45,9 @@ Library openprocurement_client.utils |
32 | 45 | # Uncomment this line if there is need to process files operations without DS. |
33 | 46 | # ${ds_api_wraper}= set variable ${None} |
34 | 47 | ${ds_api_wraper}= prepare_ds_api_wrapper ${DS_HOST_URL} ${auth_ds} |
35 | - ${api_wrapper}= prepare_api_wrapper ${USERS.users['${username}'].api_key} ${RESOURCE} ${API_HOST_URL} ${API_VERSION} ${ds_api_wraper} | |
48 | + ${api_wrapper}= Run Keyword If '${MODE}' == 'planning' | |
49 | + ... prepare_plan_api_wrapper ${USERS.users['${username}'].api_key} ${API_HOST_URL} ${API_VERSION} | |
50 | + ... ELSE prepare_api_wrapper ${USERS.users['${username}'].api_key} ${RESOURCE} ${API_HOST_URL} ${API_VERSION} ${ds_api_wraper} | |
36 | 51 | Set To Dictionary ${USERS.users['${username}']} client=${api_wrapper} |
37 | 52 | Set To Dictionary ${USERS.users['${username}']} access_token=${EMPTY} |
38 | 53 | ${id_map}= Create Dictionary |
... | ... | @@ -117,6 +132,20 @@ Library openprocurement_client.utils |
117 | 132 | [return] ${tender.data.tenderID} |
118 | 133 | |
119 | 134 | |
135 | +Створити план | |
136 | + [Arguments] ${username} ${tender_data} | |
137 | + ${tender}= Call Method ${USERS.users['${username}'].client} create_plan ${tender_data} | |
138 | + Log ${tender} | |
139 | + ${access_token}= Get Variable Value ${tender.access.token} | |
140 | + ${tender}= Call Method ${USERS.users['${username}'].client} patch_plan ${tender} | |
141 | + Log ${tender} | |
142 | + Log ${\n}${API_HOST_URL}/api/${API_VERSION}/plans/${tender.data.id}${\n} WARN | |
143 | + Set To Dictionary ${USERS.users['${username}']} access_token=${access_token} | |
144 | + Set To Dictionary ${USERS.users['${username}']} tender_data=${tender} | |
145 | + Log ${USERS.users['${username}'].tender_data} | |
146 | + [return] ${tender.data.planID} | |
147 | + | |
148 | + | |
120 | 149 | Пошук тендера по ідентифікатору |
121 | 150 | [Arguments] ${username} ${tender_uaid} ${save_key}=tender_data |
122 | 151 | ${internalid}= openprocurement_client.Отримати internal id по UAid ${username} ${tender_uaid} | ... | ... |
1 | 1 | from openprocurement_client.client import Client, EDRClient |
2 | 2 | from openprocurement_client.document_service_client \ |
3 | 3 | import DocumentServiceClient |
4 | +from openprocurement_client.plan import PlansClient | |
4 | 5 | from openprocurement_client.exceptions import IdNotFound |
5 | 6 | from restkit.errors import RequestFailed, BadStatusLine |
6 | 7 | from retrying import retry |
... | ... | @@ -106,3 +107,13 @@ def download_file_from_url(url, path_to_save_file): |
106 | 107 | f.write(urllib.urlopen(url).read()) |
107 | 108 | f.close() |
108 | 109 | return os.path.basename(f.name) |
110 | + | |
111 | + | |
112 | +class StableClient_plan(PlansClient): | |
113 | + @retry(stop_max_attempt_number=100, wait_random_min=500, wait_random_max=4000, retry_on_exception=retry_if_request_failed) | |
114 | + def request(self, *args, **kwargs): | |
115 | + return super(StableClient_plan, self).request(*args, **kwargs) | |
116 | + | |
117 | + | |
118 | +def prepare_plan_api_wrapper(key, host_url, api_version): | |
119 | + return StableClient_plan(key, host_url, api_version) | |
\ No newline at end of file | ... | ... |
Please
register
or
login
to post a comment