Commit 42df9535c12ff0341e4613ca29d8ad1437a2d25e
Merge pull request #24 from selurvedu/tenders_feed
Support new method of tender list retrieval (?feed=tenders)
Showing
2 changed files
with
22 additions
and
17 deletions
... | ... | @@ -8,23 +8,25 @@ Library Selenium2Screenshots |
8 | 8 | [Documentation] |
9 | 9 | ... ${ARGUMENTS[0]} == username |
10 | 10 | ... ${ARGUMENTS[1]} == tenderid |
11 | - log many @{ARGUMENTS} | |
12 | - ${tenders}= get_internal_id ${USERS.users['${ARGUMENTS[0]}'].client.get_tenders} ${USERS.users['${ARGUMENTS[0]}'].creation_date} | |
11 | + Log Many @{ARGUMENTS} | |
12 | + Log Many ${ID_MAP} | |
13 | + ${status}= Run Keyword And Return Status Dictionary Should Contain Key ${ID_MAP} ${ARGUMENTS[1]} | |
14 | + Run Keyword And Return If ${status} Get From Dictionary ${ID_MAP} ${ARGUMENTS[1]} | |
15 | + ${tenders}= get_tenders ${USERS.users['${ARGUMENTS[0]}'].client} | |
16 | + Log Many @{tenders} | |
13 | 17 | :FOR ${tender} IN @{tenders} |
14 | - \ log ${tender} | |
15 | - \ ${internal_id}= Run Keyword And Return If '${tender.tenderID}' == '${ARGUMENTS[1]}' Get Variable Value ${tender.id} | |
16 | - \ Exit For Loop If '${tender.tenderID}' == '${ARGUMENTS[1]}' | |
17 | - log ${internal_id} | |
18 | - log ${tenders} | |
19 | - [return] ${internal_id} | |
18 | + \ Set To Dictionary ${ID_MAP} ${tender.tenderID} ${tender.id} | |
19 | + Log Many ${ID_MAP} | |
20 | + Dictionary Should Contain Key ${ID_MAP} ${ARGUMENTS[1]} | |
21 | + Run Keyword And Return Get From Dictionary ${ID_MAP} ${ARGUMENTS[1]} | |
20 | 22 | |
21 | 23 | Підготувати клієнт для користувача |
22 | 24 | [Arguments] @{ARGUMENTS} |
23 | 25 | [Documentation] Відкрити брaвзер, створити обєкт api wrapper, тощо |
24 | - ${api_wrapper}= prepare_api_wrapper ${USERS.users['${ARGUMENTS[0]}'].api_key} ${API_HOST_URL} ${api_version} | |
25 | - ${creation_date} = get_date | |
26 | - Set To Dictionary ${USERS.users['${ARGUMENTS[0]}']} creation_date ${creation_date} | |
27 | - Set To Dictionary ${USERS.users['${ARGUMENTS[0]}']} client ${api_wrapper} | |
26 | + ${api_wrapper}= prepare_api_wrapper ${USERS.users['${ARGUMENTS[0]}'].api_key} ${API_HOST_URL} ${api_version} | |
27 | + Set To Dictionary ${USERS.users['${ARGUMENTS[0]}']} client ${api_wrapper} | |
28 | + ${ID_MAP}= Create Dictionary | |
29 | + Set Suite Variable ${ID_MAP} | |
28 | 30 | Log Variables |
29 | 31 | |
30 | 32 | Підготувати дані для оголошення тендера | ... | ... |
1 | 1 | from openprocurement_client.client import Client |
2 | -import sys | |
3 | 2 | |
4 | 3 | |
5 | -def prepare_api_wrapper(key='', host_url="https://api-sandbox.openprocurement.org", api_version='0.8'): | |
4 | +def prepare_api_wrapper(key='', | |
5 | + host_url='https://api-sandbox.openprocurement.org', | |
6 | + api_version='0.8'): | |
6 | 7 | return Client(key, host_url, api_version) |
7 | 8 | |
8 | 9 | |
9 | -def get_internal_id(get_tenders_function, date): | |
10 | - result = get_tenders_function({"offset": date, "opt_fields": 'tenderID'}) | |
11 | - return result | |
10 | +def get_tenders(client, offset=None): | |
11 | + params = {'opt_fields': 'tenderID', 'descending': 1} | |
12 | + if offset: | |
13 | + params['offset'] = offset | |
14 | + return client.get_tenders(params) | ... | ... |
Please
register
or
login
to post a comment