Commit 2eafc3bfcad437a5309c74dc7210ed6ca1bde3d9

Authored by Alex
1 parent 94d0a38d

- added: get tenderData from tenderUaId

Showing 1 changed file with 53 additions and 11 deletions
@@ -4,6 +4,7 @@ import copy @@ -4,6 +4,7 @@ import copy
4 import urllib 4 import urllib
5 import urllib3 5 import urllib3
6 import string 6 import string
  7 +import requests
7 8
8 import dateutil.parser 9 import dateutil.parser
9 from iso8601 import parse_date 10 from iso8601 import parse_date
@@ -13,6 +14,7 @@ import pytz @@ -13,6 +14,7 @@ import pytz
13 14
14 TZ = pytz.timezone('Europe/Kiev') 15 TZ = pytz.timezone('Europe/Kiev')
15 16
  17 +
16 def get_library(): 18 def get_library():
17 return BuiltIn().get_library_instance('Selenium2Library') 19 return BuiltIn().get_library_instance('Selenium2Library')
18 20
@@ -184,22 +186,23 @@ def procuring_entity_name(tender_data): @@ -184,22 +186,23 @@ def procuring_entity_name(tender_data):
184 tender_data.data.procuringEntity.identifier['legalName'] = u"ТОВ \"ПлейТендер\"" 186 tender_data.data.procuringEntity.identifier['legalName'] = u"ТОВ \"ПлейТендер\""
185 tender_data.data.procuringEntity.identifier['legalName_en'] = u"TOV \"playtender\"" 187 tender_data.data.procuringEntity.identifier['legalName_en'] = u"TOV \"playtender\""
186 if 'address' in tender_data.data.procuringEntity: 188 if 'address' in tender_data.data.procuringEntity:
187 - tender_data.data.procuringEntity.address['region'] = u"м. Київ"  
188 - tender_data.data.procuringEntity.address['postalCode'] = u"123123"  
189 - tender_data.data.procuringEntity.address['locality'] = u"Київ"  
190 - tender_data.data.procuringEntity.address['streetAddress'] = u"address" 189 + tender_data.data.procuringEntity.address['region'] = u"м. Київ"
  190 + tender_data.data.procuringEntity.address['postalCode'] = u"123123"
  191 + tender_data.data.procuringEntity.address['locality'] = u"Київ"
  192 + tender_data.data.procuringEntity.address['streetAddress'] = u"address"
191 if 'contactPoint' in tender_data.data.procuringEntity: 193 if 'contactPoint' in tender_data.data.procuringEntity:
192 - tender_data.data.procuringEntity.contactPoint['name'] = u"Test ЗамовникОборони"  
193 - tender_data.data.procuringEntity.contactPoint['name_en'] = u"Test"  
194 - tender_data.data.procuringEntity.contactPoint['email'] = u"chuzhin@mail.ua"  
195 - tender_data.data.procuringEntity.contactPoint['telephone'] = u"+3801111111111"  
196 - tender_data.data.procuringEntity.contactPoint['url'] = u"http://playtender.com.ua" 194 + tender_data.data.procuringEntity.contactPoint['name'] = u"Test ЗамовникОборони"
  195 + tender_data.data.procuringEntity.contactPoint['name_en'] = u"Test"
  196 + tender_data.data.procuringEntity.contactPoint['email'] = u"chuzhin@mail.ua"
  197 + tender_data.data.procuringEntity.contactPoint['telephone'] = u"+3801111111111"
  198 + tender_data.data.procuringEntity.contactPoint['url'] = u"http://playtender.com.ua"
197 if 'buyers' in tender_data.data: 199 if 'buyers' in tender_data.data:
198 tender_data.data.buyers[0]['name'] = u"ТОВ \"ПлейТендер\"" 200 tender_data.data.buyers[0]['name'] = u"ТОВ \"ПлейТендер\""
199 tender_data.data.buyers[0].identifier['id'] = u"1234567890-playtender" 201 tender_data.data.buyers[0].identifier['id'] = u"1234567890-playtender"
200 tender_data.data.buyers[0].identifier['legalName'] = u"ТОВ \"ПлейТендер\"" 202 tender_data.data.buyers[0].identifier['legalName'] = u"ТОВ \"ПлейТендер\""
201 return tender_data 203 return tender_data
202 204
  205 +
203 # prepare data 206 # prepare data
204 def prepare_procuring_entity_data(data): 207 def prepare_procuring_entity_data(data):
205 try: 208 try:
@@ -254,7 +257,8 @@ def generate_dictionary_from_field_path_and_value(path, value): @@ -254,7 +257,8 @@ def generate_dictionary_from_field_path_and_value(path, value):
254 value = generate_dictionary_from_field_path_and_value('.'.join(path_keys_list), value) 257 value = generate_dictionary_from_field_path_and_value('.'.join(path_keys_list), value)
255 indexRegex = re.compile(r'(\[(\d+)\]$)') 258 indexRegex = re.compile(r'(\[(\d+)\]$)')
256 matchObj = indexRegex.search(key) 259 matchObj = indexRegex.search(key)
257 - print matchObj 260 + print
  261 + matchObj
258 if matchObj: 262 if matchObj:
259 key = indexRegex.sub('', key) 263 key = indexRegex.sub('', key)
260 value['list_index'] = matchObj.group(2) 264 value['list_index'] = matchObj.group(2)
@@ -364,23 +368,29 @@ def convert_date_to_string_contr(date): @@ -364,23 +368,29 @@ def convert_date_to_string_contr(date):
364 date = date.strftime("%d.%m.%Y %H:%M:%S") 368 date = date.strftime("%d.%m.%Y %H:%M:%S")
365 return date 369 return date
366 370
  371 +
367 def get_value_minimalStepPercentage(value): 372 def get_value_minimalStepPercentage(value):
368 value = value / 100 373 value = value / 100
369 return value 374 return value
370 375
  376 +
371 def set_value_minimalStepPercentage(value): 377 def set_value_minimalStepPercentage(value):
372 value = value * 100 378 value = value * 100
373 return value 379 return value
374 380
  381 +
375 def convert_esco__float_to_string(number): 382 def convert_esco__float_to_string(number):
376 return '{0:.5f}'.format(float(number)) 383 return '{0:.5f}'.format(float(number))
377 384
  385 +
378 def convert_string_to_float(number): 386 def convert_string_to_float(number):
379 return float(number) 387 return float(number)
380 388
  389 +
381 def download_file(url, file_name, output_dir): 390 def download_file(url, file_name, output_dir):
382 urllib.urlretrieve(url, ('{}/{}'.format(output_dir, file_name))) 391 urllib.urlretrieve(url, ('{}/{}'.format(output_dir, file_name)))
383 392
  393 +
384 def parse_complaintPeriod_date(date_string): 394 def parse_complaintPeriod_date(date_string):
385 date_str = datetime.strptime(date_string, "%d.%m.%Y %H:%M") 395 date_str = datetime.strptime(date_string, "%d.%m.%Y %H:%M")
386 date = datetime(date_str.year, date_str.month, date_str.day, date_str.hour, date_str.minute, date_str.second, 396 date = datetime(date_str.year, date_str.month, date_str.day, date_str.hour, date_str.minute, date_str.second,
@@ -388,13 +398,15 @@ def parse_complaintPeriod_date(date_string): @@ -388,13 +398,15 @@ def parse_complaintPeriod_date(date_string):
388 date = TZ.localize(date).isoformat() 398 date = TZ.localize(date).isoformat()
389 return date 399 return date
390 400
  401 +
391 def parse_deliveryPeriod_date1(date): 402 def parse_deliveryPeriod_date1(date):
392 date = dateutil.parser.parse(date) 403 date = dateutil.parser.parse(date)
393 date = date.strftime("%d.%m.%Y") 404 date = date.strftime("%d.%m.%Y")
394 return date 405 return date
395 406
  407 +
396 def parse_deliveryPeriod_date(date_string): 408 def parse_deliveryPeriod_date(date_string):
397 -# date_str = datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S+03:00") 409 + # date_str = datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S+03:00")
398 if '+03' in date_string: 410 if '+03' in date_string:
399 date_str = datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S+03:00") 411 date_str = datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S+03:00")
400 else: 412 else:
@@ -403,9 +415,39 @@ def parse_deliveryPeriod_date(date_string): @@ -403,9 +415,39 @@ def parse_deliveryPeriod_date(date_string):
403 date = date.strftime("%d.%m.%Y") 415 date = date.strftime("%d.%m.%Y")
404 return date 416 return date
405 417
  418 +
406 def split_joinvalue(str_value): 419 def split_joinvalue(str_value):
407 str_value = str_value.split() 420 str_value = str_value.split()
408 str_value = ''.join(str_value) 421 str_value = ''.join(str_value)
409 print(str_value) 422 print(str_value)
410 str_value.replace(" ", "") 423 str_value.replace(" ", "")
411 return str_value 424 return str_value
  425 +
  426 +
  427 +def doGetRequest(url, data):
  428 + r = requests.get(url, params=data)
  429 + response = {}
  430 + response['status_code'] = r.status_code
  431 + response['reason'] = r.reason
  432 + response['content'] = r.content
  433 + response['json'] = r.json()
  434 + return response
  435 +
  436 +
  437 +def getTenderDataByTenderUaId(apiBaseUrl, tenderUaId):
  438 + requestData = {"opt_fields": "tenderID", "descending": "1", "mode": "_all_"}
  439 + updatesResponse = doGetRequest(apiBaseUrl.strip("/") + "/tenders", data=requestData)
  440 + if "json" not in updatesResponse:
  441 + print('json key not found')
  442 + return {}
  443 + tenderId = None
  444 + print("lastTenders:")
  445 + print(updatesResponse['json']['data'])
  446 + for item in updatesResponse['json']['data']:
  447 + if tenderUaId == item['tenderID']:
  448 + tenderId = item['id']
  449 + break
  450 + if tenderId is None:
  451 + return {}
  452 + tenderDataResponse = doGetRequest(apiBaseUrl.strip("/") + "/tenders/" + tenderId, data={})
  453 + return tenderDataResponse['json']
Please register or login to post a comment