Commit c1dfb4576c0a29d56bda902a98ae076c935fea81

Authored by selurvedu
2 parents 8254da94 64866025

Merge pull request #532 from bubanoid/devel

Add Document Service support into devel
... ... @@ -14,6 +14,7 @@ recipe = zc.recipe.egg
14 14 eggs =
15 15 op_robot_tests
16 16 openprocurement_client
  17 + restkit
17 18 robotframework
18 19 robotframework-lint
19 20 robotframework-debuglibrary
... ... @@ -57,7 +58,7 @@ gh_push = git@github.com:
57 58
58 59 [sources]
59 60 barbecue = git ${remotes:gh}openprocurement/barbecue.git
60   -openprocurement_client = git ${remotes:gh}openprocurement/openprocurement.client.python.git
  61 +openprocurement_client = git ${remotes:gh}openprocurement/openprocurement.client.python.git branch=use_requests
61 62 robot_tests.broker.alltenders = git ${remotes:gh}openprocurement/robot_tests.broker.alltenders.git
62 63 robot_tests.broker.dzo = git ${remotes:gh}openprocurement/robot_tests.broker.dzo.git
63 64 robot_tests.broker.25h8 = git ${remotes:gh}openprocurement/robot_tests.broker.25h8.git
... ...
... ... @@ -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, створити об’єкт edr_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 process 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
... ... @@ -38,11 +49,11 @@ Library openprocurement_client_helper.py
38 49 Log ${tender_uaid}
39 50 Log ${filepath}
40 51 ${tender}= openprocurement_client.Пошук тендера по ідентифікатору ${username} ${tender_uaid}
41   - ${tender}= set_access_key ${tender} ${USERS.users['${username}'].access_token}
  52 + ${tender}= set_access_key ${tender} ${USERS.users['${username}'].access_token}
42 53 ${reply}= Call Method ${USERS.users['${username}'].client} upload_document ${filepath} ${tender}
43 54 Log object data ${reply} reply
44 55 #return here is needed to have uploaded doc data in `Завантажити документ в лот` keyword
45   - [return] ${reply}
  56 + [return] ${reply}
46 57
47 58
48 59 Отримати інформацію із документа
... ... @@ -775,13 +786,13 @@ Library openprocurement_client_helper.py
775 786
776 787
777 788 Змінити документ в ставці
778   - [Arguments] ${username} ${tender_uaid} ${path} ${doc_id}
  789 + [Arguments] ${username} ${tender_uaid} ${path} ${doc_id} ${doc_type}=documents
779 790 ${bid_id}= Get Variable Value ${USERS.users['${username}'].bidresponses['bid'].data.id}
780 791 ${tender}= openprocurement_client.Пошук тендера по ідентифікатору ${username} ${tender_uaid}
781 792 ${tender}= set_access_key ${tender} ${USERS.users['${username}']['access_token']}
782 793 ${bid}= openprocurement_client.Отримати пропозицію ${username} ${tender_uaid}
783 794 ${bid_doc}= get_document_by_id ${bid.data} ${doc_id}
784   - ${response}= Call Method ${USERS.users['${username}'].client} update_bid_document ${path} ${tender} ${bid_id} ${bid_doc['id']}
  795 + ${response}= Call Method ${USERS.users['${username}'].client} update_bid_document ${path} ${tender} ${bid_id} ${bid_doc['id']} ${doc_type}
785 796 ${uploaded_file} = Create Dictionary
786 797 ... filepath=${path}
787 798 ... upload_response=${response}
... ...
1 1 from openprocurement_client.client import Client, EDRClient
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 class StableEDRClient(EDRClient):
... ...
... ... @@ -151,9 +151,9 @@ ztv:
151 151 keywords_file: ztv
152 152 roles:
153 153 tender_owner: ztv_Owner
154   - provider: ztv_Provider
155   - provider1: ztv_Provider1
156   - viewer: ztv_Viewer
  154 + provider: ztv_Provider
  155 + provider1: ztv_Provider1
  156 + viewer: ztv_Viewer
157 157 timeout_on_wait: 300
158 158 Newtend:
159 159 keywords_file: newtend
... ...
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 auth_edr: [test.quintagroup.com, f5111c99a97a45348d8165ba8fcf0d62]
... ... @@ -7,6 +10,9 @@ users:
7 10 position: [0, 0]
8 11 size: [1400, 900]
9 12 Tender_User:
  13 + auth_ds:
  14 + tenders: [test.quintagroup.com, test.quintagroup.com]
  15 + auctions: [test.quintagroup.com, bc698baa8b814908bc75405ed3d63548]
10 16 api_key: e9c3ccb8e8124f26941d5f9639a4ebc3
11 17 broker: Quinta
12 18 auth_edr: [test.quintagroup.com, f5111c99a97a45348d8165ba8fcf0d62]
... ... @@ -14,6 +20,9 @@ users:
14 20 position: [0, 0]
15 21 size: [1400, 900]
16 22 Tender_User1:
  23 + auth_ds:
  24 + tenders: [test.quintagroup.com, test.quintagroup.com]
  25 + auctions: [test.quintagroup.com, bc698baa8b814908bc75405ed3d63548]
17 26 api_key: e9c3ccb8e8124f26941d5f9639a4ebc3
18 27 broker: Quinta
19 28 auth_edr: [test.quintagroup.com, f5111c99a97a45348d8165ba8fcf0d62]
... ... @@ -21,6 +30,9 @@ users:
21 30 position: [0, 0]
22 31 size: [1400, 900]
23 32 Tender_User2:
  33 + auth_ds:
  34 + tenders: [test.quintagroup.com, test.quintagroup.com]
  35 + auctions: [test.quintagroup.com, bc698baa8b814908bc75405ed3d63548]
24 36 api_key: e9c3ccb8e8124f26941d5f9639a4ebc3
25 37 broker: Quinta
26 38 auth_edr: [test.quintagroup.com, f5111c99a97a45348d8165ba8fcf0d62]
... ... @@ -28,6 +40,9 @@ users:
28 40 position: [0, 0]
29 41 size: [1400, 900]
30 42 Tender_Viewer:
  43 + auth_ds:
  44 + tenders: [test.quintagroup.com, test.quintagroup.com]
  45 + auctions: [test.quintagroup.com, bc698baa8b814908bc75405ed3d63548]
31 46 api_key: ""
32 47 broker: Quinta
33 48 browser: firefox
... ...
... ... @@ -49,7 +49,7 @@ Set Suite Variable With Default Value
49 49 ${repo}= Run git remote -v
50 50 ${branch}= Run git branch -vva
51 51 ${status}= Run git status
52   - ${diff}= Run git diff
  52 + ${diff}= Run git diff
53 53 ${reflog}= Run git reflog
54 54 Log ${commit}
55 55 Log ${repo}
... ...
1 1 *** Variables ***
  2 +${RESOURCE} tenders # possible values: tenders, auctions
2 3 ${API_HOST_URL} https://lb.api-sandbox.openprocurement.org
3 4 ${API_VERSION} 2.3
4 5 ${BROKER} Quinta
  6 +${DS_HOST_URL} https://upload.docs-sandbox.openprocurement.org
5 7 ${ROLE} viewer
6 8 ${EDR_HOST_URL} https://lb.edr-sandbox.openprocurement.org
7   -${EDR_VERSION} 0
\ No newline at end of file
  9 +${EDR_VERSION} 0
... ...
Please register or login to post a comment