Commit 14703a0397114b7fa5f66fd6d7d28cb6969e1374

Authored by lesiavl
1 parent e49de33d

Fix url check in tender without lots

@@ -61,19 +61,19 @@ Library openprocurement_client_helper.py @@ -61,19 +61,19 @@ Library openprocurement_client_helper.py
61 Отримати посилання на аукціон для глядача 61 Отримати посилання на аукціон для глядача
62 [Arguments] ${username} ${tender_uaid} ${lot_id}=${Empty} 62 [Arguments] ${username} ${tender_uaid} ${lot_id}=${Empty}
63 ${tender}= openprocurement_client.Пошук тендера по ідентифікатору ${username} ${tender_uaid} 63 ${tender}= openprocurement_client.Пошук тендера по ідентифікатору ${username} ${tender_uaid}
64 - ${lots}= get_object_by_id ${tender.data} ${lot_id} lots id  
65 - ${auctionUrl}= Get Variable Value ${lots['auctionUrl']}  
66 - [return] ${auctionUrl} 64 + ${object_with_url}= get_object_by_id ${tender.data} ${lot_id} lots id
  65 + Log ${object_with_url}
  66 + ${auctionUrl}= Get Variable Value ${object_with_url['auctionUrl']}
  67 + [Return] ${auctionUrl}
67 68
68 69
69 Отримати посилання на аукціон для учасника 70 Отримати посилання на аукціон для учасника
70 [Arguments] ${username} ${tender_uaid} ${relatedLot}=${Empty} 71 [Arguments] ${username} ${tender_uaid} ${relatedLot}=${Empty}
71 ${bid}= openprocurement_client.Отримати пропозицію ${username} ${tender_uaid} 72 ${bid}= openprocurement_client.Отримати пропозицію ${username} ${tender_uaid}
72 - Log ${bid}  
73 - ${lot_Values}= get_object_by_id ${bid.data} ${relatedLot} lotValues relatedLot  
74 - ${participationUrl}= Get Variable Value ${lot_Values['participationUrl']}  
75 - Log ${participationUrl}  
76 - [return] ${participationUrl} 73 + ${object_with_url}= get_object_by_id ${bid.data} ${relatedLot} lotValues relatedLot
  74 + Log ${object_with_url}
  75 + ${participationUrl}= Get Variable Value ${object_with_url['participationUrl']}
  76 + [Return] ${participationUrl}
77 77
78 ############################################################################## 78 ##############################################################################
79 # Tender operations 79 # Tender operations
@@ -473,21 +473,22 @@ def get_object_by_id(data, given_object_id, slice_element, object_id): @@ -473,21 +473,22 @@ def get_object_by_id(data, given_object_id, slice_element, object_id):
473 slice_element: what path should be extracted (e.g. from { key: val } extract key ) 473 slice_element: what path should be extracted (e.g. from { key: val } extract key )
474 object_id: what property is id (e.g. from { id: 1, name: 2 } extract id) 474 object_id: what property is id (e.g. from { id: 1, name: 2 } extract id)
475 """ 475 """
476 - sliced_object = data[slice_element]  
477 - # Slice the given object, e.g. slice bid object to lotValues object  
478 476
479 - if not sliced_object: 477 + # Slice the given object, e.g. slice bid object to lotValues object
  478 + try:
  479 + sliced_object = data[slice_element]
  480 + except KeyError:
480 return data 481 return data
481 482
  483 + # If there is one sliced object, get the 1st element
482 if len(sliced_object) == 1: 484 if len(sliced_object) == 1:
483 return sliced_object[0] 485 return sliced_object[0]
484 - # If there is one sliced object, get the 1st element  
485 486
  487 + # Compare given object id and id from sliced object
486 for index, element in enumerate(sliced_object): 488 for index, element in enumerate(sliced_object):
487 element_id = element[object_id] 489 element_id = element[object_id]
488 if element_id == given_object_id: 490 if element_id == given_object_id:
489 return element 491 return element
490 - # Compare given object id and id from sliced object  
491 492
492 return sliced_object[0] 493 return sliced_object[0]
493 494
Please register or login to post a comment