Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/a383834598655550_fix_bid_tests'
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaksymiv committed Jul 17, 2017
2 parents 31c23f5 + 58a66b4 commit 7cd9fa7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 139 deletions.
6 changes: 5 additions & 1 deletion openprocurement/tender/competitivedialogue/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from openprocurement.api.tests.base import PrefixedRequestClass, test_organization
from openprocurement.tender.openua.tests.base import (test_tender_data as base_test_tender_data_ua, BaseTenderWebTest)


now = datetime.now()
test_tender_data_eu = deepcopy(base_test_tender_data_eu)
test_tender_data_eu["procurementMethodType"] = CD_EU_TYPE
Expand Down Expand Up @@ -906,9 +907,12 @@ def set_status(self, status, extra=None):
self.assertEqual(response.content_type, 'application/json')
return response

test_features_tender_eu_data = test_features_tender_data.copy()
test_features_tender_eu_data = deepcopy(test_features_tender_data)
test_features_tender_eu_data['procurementMethodType'] = CD_EU_TYPE

author = deepcopy(test_bids[0]["tenderers"][0])
author['identifier']['id'] = test_shortlistedFirms[0]['identifier']['id']
author['identifier']['scheme'] = test_shortlistedFirms[0]['identifier']['scheme']

test_bids_cd = deepcopy(test_bids_eu)
test_bids_cd.append(test_bids_cd[0].copy()) # Minimal number of bids for successfull competitive dialogue is 3.
92 changes: 4 additions & 88 deletions openprocurement/tender/competitivedialogue/tests/stage1/bid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
BaseCompetitiveDialogEUContentWebTest,
test_tender_data_eu,
test_features_tender_eu_data,
test_bids_eu as test_bids
test_bids_cd as test_bids
)
from openprocurement.tender.openeu.tests.base import (
test_tender_data,
test_features_tender_data as test_features_tender_eu_data
)

test_bids.append(test_bids[0].copy()) # Minimal number of bits is 3


class CompetitiveDialogEUBidResourceTest(BaseCompetitiveDialogEUContentWebTest):
Expand Down Expand Up @@ -764,7 +758,7 @@ def test_bids_invalidation_on_tender_change(self):
self.app.authorization = ('Basic', ('anon', ''))
response = self.app.get('/tenders/{}/bids'.format(self.tender_id))
self.assertEqual(response.status, '200 OK')
self.assertEqual(len(response.json['data']), 7)
self.assertEqual(len(response.json['data']), 6)
for b in response.json['data']:
if b['status'] == u'invalid':
self.assertEqual(set(b.keys()), set(['id', 'status']))
Expand All @@ -785,7 +779,7 @@ def test_bids_invalidation_on_tender_change(self):
self.set_status('complete')
response = self.app.get('/tenders/{}'.format(self.tender_id))
self.assertEqual(response.status, '200 OK')
self.assertEqual(len(response.json['data']['bids']), 7)
self.assertEqual(len(response.json['data']['bids']), 6)
for bid in response.json['data']['bids']:
if bid['id'] in bids_access: # previously invalidated bids
self.assertEqual(bid['status'], 'invalid')
Expand Down Expand Up @@ -843,42 +837,17 @@ class CompetitiveDialogEUBidFeaturesResourceTest(BaseCompetitiveDialogEUContentW
def test_features_bidder(self):
test_features_bids = [
{
# "status": "pending",
"parameters": [
{
"code": i["code"],
"value": 0.1,
}
for i in self.initial_data['features']
],
"tenderers": test_bids[0]["tenderers"],
"value": {
"amount": 469,
"currency": "UAH",
"valueAddedTaxIncluded": True
},
'selfQualified': True,
'selfEligible': True
},
{
"status": "pending",
"parameters": [
{
"code": i["code"],
"value": 0.15,
}
for i in self.initial_data['features']
],
"tenderers": test_bids[1]["tenderers"],
"value": {
"amount": 479,
"currency": "UAH",
"valueAddedTaxIncluded": True
},
'selfQualified': True,
'selfEligible': True
},
]

for i in test_features_bids:
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id), {'data': i})
i['status'] = "pending"
Expand All @@ -889,59 +858,6 @@ def test_features_bidder(self):
bid.pop(u'id')
self.assertEqual(bid, i)

def test_features_bidder_invalid(self):
data = {
"tenderers": test_bids[0]["tenderers"],
"value": {
"amount": 469,
"currency": "UAH",
"valueAddedTaxIncluded": True
},
'selfQualified': True,
'selfEligible': True
}
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id), {'data': data}, status=422)
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
self.assertEqual(response.json['errors'], [
{u'description': [u'This field is required.'], u'location': u'body', u'name': u'parameters'}
])
data["parameters"] = [
{
"code": "OCDS-123454-AIR-INTAKE",
"value": 0.1,
}
]
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id), {'data': data}, status=422)
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
self.assertEqual(response.json['errors'], [
{u'description': [u'All features parameters is required.'], u'location': u'body', u'name': u'parameters'}
])
data["parameters"].append({
"code": "OCDS-123454-AIR-INTAKE",
"value": 0.1,
})
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id), {'data': data}, status=422)
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
self.assertEqual(response.json['errors'], [
{u'description': [u'Parameter code should be uniq for all parameters'], u'location': u'body', u'name': u'parameters'}
])
data["parameters"][1]["code"] = "OCDS-123454-YEARS"
data["parameters"][1]["value"] = 0.2
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id), {'data': data}, status=422)
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
self.assertEqual(response.json['errors'], [
{u'description': [{u'value': [u'value should be one of feature value.']}], u'location': u'body', u'name': u'parameters'}
])


class CompetitiveDialogEUBidDocumentResourceTest(BaseCompetitiveDialogEUContentWebTest):
initial_auth = ('Basic', ('broker', ''))
initial_status = 'active.tendering'
Expand Down
62 changes: 12 additions & 50 deletions openprocurement/tender/competitivedialogue/tests/stage1/lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
BaseCompetitiveDialogEUContentWebTest,
test_tender_data_eu as test_tender_data,
test_tender_data_ua,
test_lots)
from openprocurement.tender.openeu.tests.base import test_bids
from openprocurement.tender.competitivedialogue.models import FEATURES_MAX_SUM
test_lots,
test_bids_cd as test_bids)

test_bids.append(test_bids[0].copy()) # Minimal number of bits is 3
from openprocurement.tender.competitivedialogue.models import FEATURES_MAX_SUM


class CompetitiveDialogueEULotResourceTest(BaseCompetitiveDialogEUContentWebTest):
Expand Down Expand Up @@ -1473,6 +1472,7 @@ def test_1lot_3bid_1del(self):
# create bid
self.app.authorization = ('Basic', ('broker', ''))
bids = []
self.assertEqual(len(test_bids), 3)
bidder_data = deepcopy(test_bids[0]['tenderers'][0])
for index, test_bid in enumerate(test_bids):
bidder_data['identifier']['id'] = str(00037256+index)
Expand All @@ -1487,33 +1487,14 @@ def test_1lot_3bid_1del(self):
response = self.app.delete('/tenders/{}/bids/{}?acc_token={}'.format(tender_id, bids[2].keys()[0],
bids[2].values()[0]))
self.assertEqual(response.status, '200 OK')
# switch to active.pre-qualification
self.time_shift('active.pre-qualification')
self.check_chronograph()

response = self.app.get('/tenders/{}/qualifications?acc_token={}'.format(self.tender_id, owner_token))
self.assertEqual(response.content_type, 'application/json')
qualifications = response.json['data']

for qualification in qualifications:
response = self.app.patch_json('/tenders/{}/qualifications/{}?acc_token={}'.format(self.tender_id,
qualification['id'],
owner_token),
{"data": {'status': 'active', "qualified": True, "eligible": True}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']['status'], 'active')
response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender_id, owner_token),
{"data": {"status": "active.pre-qualification.stand-still"}})
self.assertEqual(response.status, "200 OK")
# try switch to active.pre-qualification
self.time_shift('active.pre-qualification')
self.check_chronograph()

response = self.app.get('/tenders/{}?acc_token={}'.format(self.tender_id, owner_token))
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.status, "200 OK")

response = self.app.get('/tenders/{}/qualifications?acc_token={}'.format(self.tender_id, owner_token))
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.status, "200 OK")
response = self.app.get('/tenders/{}?acc_token={}'.format(tender_id, owner_token))
self.assertTrue(all([i['status'] == 'unsuccessful' for i in response.json['data']['lots']]))
self.assertEqual(response.json['data']['status'], 'unsuccessful')

def test_1lot_3bid_1un(self):
self.app.authorization = ('Basic', ('broker', ''))
Expand Down Expand Up @@ -3147,6 +3128,7 @@ def test_1lot_3bid_1del(self):
self.app.authorization = ('Basic', ('broker', ''))
bids = []
bidder_data = deepcopy(test_bids[0]['tenderers'][0])
self.assertEqual(len(test_bids), 3)
for index, test_bid in enumerate(test_bids):
bidder_data['identifier']['id'] = (00037256+index)
response = self.app.post_json('/tenders/{}/bids'.format(tender_id),
Expand All @@ -3164,29 +3146,9 @@ def test_1lot_3bid_1del(self):
self.time_shift('active.pre-qualification')
self.check_chronograph()

response = self.app.get('/tenders/{}/qualifications?acc_token={}'.format(self.tender_id, owner_token))
self.assertEqual(response.content_type, 'application/json')
qualifications = response.json['data']

for qualification in qualifications:
response = self.app.patch_json('/tenders/{}/qualifications/{}?acc_token={}'.format(self.tender_id,
qualification['id'],
owner_token),
{"data": {'status': 'active', "qualified": True, "eligible": True}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']['status'], 'active')
response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender_id, owner_token),
{"data": {"status": "active.pre-qualification.stand-still"}})
self.assertEqual(response.status, "200 OK")
self.check_chronograph()

response = self.app.get('/tenders/{}?acc_token={}'.format(self.tender_id, owner_token))
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.status, "200 OK")

response = self.app.get('/tenders/{}/qualifications?acc_token={}'.format(self.tender_id, owner_token))
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.status, "200 OK")
self.assertTrue(all([i['status'] == 'unsuccessful' for i in response.json['data']['lots']]))
self.assertEqual(response.json['data']['status'], 'unsuccessful')

def test_1lot_3bid_1un(self):
self.app.authorization = ('Basic', ('broker', ''))
Expand Down

0 comments on commit 7cd9fa7

Please sign in to comment.