Commit 40c8306e1b51fc2d37e20234ecc68035fdeee8ae

Authored by oleg.stasiv
1 parent 22b89940

Add negative tests for bids

@@ -698,25 +698,33 @@ def test_bid_data_selection(data, index): @@ -698,25 +698,33 @@ def test_bid_data_selection(data, index):
698 return bid 698 return bid
699 699
700 700
701 -def test_bid_data_pq(data, over_limit): 701 +def test_bid_data_pq(data, over_limit=False, missing_criteria=False, more_than_two_requirements=False, invalid_expected_value=False):
702 bid = test_bid_data() 702 bid = test_bid_data()
703 bid.data.requirementResponses = [] 703 bid.data.requirementResponses = []
704 - for criteria in data['criteria']:  
705 - for requirements in criteria['requirementGroups']:  
706 - for requirement in requirements['requirements']:  
707 - if requirement.get('expectedValue'):  
708 - value = requirement.get('expectedValue')  
709 - else:  
710 - value = fake.random_int(min=int(requirement.get('minValue')), max=int(data['value']['amount']))  
711 - requirement = {  
712 - "requirement": {"id": requirement['id']},  
713 - "value": value  
714 - }  
715 - bid.data.requirementResponses.append(requirement) 704 + if 'criteria' in data:
  705 + for criteria in data['criteria']:
  706 + for requirements in criteria['requirementGroups']:
  707 + for requirement in requirements['requirements']:
  708 + if requirement.get('expectedValue'):
  709 + value = requirement.get('expectedValue')
  710 + if invalid_expected_value:
  711 + value = "invalid_value"
  712 + else:
  713 + value = fake.random_int(min=int(requirement.get('minValue')), max=int(data['value']['amount']))
  714 + requirement = {
  715 + "requirement": {"id": requirement['id']},
  716 + "value": value
  717 + }
  718 + bid.data.requirementResponses.append(requirement)
  719 + if not more_than_two_requirements:
  720 + break
716 bid.data['status'] = 'draft' 721 bid.data['status'] = 'draft'
717 - bid.data.update(test_bid_value(fake.random_int(min=1, max=int(data['value']['amount'])), data['value']['valueAddedTaxIncluded'])) 722 + bid.data.update(test_bid_value(fake.random_int(min=1, max=int(data['value']['amount'])),
  723 + data['value']['valueAddedTaxIncluded']))
718 if over_limit: 724 if over_limit:
719 bid.data['value']['amount'] = int(data['value']['amount']) + fake.random_int(min=1, max=1000) 725 bid.data['value']['amount'] = int(data['value']['amount']) + fake.random_int(min=1, max=1000)
  726 + if missing_criteria:
  727 + del bid['data']['requirementResponses'][-1]
720 return bid 728 return bid
721 729
722 730
@@ -353,7 +353,14 @@ Get Broker Property By Username @@ -353,7 +353,14 @@ Get Broker Property By Username
353 Підготувати дані для подання пропозиції priceQuotation 353 Підготувати дані для подання пропозиції priceQuotation
354 [Arguments] ${username} 354 [Arguments] ${username}
355 ${BID_OVER_LIMIT}= Get Variable Value ${BID_OVER_LIMIT} ${False} 355 ${BID_OVER_LIMIT}= Get Variable Value ${BID_OVER_LIMIT} ${False}
356 - ${bid}= test_bid_data_pq ${USERS.users['${username}'].tender_data.data} ${BID_OVER_LIMIT} 356 + ${BID_ONE_OF_THE_CRITERIAS_IS_MISSING}= Get Variable Value ${BID_ONE_OF_THE_CRITERIAS_IS_MISSING} ${False}
  357 + ${BID_SAME_GROUPS_DIFFERENT_CRITERIA}= Get Variable Value ${BID_SAME_GROUPS_DIFFERENT_CRITERIA} ${False}
  358 + ${BID_INVALID_EXPECTED_VALUE}= Get Variable Value ${BID_INVALID_EXPECTED_VALUE} ${False}
  359 + ${bid}= test_bid_data_pq ${USERS.users['${username}'].tender_data.data}
  360 + ... ${BID_OVER_LIMIT}
  361 + ... ${BID_ONE_OF_THE_CRITERIAS_IS_MISSING}
  362 + ... ${BID_SAME_GROUPS_DIFFERENT_CRITERIA}
  363 + ... ${BID_INVALID_EXPECTED_VALUE}
357 [Return] ${bid} 364 [Return] ${bid}
358 365
359 366
@@ -8155,7 +8155,6 @@ @@ -8155,7 +8155,6 @@
8155 "anotherEvent" 8155 "anotherEvent"
8156 ], 8156 ],
8157 "valid_profile_ids": [ 8157 "valid_profile_ids": [
8158 - "400496-33600000-683398-42000777",  
8159 "999999-33140000-555666-42000111" 8158 "999999-33140000-555666-42000111"
8160 ], 8159 ],
8161 "invalid_profile_ids": [ 8160 "invalid_profile_ids": [
Please register or login to post a comment