Skip to content

Commit

Permalink
Added tests on procuring entity kinds
Browse files Browse the repository at this point in the history
  • Loading branch information
ktarasz committed Apr 13, 2016
1 parent 85a8c19 commit 1e29001
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 50 deletions.
6 changes: 5 additions & 1 deletion openprocurement/tender/limited/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from openprocurement.api.models import Cancellation as BaseCancellation
from openprocurement.api.models import ITender
from openprocurement.api.models import Contract as BaseContract
from openprocurement.api.models import ProcuringEntity
from openprocurement.tender.openua.models import Complaint
from openprocurement.tender.openua.models import Item

Expand Down Expand Up @@ -120,7 +121,7 @@ class Options:
procurementMethodRationale_en = StringType()
procurementMethodRationale_ru = StringType()
procurementMethodType = StringType(default="reporting")
procuringEntity = ModelType(Organization, required=True) # The entity managing the procurement, which may be different from the buyer who is paying / using the items being procured.
procuringEntity = ModelType(ProcuringEntity, required=True) # The entity managing the procurement, which may be different from the buyer who is paying / using the items being procured.
documents = ListType(ModelType(Document), default=list()) # All documents and attachments related to the tender.
awards = ListType(ModelType(Award), default=list())
contracts = ListType(ModelType(Contract), default=list())
Expand All @@ -135,6 +136,7 @@ class Options:

create_accreditation = 1
edit_accreditation = 2
procuring_entity_kinds = ['general', 'special', 'defense', 'other']

__parent__ = None
__name__ = ''
Expand Down Expand Up @@ -202,6 +204,7 @@ class Tender(ReportingTender):
procurementMethodType = StringType(default="negotiation")
create_accreditation = 3
edit_accreditation = 4
procuring_entity_kinds = ['general', 'special', 'defense']

NegotiationTender = Tender

Expand All @@ -213,5 +216,6 @@ class Tender(NegotiationTender):
procurementMethodType = StringType(default="negotiation.quick")
create_accreditation = 3
edit_accreditation = 4
procuring_entity_kinds = ['general', 'special', 'defense']

NegotiationQuickTender = Tender
60 changes: 30 additions & 30 deletions openprocurement/tender/limited/tests/award.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from openprocurement.tender.limited.tests.base import (
BaseTenderContentWebTest, test_tender_data, test_tender_negotiation_data,
test_tender_negotiation_quick_data)
test_tender_negotiation_quick_data, test_organization)


class TenderAwardResourceTest(BaseTenderContentWebTest):
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_create_tender_award_invalid(self):
])

response = self.app.post_json('/tenders/some_id/awards', {'data': {
'suppliers': [self.initial_data["procuringEntity"]], 'bid_id': 'some_id'}}, status=404)
'suppliers': [test_organization], 'bid_id': 'some_id'}}, status=404)
self.assertEqual(response.status, '404 Not Found')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
Expand All @@ -93,20 +93,20 @@ def test_create_tender_award_invalid(self):
self.set_status('complete')

response = self.app.post_json('/tenders/{}/awards?acc_token={}'.format(self.tender_id, self.tender_token),
{'data': {'suppliers': [self.initial_data["procuringEntity"]],
{'data': {'suppliers': [test_organization],
'status': 'pending'}}, status=403)
self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'][0]["description"], "Can't create award in current (complete) tender status")

def test_create_tender_award(self):
request_path = '/tenders/{}/awards?acc_token={}'.format(self.tender_id, self.tender_token)
response = self.app.post_json(request_path, {'data': {'suppliers': [self.initial_data["procuringEntity"]],
response = self.app.post_json(request_path, {'data': {'suppliers': [test_organization],
'status': 'pending'}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
award = response.json['data']
self.assertEqual(award['suppliers'][0]['name'], self.initial_data["procuringEntity"]['name'])
self.assertEqual(award['suppliers'][0]['name'], test_organization['name'])
self.assertIn('id', award)
self.assertIn(award['id'], response.headers['Location'])

Expand Down Expand Up @@ -140,12 +140,12 @@ def test_create_tender_award(self):

def test_canceling_created_award_and_create_new_one(self):
request_path = '/tenders/{}/awards?acc_token={}'.format(self.tender_id, self.tender_token)
response = self.app.post_json(request_path, {'data': {'suppliers': [self.initial_data["procuringEntity"]],
response = self.app.post_json(request_path, {'data': {'suppliers': [test_organization],
'status': 'pending'}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
award = response.json['data']
self.assertEqual(award['suppliers'][0]['name'], self.initial_data["procuringEntity"]['name'])
self.assertEqual(award['suppliers'][0]['name'], test_organization['name'])
self.assertIn('id', award)
self.assertIn(award['id'], response.headers['Location'])

Expand All @@ -155,7 +155,7 @@ def test_canceling_created_award_and_create_new_one(self):
self.assertEqual(response.json['data'][-1], award)

response = self.app.post_json('/tenders/{}/awards?acc_token={}'.format(
self.tender_id, self.tender_token), {'data': {'suppliers':[self.initial_data["procuringEntity"]], 'status': 'pending'}}, status=403)
self.tender_id, self.tender_token), {'data': {'suppliers':[test_organization], 'status': 'pending'}}, status=403)
self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.json['errors'][0]["description"], "Can't create new award while any (pending) award exists")

Expand All @@ -166,7 +166,7 @@ def test_canceling_created_award_and_create_new_one(self):
self.assertEqual(response.json['data']['status'], u'active')

response = self.app.post_json('/tenders/{}/awards?acc_token={}'.format(
self.tender_id, self.tender_token), {'data': {'suppliers':[self.initial_data["procuringEntity"]], 'status': 'pending'}}, status=403)
self.tender_id, self.tender_token), {'data': {'suppliers':[test_organization], 'status': 'pending'}}, status=403)
self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.json['errors'][0]["description"], "Can't create new award while any (active) award exists")

Expand All @@ -177,12 +177,12 @@ def test_canceling_created_award_and_create_new_one(self):
self.assertEqual(response.json['data']['status'], u'cancelled')

# Create new award
response = self.app.post_json(request_path, {'data': {'suppliers': [self.initial_data["procuringEntity"]],
response = self.app.post_json(request_path, {'data': {'suppliers': [test_organization],
'status': 'pending'}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
new_award = response.json['data']
self.assertEqual(new_award['suppliers'][0]['name'], self.initial_data["procuringEntity"]['name'])
self.assertEqual(new_award['suppliers'][0]['name'], test_organization['name'])
self.assertIn('id', new_award)
self.assertIn(new_award['id'], response.headers['Location'])

Expand All @@ -209,7 +209,7 @@ def test_canceling_created_award_and_create_new_one(self):

def test_patch_tender_award(self):
request_path = '/tenders/{}/awards?acc_token={}'.format(self.tender_id, self.tender_token)
response = self.app.post_json(request_path, {'data': {'suppliers': [self.initial_data["procuringEntity"]],
response = self.app.post_json(request_path, {'data': {'suppliers': [test_organization],
'status': u'pending', "value": {"amount": 500}}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
Expand Down Expand Up @@ -283,7 +283,7 @@ def test_patch_tender_award(self):
self.assertEqual(response.status, '200 OK')

# create new award and test other states
response = self.app.post_json(request_path, {'data': {'suppliers': [self.initial_data["procuringEntity"]],
response = self.app.post_json(request_path, {'data': {'suppliers': [test_organization],
'status': u'pending', "value": {"amount": 500}}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
Expand All @@ -300,7 +300,7 @@ def test_patch_tender_award(self):
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'][0]["description"], "Can't update award in current (unsuccessful) status")

response = self.app.post_json(request_path, {'data': {'suppliers': [self.initial_data["procuringEntity"]],
response = self.app.post_json(request_path, {'data': {'suppliers': [test_organization],
'status': u'pending', "value": {"amount": 500}}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
Expand Down Expand Up @@ -349,7 +349,7 @@ def test_patch_tender_award(self):

def test_patch_tender_award_unsuccessful(self):
request_path = '/tenders/{}/awards?acc_token={}'.format(self.tender_id, self.tender_token)
response = self.app.post_json(request_path, {'data': {'suppliers': [self.initial_data["procuringEntity"]],
response = self.app.post_json(request_path, {'data': {'suppliers': [test_organization],
'status': u'pending', "value": {"amount": 500}}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
Expand Down Expand Up @@ -381,7 +381,7 @@ def test_patch_tender_award_unsuccessful(self):

def test_get_tender_award(self):
response = self.app.post_json('/tenders/{}/awards?acc_token={}'.format(
self.tender_id, self.tender_token), {'data': {'suppliers': [self.initial_data["procuringEntity"]],
self.tender_id, self.tender_token), {'data': {'suppliers': [test_organization],
'status': 'pending'}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
Expand Down Expand Up @@ -427,7 +427,7 @@ def setUp(self):
super(TenderNegotiationAwardComplaintResourceTest, self).setUp()
# Create award
request_path = '/tenders/{}/awards?acc_token={}'.format(self.tender_id, self.tender_token)
response = self.app.post_json(request_path, {'data': {'suppliers': [self.initial_data["procuringEntity"]],
response = self.app.post_json(request_path, {'data': {'suppliers': [test_organization],
'status': 'pending'}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
Expand All @@ -436,7 +436,7 @@ def setUp(self):

def test_create_tender_award_complaint_invalid(self):
response = self.app.post_json('/tenders/some_id/awards/some_id/complaints', {
'data': {'title': 'complaint title', 'description': 'complaint description', 'author': self.initial_data["procuringEntity"]}}, status=404)
'data': {'title': 'complaint title', 'description': 'complaint description', 'author': test_organization}}, status=404)
self.assertEqual(response.status, '404 Not Found')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
Expand Down Expand Up @@ -535,13 +535,13 @@ def test_create_tender_award_complaint(self):
response = self.app.post_json('/tenders/{}/awards/{}/complaints'.format(self.tender_id, self.award_id), {'data': {
'title': 'complaint title',
'description': 'complaint description',
'author': self.initial_data["procuringEntity"],
'author': test_organization,
'status': 'pending'
}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
complaint = response.json['data']
self.assertEqual(complaint['author']['name'], self.initial_data["procuringEntity"]['name'])
self.assertEqual(complaint['author']['name'], test_organization['name'])
self.assertIn('id', complaint)
self.assertIn(complaint['id'], response.headers['Location'])

Expand All @@ -553,14 +553,14 @@ def test_create_tender_award_complaint(self):
self.set_status('unsuccessful')

response = self.app.post_json('/tenders/{}/awards/{}/complaints'.format(
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': self.initial_data["procuringEntity"]}}, status=403)
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': test_organization}}, status=403)
self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'][0]["description"], "Can't add complaint in current (unsuccessful) tender status")

def test_patch_tender_award_complaint(self):
response = self.app.post_json('/tenders/{}/awards/{}/complaints'.format(
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': self.initial_data["procuringEntity"]}})
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': test_organization}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
complaint = response.json['data']
Expand Down Expand Up @@ -643,7 +643,7 @@ def test_patch_tender_award_complaint(self):
self.assertEqual(response.json['data']["cancellationReason"], "reason")

response = self.app.post_json('/tenders/{}/awards/{}/complaints'.format(
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': self.initial_data["procuringEntity"]}})
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': test_organization}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
complaint = response.json['data']
Expand All @@ -664,7 +664,7 @@ def test_review_tender_award_complaint(self):
response = self.app.post_json('/tenders/{}/awards/{}/complaints'.format(self.tender_id, self.award_id), {'data': {
'title': 'complaint title',
'description': 'complaint description',
'author': self.initial_data["procuringEntity"],
'author': test_organization,
'status': 'pending'
}})
self.assertEqual(response.status, '201 Created')
Expand Down Expand Up @@ -703,7 +703,7 @@ def test_review_tender_award_complaint(self):

def test_get_tender_award_complaint(self):
response = self.app.post_json('/tenders/{}/awards/{}/complaints'.format(
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': self.initial_data["procuringEntity"]}})
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': test_organization}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
complaint = response.json['data']
Expand Down Expand Up @@ -733,7 +733,7 @@ def test_get_tender_award_complaint(self):

def test_get_tender_award_complaints(self):
response = self.app.post_json('/tenders/{}/awards/{}/complaints'.format(
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': self.initial_data["procuringEntity"]}})
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': test_organization}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
complaint = response.json['data']
Expand All @@ -758,7 +758,7 @@ def test_get_tender_award_complaints(self):
self.db.save(tender)

response = self.app.post_json('/tenders/{}/awards/{}/complaints'.format(
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': self.initial_data["procuringEntity"]}}, status=403)
self.tender_id, self.award_id), {'data': {'title': 'complaint title', 'description': 'complaint description', 'author': test_organization}}, status=403)
self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'][0]["description"], "Can add complaint only in complaintPeriod")
Expand All @@ -776,15 +776,15 @@ def setUp(self):
# Create award
# Create award
request_path = '/tenders/{}/awards?acc_token={}'.format(self.tender_id, self.tender_token)
response = self.app.post_json(request_path, {'data': {'suppliers': [self.initial_data["procuringEntity"]],
response = self.app.post_json(request_path, {'data': {'suppliers': [test_organization],
'status': 'pending'}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
award = response.json['data']
self.award_id = award['id']
# Create complaint for award
response = self.app.post_json('/tenders/{}/awards/{}/complaints'.format(self.tender_id, self.award_id),
{'data': {'title': 'complaint title', 'description': 'complaint description', 'author': self.initial_data["procuringEntity"]}})
{'data': {'title': 'complaint title', 'description': 'complaint description', 'author': test_organization}})
complaint = response.json['data']
self.complaint_id = complaint['id']
self.complaint_owner_token = response.json['access']['token']
Expand Down Expand Up @@ -1114,7 +1114,7 @@ def setUp(self):
super(TenderAwardDocumentResourceTest, self).setUp()
# Create award
response = self.app.post_json('/tenders/{}/awards?acc_token={}'.format(
self.tender_id, self.tender_token), {'data': {'suppliers': [self.initial_data["procuringEntity"]], 'status': 'pending'}})
self.tender_id, self.tender_token), {'data': {'suppliers': [test_organization], 'status': 'pending'}})
award = response.json['data']
self.award_id = award['id']

Expand Down

0 comments on commit 1e29001

Please sign in to comment.