Commit 40c977213dca2c26c7e135b6c7a4bb38830eb6f0
1 parent
af4b0d78
op_client: Fix a performance issue
A lot of requests were performed without real need. The issue was caused by false negative result of `Dictionary should contain key`. Unlike `get_from_object()`, it can't check whether a nested field is present or not.
Showing
1 changed file
with
23 additions
and
9 deletions
... | ... | @@ -64,16 +64,30 @@ Library openprocurement_client_helper.py |
64 | 64 | |
65 | 65 | |
66 | 66 | Отримати інформацію із тендера |
67 | - [Arguments] ${username} ${fieldname} | |
67 | + [Arguments] ${username} ${field_name} | |
68 | 68 | Log ${username} |
69 | - Log ${fieldname} | |
70 | - ${status}= Run Keyword And Return Status Dictionary Should Contain Key ${USERS.users['${username}'].tender_data.data} ${fieldname} | |
71 | - Run Keyword Unless | |
72 | - ... ${status} | |
73 | - ... openprocurement_client.Пошук тендера по ідентифікатору ${username} ${TENDER['TENDER_UAID']} | |
74 | - ${field_value}= Get_From_Object ${USERS.users['${username}'].tender_data.data} ${fieldname} | |
75 | - Log ${field_value} | |
76 | - [return] ${field_value} | |
69 | + Log ${field_name} | |
70 | + | |
71 | + ${status} ${field_value}= Run keyword and ignore error | |
72 | + ... Get from object | |
73 | + ... ${USERS.users['${username}'].tender_data.data} | |
74 | + ... ${field_name} | |
75 | + # If field is found, return its value | |
76 | + Run Keyword if '${status}' == 'PASS' Return from keyword ${field_value} | |
77 | + | |
78 | + # Else refresh cached data and try again | |
79 | + openprocurement_client.Пошук тендера по ідентифікатору | |
80 | + ... ${username} | |
81 | + ... ${TENDER['TENDER_UAID']} | |
82 | + | |
83 | + ${status} ${field_value}= Run keyword and ignore error | |
84 | + ... Get from object | |
85 | + ... ${USERS.users['${username}'].tender_data.data} | |
86 | + ... ${field_name} | |
87 | + Run Keyword if '${status}' == 'PASS' Return from keyword ${field_value} | |
88 | + | |
89 | + # If field is still absent, trigger a failure | |
90 | + Fail Field not found: ${field_name} | |
77 | 91 | |
78 | 92 | |
79 | 93 | Внести зміни в тендер | ... | ... |
Please
register
or
login
to post a comment