Commit 260bd5348aa186836651c534aed149765b61c6b5
1 parent
0f77e5f1
Implement document service support
DS-client instance is constructed outside of the client constructor and is passed as an argument to the client constructor. Then it is saved as one of the client attributes.
Showing
5 changed files
with
53 additions
and
10 deletions
| ... | ... | @@ -16,6 +16,7 @@ Resource resource.robot |
| 16 | 16 | ... tender_meat=${${TENDER_MEAT}} |
| 17 | 17 | ... lot_meat=${${LOT_MEAT}} |
| 18 | 18 | ... item_meat=${${ITEM_MEAT}} |
| 19 | + ... api_host_url=${API_HOST_URL} | |
| 19 | 20 | ${DIALOGUE_TYPE}= Get Variable Value ${DIALOGUE_TYPE} |
| 20 | 21 | Run keyword if '${DIALOGUE_TYPE}' != '${None}' Set to dictionary ${tender_parameters} dialogue_type=${DIALOGUE_TYPE} |
| 21 | 22 | ${tender_data}= Підготувати дані для створення тендера ${tender_parameters} | ... | ... |
| 1 | 1 | *** Settings *** |
| 2 | 2 | Library openprocurement_client_helper.py |
| 3 | +Library openprocurement_client.utils | |
| 3 | 4 | |
| 4 | 5 | |
| 5 | 6 | *** Keywords *** |
| ... | ... | @@ -18,10 +19,20 @@ Library openprocurement_client_helper.py |
| 18 | 19 | |
| 19 | 20 | Підготувати клієнт для користувача |
| 20 | 21 | [Arguments] ${username} |
| 21 | - [Documentation] Відкрити браузер, створити об’єкт api wrapper, тощо | |
| 22 | + [Documentation] Відкрити браузер, створити об’єкти api wrapper і | |
| 23 | + ... ds api wrapper, приєднати їх атрибутами до користувача, тощо | |
| 24 | + Log ${RESOURCE} | |
| 22 | 25 | Log ${API_HOST_URL} |
| 23 | 26 | Log ${API_VERSION} |
| 24 | - ${api_wrapper}= prepare_api_wrapper ${USERS.users['${username}'].api_key} ${API_HOST_URL} ${API_VERSION} | |
| 27 | + Log ${DS_HOST_URL} | |
| 28 | + ${auth_ds_all}= get variable value ${USERS.users.${username}.auth_ds} | |
| 29 | + ${auth_ds}= set variable ${auth_ds_all.${RESOURCE}} | |
| 30 | + Log ${auth_ds} | |
| 31 | + | |
| 32 | +# Uncomment this line if there is need to precess files operations without DS. | |
| 33 | +# ${ds_api_wraper}= set variable ${None} | |
| 34 | + ${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} | |
| 25 | 36 | Set To Dictionary ${USERS.users['${username}']} client=${api_wrapper} |
| 26 | 37 | Set To Dictionary ${USERS.users['${username}']} access_token=${EMPTY} |
| 27 | 38 | ${id_map}= Create Dictionary |
| ... | ... | @@ -35,11 +46,11 @@ Library openprocurement_client_helper.py |
| 35 | 46 | Log ${tender_uaid} |
| 36 | 47 | Log ${filepath} |
| 37 | 48 | ${tender}= openprocurement_client.Пошук тендера по ідентифікатору ${username} ${tender_uaid} |
| 38 | - ${tender}= set_access_key ${tender} ${USERS.users['${username}'].access_token} | |
| 49 | + ${tender}= set_access_key ${tender} ${USERS.users['${username}'].access_token} | |
| 39 | 50 | ${reply}= Call Method ${USERS.users['${username}'].client} upload_document ${filepath} ${tender} |
| 40 | 51 | Log object data ${reply} reply |
| 41 | 52 | #return here is needed to have uploaded doc data in `Завантажити документ в лот` keyword |
| 42 | - [return] ${reply} | |
| 53 | + [return] ${reply} | |
| 43 | 54 | |
| 44 | 55 | |
| 45 | 56 | Отримати інформацію із документа |
| ... | ... | @@ -762,13 +773,13 @@ Library openprocurement_client_helper.py |
| 762 | 773 | |
| 763 | 774 | |
| 764 | 775 | Змінити документ в ставці |
| 765 | - [Arguments] ${username} ${tender_uaid} ${path} ${doc_id} | |
| 776 | + [Arguments] ${username} ${tender_uaid} ${path} ${doc_id} ${doc_type}=documents | |
| 766 | 777 | ${bid_id}= Get Variable Value ${USERS.users['${username}'].bidresponses['bid'].data.id} |
| 767 | 778 | ${tender}= openprocurement_client.Пошук тендера по ідентифікатору ${username} ${tender_uaid} |
| 768 | 779 | ${tender}= set_access_key ${tender} ${USERS.users['${username}']['access_token']} |
| 769 | 780 | ${bid}= openprocurement_client.Отримати пропозицію ${username} ${tender_uaid} |
| 770 | 781 | ${bid_doc}= get_document_by_id ${bid.data} ${doc_id} |
| 771 | - ${response}= Call Method ${USERS.users['${username}'].client} update_bid_document ${path} ${tender} ${bid_id} ${bid_doc['id']} | |
| 782 | + ${response}= Call Method ${USERS.users['${username}'].client} update_bid_document ${path} ${tender} ${bid_id} ${bid_doc['id']} ${doc_type} | |
| 772 | 783 | ${uploaded_file} = Create Dictionary |
| 773 | 784 | ... filepath=${path} |
| 774 | 785 | ... upload_response=${response} | ... | ... |
| 1 | 1 | from openprocurement_client.client import Client |
| 2 | -from openprocurement_client.utils import get_tender_id_by_uaid | |
| 2 | +from openprocurement_client.document_service_client \ | |
| 3 | + import DocumentServiceClient | |
| 3 | 4 | from openprocurement_client.exceptions import IdNotFound |
| 4 | 5 | from restkit.errors import RequestFailed, BadStatusLine |
| 5 | 6 | from retrying import retry |
| ... | ... | @@ -19,13 +20,26 @@ def retry_if_request_failed(exception): |
| 19 | 20 | |
| 20 | 21 | |
| 21 | 22 | class StableClient(Client): |
| 22 | - @retry(stop_max_attempt_number=100, wait_random_min=500, wait_random_max=4000, retry_on_exception=retry_if_request_failed) | |
| 23 | + @retry(stop_max_attempt_number=100, wait_random_min=500, | |
| 24 | + wait_random_max=4000, retry_on_exception=retry_if_request_failed) | |
| 23 | 25 | def request(self, *args, **kwargs): |
| 24 | 26 | return super(StableClient, self).request(*args, **kwargs) |
| 25 | 27 | |
| 26 | 28 | |
| 27 | -def prepare_api_wrapper(key, host_url, api_version): | |
| 28 | - return StableClient(key, host_url, api_version) | |
| 29 | +class StableDsClient(DocumentServiceClient): | |
| 30 | + @retry(stop_max_attempt_number=100, wait_random_min=500, | |
| 31 | + wait_random_max=4000, retry_on_exception=retry_if_request_failed) | |
| 32 | + def request(self, *args, **kwargs): | |
| 33 | + return super(StableDsClient, self).request(*args, **kwargs) | |
| 34 | + | |
| 35 | + | |
| 36 | +def prepare_api_wrapper(key, resource, host_url, api_version, ds_client=None): | |
| 37 | + return StableClient(key, resource, host_url, api_version, | |
| 38 | + ds_client=ds_client) | |
| 39 | + | |
| 40 | + | |
| 41 | +def prepare_ds_api_wrapper(ds_host_url, auth_ds): | |
| 42 | + return StableDsClient(ds_host_url, auth_ds) | |
| 29 | 43 | |
| 30 | 44 | |
| 31 | 45 | def get_complaint_internal_id(tender, complaintID): | ... | ... |
| 1 | 1 | users: |
| 2 | 2 | Tender_Owner: |
| 3 | + auth_ds: | |
| 4 | + tenders: [test.quintagroup.com, test.quintagroup.com] | |
| 5 | + auctions: [test.quintagroup.com, bc698baa8b814908bc75405ed3d63548] | |
| 3 | 6 | api_key: e9c3ccb8e8124f26941d5f9639a4ebc3 |
| 4 | 7 | broker: Quinta |
| 5 | 8 | Tender_User: |
| 9 | + auth_ds: | |
| 10 | + tenders: [test.quintagroup.com, test.quintagroup.com] | |
| 11 | + auctions: [test.quintagroup.com, bc698baa8b814908bc75405ed3d63548] | |
| 6 | 12 | api_key: e9c3ccb8e8124f26941d5f9639a4ebc3 |
| 7 | 13 | broker: Quinta |
| 8 | 14 | Tender_User1: |
| 15 | + auth_ds: | |
| 16 | + tenders: [test.quintagroup.com, test.quintagroup.com] | |
| 17 | + auctions: [test.quintagroup.com, bc698baa8b814908bc75405ed3d63548] | |
| 9 | 18 | api_key: e9c3ccb8e8124f26941d5f9639a4ebc3 |
| 10 | 19 | broker: Quinta |
| 11 | 20 | Tender_User2: |
| 21 | + auth_ds: | |
| 22 | + tenders: [test.quintagroup.com, test.quintagroup.com] | |
| 23 | + auctions: [test.quintagroup.com, bc698baa8b814908bc75405ed3d63548] | |
| 12 | 24 | api_key: e9c3ccb8e8124f26941d5f9639a4ebc3 |
| 13 | 25 | broker: Quinta |
| 14 | 26 | Tender_Viewer: |
| 27 | + auth_ds: | |
| 28 | + tenders: [test.quintagroup.com, test.quintagroup.com] | |
| 29 | + auctions: [test.quintagroup.com, bc698baa8b814908bc75405ed3d63548] | |
| 15 | 30 | api_key: "" |
| 16 | 31 | broker: Quinta |
| 17 | 32 | browser: firefox | ... | ... |
Please
register
or
login
to post a comment