Commit d66102a14cc1106f1155733b6ce6a422ee5b5947
1 parent
c065d55f
add keywords for openprocurement client
Showing
2 changed files
with
139 additions
and
0 deletions
@@ -43,6 +43,19 @@ Library openprocurement_client.utils | @@ -43,6 +43,19 @@ Library openprocurement_client.utils | ||
43 | [return] ${monitoring_id} | 43 | [return] ${monitoring_id} |
44 | 44 | ||
45 | 45 | ||
46 | +Отримати internal id угоди по UAid | ||
47 | + [Arguments] ${username} ${agreement_uaid} | ||
48 | + Log ${username} | ||
49 | + Log ${agreement_uaid} | ||
50 | + Log Many ${USERS.users['${username}'].id_map} | ||
51 | + ${status}= Run Keyword And Return Status Dictionary Should Contain Key ${USERS.users['${username}'].id_map} ${agreement_uaid} | ||
52 | + Run Keyword And Return If ${status} Get From Dictionary ${USERS.users['${username}'].id_map} ${agreement_uaid} | ||
53 | + Call Method ${USERS.users['${username}'].agreement_client} get_agreements | ||
54 | + ${agreement_id}= Wait Until Keyword Succeeds 5x 30 sec get_agreement_id_by_uaid ${agreement_uaid} ${USERS.users['${username}'].agreement_client} | ||
55 | + Set To Dictionary ${USERS.users['${username}'].id_map} ${agreement_uaid} ${agreement_id} | ||
56 | + [return] ${agreement_id} | ||
57 | + | ||
58 | + | ||
46 | Підготувати клієнт для користувача | 59 | Підготувати клієнт для користувача |
47 | [Arguments] ${username} | 60 | [Arguments] ${username} |
48 | [Documentation] Відкрити браузер, створити об’єкти api wrapper і | 61 | [Documentation] Відкрити браузер, створити об’єкти api wrapper і |
@@ -62,7 +75,9 @@ Library openprocurement_client.utils | @@ -62,7 +75,9 @@ Library openprocurement_client.utils | ||
62 | ... prepare_plan_api_wrapper ${USERS.users['${username}'].api_key} PLANS ${API_HOST_URL} ${API_VERSION} | 75 | ... prepare_plan_api_wrapper ${USERS.users['${username}'].api_key} PLANS ${API_HOST_URL} ${API_VERSION} |
63 | ... ELSE prepare_api_wrapper ${USERS.users['${username}'].api_key} ${RESOURCE} ${API_HOST_URL} ${API_VERSION} ${ds_api_wraper} | 76 | ... ELSE prepare_api_wrapper ${USERS.users['${username}'].api_key} ${RESOURCE} ${API_HOST_URL} ${API_VERSION} ${ds_api_wraper} |
64 | ${dasu_api_wraper}= prepare_dasu_api_wrapper ${USERS.users['${username}'].dasu_api_key} ${DASU_RESOURCE} ${DASU_API_HOST_URL} ${DASU_API_VERSION} ${ds_api_wraper} | 77 | ${dasu_api_wraper}= prepare_dasu_api_wrapper ${USERS.users['${username}'].dasu_api_key} ${DASU_RESOURCE} ${DASU_API_HOST_URL} ${DASU_API_VERSION} ${ds_api_wraper} |
78 | + ${agreement_wrapper}= prepare_agreement_api_wrapper ${USERS.users['${username}'].api_key} AGREEMENTS ${API_HOST_URL} ${API_VERSION} ${ds_api_wraper} | ||
65 | Set To Dictionary ${USERS.users['${username}']} client=${api_wrapper} | 79 | Set To Dictionary ${USERS.users['${username}']} client=${api_wrapper} |
80 | + Set To Dictionary ${USERS.users['${username}']} agreement_client=${agreement_wrapper} | ||
66 | Set To Dictionary ${USERS.users['${username}']} dasu_client=${dasu_api_wraper} | 81 | Set To Dictionary ${USERS.users['${username}']} dasu_client=${dasu_api_wraper} |
67 | Set To Dictionary ${USERS.users['${username}']} access_token=${EMPTY} | 82 | Set To Dictionary ${USERS.users['${username}']} access_token=${EMPTY} |
68 | ${id_map}= Create Dictionary | 83 | ${id_map}= Create Dictionary |
@@ -75,6 +90,8 @@ Library openprocurement_client.utils | @@ -75,6 +90,8 @@ Library openprocurement_client.utils | ||
75 | ${contract_api_wrapper}= prepare_contract_api_wrapper ${USERS.users['${username}'].api_key} CONTRACTS ${api_host_url} ${api_version} ${ds_api_wraper} | 90 | ${contract_api_wrapper}= prepare_contract_api_wrapper ${USERS.users['${username}'].api_key} CONTRACTS ${api_host_url} ${api_version} ${ds_api_wraper} |
76 | Set To Dictionary ${USERS.users['${username}']} contracting_client=${contract_api_wrapper} | 91 | Set To Dictionary ${USERS.users['${username}']} contracting_client=${contract_api_wrapper} |
77 | Set To Dictionary ${USERS.users['${username}']} contract_access_token=${EMPTY} | 92 | Set To Dictionary ${USERS.users['${username}']} contract_access_token=${EMPTY} |
93 | + Set To Dictionary ${USERS.users['${username}']} agreement_access_token=${EMPTY} | ||
94 | + ${contracts_id_map}= Create Dictionary | ||
78 | ${contracts_id_map}= Create Dictionary | 95 | ${contracts_id_map}= Create Dictionary |
79 | Set To Dictionary ${USERS.users['${username}']} contracts_id_map=${contracts_id_map} | 96 | Set To Dictionary ${USERS.users['${username}']} contracts_id_map=${contracts_id_map} |
80 | Log Variables | 97 | Log Variables |
@@ -246,6 +263,16 @@ Library openprocurement_client.utils | @@ -246,6 +263,16 @@ Library openprocurement_client.utils | ||
246 | [return] ${monitoring} | 263 | [return] ${monitoring} |
247 | 264 | ||
248 | 265 | ||
266 | +Пошук угоди по ідентифікатору | ||
267 | + [Arguments] ${username} ${agreement_uaid} ${save_key}=agreement_data | ||
268 | + ${internalid}= openprocurement_client.Отримати internal id угоди по UAid ${username} ${agreement_uaid} | ||
269 | + ${agreement}= Call Method ${USERS.users['${username}'].agreement_client} get_agreement ${internalid} | ||
270 | + Set To Dictionary ${USERS.users['${username}']} ${save_key}=${agreement} | ||
271 | + ${agreement}= munch_dict arg=${agreement} | ||
272 | + Log ${agreement} | ||
273 | + [return] ${agreement} | ||
274 | + | ||
275 | + | ||
249 | Отримати доступ до об'єкта моніторингу | 276 | Отримати доступ до об'єкта моніторингу |
250 | [Arguments] ${username} ${monitoring_uaid} ${save_key}=monitoring | 277 | [Arguments] ${username} ${monitoring_uaid} ${save_key}=monitoring |
251 | ${token}= Set Variable ${USERS.users['${username}'].access_token} | 278 | ${token}= Set Variable ${USERS.users['${username}'].access_token} |
@@ -2010,3 +2037,102 @@ Library openprocurement_client.utils | @@ -2010,3 +2037,102 @@ Library openprocurement_client.utils | ||
2010 | ${document}= get_document_by_id ${tender.data} ${doc_id} | 2037 | ${document}= get_document_by_id ${tender.data} ${doc_id} |
2011 | ${filename}= download_file_from_url ${document.url} ${OUTPUT_DIR}${/}${document.title} | 2038 | ${filename}= download_file_from_url ${document.url} ${OUTPUT_DIR}${/}${document.title} |
2012 | [return] ${filename} | 2039 | [return] ${filename} |
2040 | + | ||
2041 | + | ||
2042 | +Отримати доступ до угоди | ||
2043 | + [Arguments] ${username} ${agreement_uaid} | ||
2044 | + ${token}= Set Variable ${USERS.users['${username}'].access_token} | ||
2045 | + ${internalid}= openprocurement_client.Отримати internal id угоди по UAid ${username} ${agreement_uaid} | ||
2046 | + ${agreement}= Call Method ${USERS.users['${username}'].agreement_client} patch_credentials ${internalid} ${token} | ||
2047 | + Set To Dictionary ${USERS.users['${username}']} agreement_access_token=${agreement.access.token} | ||
2048 | + ${agreement}= munch_dict arg=${agreement} | ||
2049 | + [return] ${agreement} | ||
2050 | + | ||
2051 | + | ||
2052 | +Внести зміну в угоду | ||
2053 | + [Arguments] ${username} ${agreement_uaid} ${change_data} | ||
2054 | + ${internalid}= openprocurement_client.Отримати internal id угоди по UAid ${username} ${agreement_uaid} | ||
2055 | + ${reply}= Call Method ${USERS.users['${username}'].agreement_client} create_change | ||
2056 | + ... ${internalid} | ||
2057 | + ... ${change_data} | ||
2058 | + ... access_token=${USERS.users['${username}'].agreement_access_token} | ||
2059 | + Log ${reply} | ||
2060 | + | ||
2061 | + | ||
2062 | +Застосувати зміну для угоди | ||
2063 | + [Arguments] ${username} ${agreement_uaid} ${dateSigned} ${status} | ||
2064 | + ${agreement}= openprocurement_client.Пошук угоди по ідентифікатору ${username} ${agreement_uaid} | ||
2065 | + ${data}= Create Dictionary status=${status} dateSigned=${dateSigned} | ||
2066 | + ${data}= Create Dictionary data=${data} | ||
2067 | + ${reply}= Call Method ${USERS.users['${username}'].agreement_client} patch_change | ||
2068 | + ... ${agreement.data.id} | ||
2069 | + ... ${data} | ||
2070 | + ... ${agreement.data.changes[-1].id} | ||
2071 | + ... access_token=${USERS.users['${username}'].agreement_access_token} | ||
2072 | + Log ${reply} | ||
2073 | + | ||
2074 | + | ||
2075 | +Оновити властивості угоди | ||
2076 | + [Arguments] ${username} ${agreement_uaid} ${data} | ||
2077 | + ${agreement}= openprocurement_client.Пошук угоди по ідентифікатору ${username} ${agreement_uaid} | ||
2078 | + ${reply}= Call Method ${USERS.users['${username}'].agreement_client} patch_change | ||
2079 | + ... ${agreement.data.id} | ||
2080 | + ... ${data} | ||
2081 | + ... ${agreement.data.changes[-1].id} | ||
2082 | + ... access_token=${USERS.users['${username}'].agreement_access_token} | ||
2083 | + Log ${reply} | ||
2084 | + | ||
2085 | + | ||
2086 | +Завантажити документ в рамкову угоду | ||
2087 | + [Arguments] ${username} ${filepath} ${agreement_uaid} | ||
2088 | + Log ${username} | ||
2089 | + Log ${agreement_uaid} | ||
2090 | + Log ${filepath} | ||
2091 | + ${agreement}= openprocurement_client.Пошук угоди по ідентифікатору ${username} ${agreement_uaid} | ||
2092 | + ${reply}= Call Method ${USERS.users['${username}'].agreement_client} upload_document | ||
2093 | + ... ${filepath} | ||
2094 | + ... ${agreement.data.id} | ||
2095 | + ... access_token=${USERS.users['${username}'].agreement_access_token} | ||
2096 | + Log Object Data ${reply} reply | ||
2097 | + [return] ${reply} | ||
2098 | + | ||
2099 | + | ||
2100 | +Завантажити документ для зміни у рамковій угоді | ||
2101 | + [Arguments] ${username} ${filepath} ${agreement_uaid} ${item_id} | ||
2102 | + Log ${username} | ||
2103 | + Log ${agreement_uaid} | ||
2104 | + Log ${filepath} | ||
2105 | + ${agreement}= openprocurement_client.Пошук угоди по ідентифікатору ${username} ${agreement_uaid} | ||
2106 | + ${document}= openprocurement_client.Завантажити документ в рамкову угоду ${username} ${filepath} ${agreement_uaid} | ||
2107 | + Set to dictionary ${document.data} documentOf=change | ||
2108 | + Set to dictionary ${document.data} relatedItem=${item_id} | ||
2109 | + ${reply}= Call Method ${USERS.users['${username}'].agreement_client} patch_document | ||
2110 | + ... ${agreement.data.id} | ||
2111 | + ... ${document} | ||
2112 | + ... ${document.data.id} | ||
2113 | + ... access_token=${USERS.users['${username}'].agreement_access_token} | ||
2114 | + [return] ${reply} | ||
2115 | + | ||
2116 | + | ||
2117 | +Завершити угоду | ||
2118 | + [Arguments] ${username} ${agreement_uaid} | ||
2119 | + ${internalid}= openprocurement_client.Отримати internal id угоди по UAid ${username} ${agreement_uaid} | ||
2120 | + ${data}= Create Dictionary status=terminated | ||
2121 | + ${data}= Create Dictionary data=${data} | ||
2122 | + ${reply}= Call Method ${USERS.users['${username}'].agreement_client} patch_agreement | ||
2123 | + ... ${internalid} | ||
2124 | + ... ${data} | ||
2125 | + ... access_token=${USERS.users['${username}'].agreement_access_token} | ||
2126 | + | ||
2127 | + | ||
2128 | +Отримати інформацію із угоди | ||
2129 | + [Arguments] ${username} ${agreement_uaid} ${field_name} | ||
2130 | + openprocurement_client.Пошук угоди по ідентифікатору | ||
2131 | + ... ${username} | ||
2132 | + ... ${agreement_uaid} | ||
2133 | + ${status} ${field_value}= Run Keyword And Ignore Error | ||
2134 | + ... Get From Object | ||
2135 | + ... ${USERS.users['${username}'].agreement_data.data} | ||
2136 | + ... ${field_name} | ||
2137 | + Run Keyword If '${status}' == 'PASS' Return From Keyword ${field_value} | ||
2138 | + Fail Field not found: ${field_name} |
1 | from openprocurement_client.resources.tenders import Client | 1 | from openprocurement_client.resources.tenders import Client |
2 | from openprocurement_client.resources.edr import EDRClient | 2 | from openprocurement_client.resources.edr import EDRClient |
3 | +from openprocurement_client.resources.agreements import AgreementClient | ||
3 | from openprocurement_client.dasu_client import DasuClient | 4 | from openprocurement_client.dasu_client import DasuClient |
4 | from openprocurement_client.resources.document_service import DocumentServiceClient | 5 | from openprocurement_client.resources.document_service import DocumentServiceClient |
5 | from openprocurement_client.resources.plans import PlansClient | 6 | from openprocurement_client.resources.plans import PlansClient |
@@ -34,6 +35,13 @@ class StableDsClient(DocumentServiceClient): | @@ -34,6 +35,13 @@ class StableDsClient(DocumentServiceClient): | ||
34 | return super(StableDsClient, self).request(*args, **kwargs) | 35 | return super(StableDsClient, self).request(*args, **kwargs) |
35 | 36 | ||
36 | 37 | ||
38 | +class StableAgreementClient(AgreementClient): | ||
39 | + @retry(stop_max_attempt_number=100, wait_random_min=500, | ||
40 | + wait_random_max=4000, retry_on_exception=retry_if_request_failed) | ||
41 | + def request(self, *args, **kwargs): | ||
42 | + return super(StableAgreementClient, self).request(*args, **kwargs) | ||
43 | + | ||
44 | + | ||
37 | def prepare_api_wrapper(key, resource, host_url, api_version, ds_client=None): | 45 | def prepare_api_wrapper(key, resource, host_url, api_version, ds_client=None): |
38 | return StableClient(key, resource, host_url, api_version, | 46 | return StableClient(key, resource, host_url, api_version, |
39 | ds_client=ds_client) | 47 | ds_client=ds_client) |
@@ -43,6 +51,11 @@ def prepare_ds_api_wrapper(ds_host_url, auth_ds): | @@ -43,6 +51,11 @@ def prepare_ds_api_wrapper(ds_host_url, auth_ds): | ||
43 | return StableDsClient(ds_host_url, auth_ds) | 51 | return StableDsClient(ds_host_url, auth_ds) |
44 | 52 | ||
45 | 53 | ||
54 | +def prepare_agreement_api_wrapper(key, resource, host_url, api_version, ds_client=None): | ||
55 | + return StableAgreementClient(key, resource, host_url, api_version, | ||
56 | + ds_client=ds_client) | ||
57 | + | ||
58 | + | ||
46 | class ContractingStableClient(ContractingClient): | 59 | class ContractingStableClient(ContractingClient): |
47 | @retry(stop_max_attempt_number=100, wait_random_min=500, wait_random_max=4000, retry_on_exception=retry_if_request_failed) | 60 | @retry(stop_max_attempt_number=100, wait_random_min=500, wait_random_max=4000, retry_on_exception=retry_if_request_failed) |
48 | def request(self, *args, **kwargs): | 61 | def request(self, *args, **kwargs): |
Please
register
or
login
to post a comment