Skip to content

Commit

Permalink
Add tests for upload contract docs in pending.winnerSigning status
Browse files Browse the repository at this point in the history
  • Loading branch information
VDigitall committed Mar 19, 2020
1 parent a574902 commit d8c12a8
Show file tree
Hide file tree
Showing 9 changed files with 1,159 additions and 14 deletions.
27 changes: 24 additions & 3 deletions src/openprocurement/tender/belowthreshold/tests/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
patch_tender_contract_status_by_owner,
patch_tender_contract_status_by_supplier,
patch_tender_contract_status_by_others,
create_tender_contract_document_by_supplier,
create_tender_contract_document_by_others,
put_tender_contract_document_by_supplier,
put_tender_contract_document_by_others,
patch_tender_contract_document_by_supplier,
lot2_create_tender_contract_document_by_supplier,
lot2_create_tender_contract_document_by_others,
lot2_put_tender_contract_document_by_supplier,
lot2_patch_tender_contract_document_by_supplier,
)


Expand Down Expand Up @@ -198,6 +207,12 @@ def setUp(self):
self.contract_id = contract["id"]
self.app.authorization = auth

test_create_tender_contract_document_by_supplier = snitch(create_tender_contract_document_by_supplier)
test_create_tender_contract_document_by_others = snitch(create_tender_contract_document_by_others)
test_put_tender_contract_document_by_supplier = snitch(put_tender_contract_document_by_supplier)
test_put_tender_contract_document_by_others = snitch(put_tender_contract_document_by_others)
test_patch_tender_contract_document_by_supplier = snitch(patch_tender_contract_document_by_supplier)


class Tender2LotContractDocumentResourceTest(TenderContentWebTest):
initial_status = "active.qualification"
Expand Down Expand Up @@ -240,15 +255,21 @@ def setUp(self):
self.contract_id = contract["id"]
self.app.authorization = auth

lot2_create_tender_contract_document = snitch(lot2_create_tender_contract_document)
lot2_put_tender_contract_document = snitch(lot2_put_tender_contract_document)
lot2_patch_tender_contract_document = snitch(lot2_patch_tender_contract_document)
test_lot2_create_tender_contract_document = snitch(lot2_create_tender_contract_document)
test_lot2_put_tender_contract_document = snitch(lot2_put_tender_contract_document)
test_lot2_patch_tender_contract_document = snitch(lot2_patch_tender_contract_document)
test_lot2_create_tender_contract_document_by_supplier = snitch(lot2_create_tender_contract_document_by_supplier)
test_lot2_create_tender_contract_document_by_others = snitch(lot2_create_tender_contract_document_by_others)
test_lot2_put_tender_contract_document_by_supplier = snitch(lot2_put_tender_contract_document_by_supplier)
test_lot2_patch_tender_contract_document_by_supplier = snitch(lot2_patch_tender_contract_document_by_supplier)


def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TenderContractResourceTest))
suite.addTest(unittest.makeSuite(TenderContractDocumentResourceTest))
suite.addTest(unittest.makeSuite(TenderContractVATNotIncludedResourceTest))
suite.addTest(unittest.makeSuite(Tender2LotContractDocumentResourceTest))
return suite


Expand Down
897 changes: 886 additions & 11 deletions src/openprocurement/tender/belowthreshold/tests/contract_blanks.py

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/openprocurement/tender/cfaselectionua/tests/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
patch_tender_contract_status_by_owner,
patch_tender_contract_status_by_others,
patch_tender_contract_status_by_supplier,
create_tender_contract_document_by_supplier,
create_tender_contract_document_by_others,
put_tender_contract_document_by_supplier,
put_tender_contract_document_by_others,
patch_tender_contract_document_by_supplier,
lot2_create_tender_contract_document_by_supplier,
lot2_create_tender_contract_document_by_others,
lot2_put_tender_contract_document_by_supplier,
lot2_patch_tender_contract_document_by_supplier,
)


Expand Down Expand Up @@ -135,6 +144,11 @@ class TenderContractDocumentResourceTest(TenderContentWebTest, TenderContractDoc
initial_bids = test_bids
initial_lots = test_lots

test_create_tender_contract_document_by_supplier = snitch(create_tender_contract_document_by_supplier)
test_create_tender_contract_document_by_others = snitch(create_tender_contract_document_by_others)
test_put_tender_contract_document_by_supplier = snitch(put_tender_contract_document_by_supplier)
test_put_tender_contract_document_by_others = snitch(put_tender_contract_document_by_others)
test_patch_tender_contract_document_by_supplier = snitch(patch_tender_contract_document_by_supplier)

@unittest.skip("Skip multi-lots tests")
class Tender2LotContractDocumentResourceTest(TenderContentWebTest):
Expand Down Expand Up @@ -181,6 +195,10 @@ def setUp(self):
lot2_create_tender_contract_document = snitch(lot2_create_tender_contract_document)
lot2_put_tender_contract_document = snitch(lot2_put_tender_contract_document)
lot2_patch_tender_contract_document = snitch(lot2_patch_tender_contract_document)
test_lot2_create_tender_contract_document_by_supplier = snitch(lot2_create_tender_contract_document_by_supplier)
test_lot2_create_tender_contract_document_by_others = snitch(lot2_create_tender_contract_document_by_others)
test_lot2_put_tender_contract_document_by_supplier = snitch(lot2_put_tender_contract_document_by_supplier)
test_lot2_patch_tender_contract_document_by_supplier = snitch(lot2_patch_tender_contract_document_by_supplier)


def suite():
Expand Down
170 changes: 170 additions & 0 deletions src/openprocurement/tender/cfaselectionua/tests/contract_blanks.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,37 @@ def not_found(self):


def create_tender_contract_document(self):
doc = self.db.get(self.tender_id)
for i in doc.get("awards", []):
if 'complaintPeriod' in i:
i["complaintPeriod"]["endDate"] = i["complaintPeriod"]["startDate"]
if doc['contracts'][0]['value']['valueAddedTaxIncluded']:
doc['contracts'][0]['value']['amountNet'] = str(float(doc['contracts'][0]['value']['amount']) - 1)
self.db.save(doc)

response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending.winnerSigning"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending.winnerSigning")

response = self.app.post(
"/tenders/{}/contracts/{}/documents?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
upload_files=[("file", "name.doc", "content")],
status=403
)
self.assertEqual(response.status, "403 Forbidden")
self.assertEqual(response.json["errors"][0]["description"],
"Tender onwer can't add document in current contract status")

response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending")

response = self.app.post(
"/tenders/{}/contracts/{}/documents?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
upload_files=[("file", "name.doc", "content")],
Expand Down Expand Up @@ -656,6 +687,14 @@ def create_tender_contract_document(self):


def put_tender_contract_document(self):
doc = self.db.get(self.tender_id)
for i in doc.get("awards", []):
if 'complaintPeriod' in i:
i["complaintPeriod"]["endDate"] = i["complaintPeriod"]["startDate"]
if doc['contracts'][0]['value']['valueAddedTaxIncluded']:
doc['contracts'][0]['value']['amountNet'] = str(float(doc['contracts'][0]['value']['amount']) - 1)
self.db.save(doc)

response = self.app.post(
"/tenders/{}/contracts/{}/documents?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
upload_files=[("file", "name.doc", "content")],
Expand All @@ -677,6 +716,31 @@ def put_tender_contract_document(self):
self.assertEqual(response.json["status"], "error")
self.assertEqual(response.json["errors"], [{u"description": u"Not Found", u"location": u"body", u"name": u"file"}])

response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending.winnerSigning"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending.winnerSigning")

response = self.app.put(
"/tenders/{}/contracts/{}/documents/{}?acc_token={}".format(
self.tender_id, self.contract_id, doc_id, self.tender_token
),
upload_files=[("file", "name.doc", "content2")],
status=403
)
self.assertEqual(response.status, "403 Forbidden")
self.assertEqual(response.json["errors"][0]["description"],
"Tender onwer can't update document in current contract status")

response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending")

response = self.app.put(
"/tenders/{}/contracts/{}/documents/{}?acc_token={}".format(
self.tender_id, self.contract_id, doc_id, self.tender_token
Expand Down Expand Up @@ -757,6 +821,14 @@ def put_tender_contract_document(self):


def patch_tender_contract_document(self):
doc = self.db.get(self.tender_id)
for i in doc.get("awards", []):
if 'complaintPeriod' in i:
i["complaintPeriod"]["endDate"] = i["complaintPeriod"]["startDate"]
if doc['contracts'][0]['value']['valueAddedTaxIncluded']:
doc['contracts'][0]['value']['amountNet'] = str(float(doc['contracts'][0]['value']['amount']) - 1)
self.db.save(doc)

response = self.app.post(
"/tenders/{}/contracts/{}/documents?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
upload_files=[("file", "name.doc", "content")],
Expand All @@ -766,6 +838,31 @@ def patch_tender_contract_document(self):
doc_id = response.json["data"]["id"]
self.assertIn(doc_id, response.headers["Location"])

response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending.winnerSigning"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending.winnerSigning")

response = self.app.patch_json(
"/tenders/{}/contracts/{}/documents/{}?acc_token={}".format(
self.tender_id, self.contract_id, doc_id, self.tender_token
),
{"data": {"description": "document description"}},
status=403
)
self.assertEqual(response.status, "403 Forbidden")
self.assertEqual(response.json["errors"][0]["description"],
"Tender onwer can't update document in current contract status")

response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending")

response = self.app.patch_json(
"/tenders/{}/contracts/{}/documents/{}?acc_token={}".format(
self.tender_id, self.contract_id, doc_id, self.tender_token
Expand Down Expand Up @@ -820,6 +917,29 @@ def patch_tender_contract_document(self):


def lot2_create_tender_contract_document(self):
response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending.winnerSigning"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending.winnerSigning")

response = self.app.post(
"/tenders/{}/contracts/{}/documents?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
upload_files=[("file", "name.doc", "content")],
status=403
)
self.assertEqual(response.status, "403 Forbidden")
self.assertEqual(response.json["errors"][0]["description"],
"Tender onwer can't add document in current contract status")

response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending")

response = self.app.post(
"/tenders/{}/contracts/{}/documents?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
upload_files=[("file", "name.doc", "content")],
Expand Down Expand Up @@ -873,6 +993,31 @@ def lot2_put_tender_contract_document(self):
self.assertEqual(response.json["status"], "error")
self.assertEqual(response.json["errors"], [{u"description": u"Not Found", u"location": u"body", u"name": u"file"}])

response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending.winnerSigning"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending.winnerSigning")

response = self.app.put(
"/tenders/{}/contracts/{}/documents/{}?acc_token={}".format(
self.tender_id, self.contract_id, doc_id, self.tender_token
),
upload_files=[("file", "name.doc", "content2")],
status=403
)
self.assertEqual(response.status, "403 Forbidden")
self.assertEqual(response.json["errors"][0]["description"],
"Tender onwer can't update document in current contract status")

response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending")

response = self.app.put(
"/tenders/{}/contracts/{}/documents/{}?acc_token={}".format(
self.tender_id, self.contract_id, doc_id, self.tender_token
Expand Down Expand Up @@ -916,6 +1061,31 @@ def lot2_patch_tender_contract_document(self):
doc_id = response.json["data"]["id"]
self.assertIn(doc_id, response.headers["Location"])

response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending.winnerSigning"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending.winnerSigning")

response = self.app.patch_json(
"/tenders/{}/contracts/{}/documents/{}?acc_token={}".format(
self.tender_id, self.contract_id, doc_id, self.tender_token
),
{"data": {"description": "document description"}},
status=403
)
self.assertEqual(response.status, "403 Forbidden")
self.assertEqual(response.json["errors"][0]["description"],
"Tender onwer can't update document in current contract status")

response = self.app.patch_json(
"/tenders/{}/contracts/{}?acc_token={}".format(self.tender_id, self.contract_id, self.tender_token),
{"data": {"status": "pending"}}
)
self.assertEqual(response.status, "200 OK")
self.assertEqual(response.json["data"]["status"], "pending")

response = self.app.patch_json(
"/tenders/{}/contracts/{}/documents/{}?acc_token={}".format(
self.tender_id, self.contract_id, doc_id, self.tender_token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
patch_tender_contract_status_by_owner,
patch_tender_contract_status_by_others,
patch_tender_contract_status_by_supplier,
create_tender_contract_document_by_supplier,
create_tender_contract_document_by_others,
put_tender_contract_document_by_supplier,
put_tender_contract_document_by_others,
patch_tender_contract_document_by_supplier,
)
from openprocurement.tender.openua.tests.contract_blanks import (
# TenderStage2EU(UA)ContractResourceTest
Expand Down Expand Up @@ -117,6 +122,12 @@ def setUp(self):
self.contract_id = contract["id"]
self.app.authorization = ("Basic", ("broker", ""))

test_create_tender_contract_document_by_supplier = snitch(create_tender_contract_document_by_supplier)
test_create_tender_contract_document_by_others = snitch(create_tender_contract_document_by_others)
test_put_tender_contract_document_by_supplier = snitch(put_tender_contract_document_by_supplier)
test_put_tender_contract_document_by_others = snitch(put_tender_contract_document_by_others)
test_patch_tender_contract_document_by_supplier = snitch(patch_tender_contract_document_by_supplier)


class TenderStage2UAContractResourceTest(BaseCompetitiveDialogUAStage2ContentWebTest):
initial_status = "active.qualification"
Expand Down Expand Up @@ -227,6 +238,12 @@ def setUp(self):
self.contract_id = contract["id"]
self.app.authorization = auth

test_create_tender_contract_document_by_supplier = snitch(create_tender_contract_document_by_supplier)
test_create_tender_contract_document_by_others = snitch(create_tender_contract_document_by_others)
test_put_tender_contract_document_by_supplier = snitch(put_tender_contract_document_by_supplier)
test_put_tender_contract_document_by_others = snitch(put_tender_contract_document_by_others)
test_patch_tender_contract_document_by_supplier = snitch(patch_tender_contract_document_by_supplier)


def suite():
suite = unittest.TestSuite()
Expand Down
11 changes: 11 additions & 0 deletions src/openprocurement/tender/esco/tests/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
patch_tender_contract_status_by_owner,
patch_tender_contract_status_by_others,
patch_tender_contract_status_by_supplier,
create_tender_contract_document_by_supplier,
create_tender_contract_document_by_others,
put_tender_contract_document_by_supplier,
put_tender_contract_document_by_others,
patch_tender_contract_document_by_supplier,
)

from openprocurement.tender.openua.tests.contract_blanks import (
Expand Down Expand Up @@ -141,6 +146,12 @@ def setUp(self):
self.contract_id = contract["id"]
self.app.authorization = ("Basic", ("broker", ""))

test_create_tender_contract_document_by_supplier = snitch(create_tender_contract_document_by_supplier)
test_create_tender_contract_document_by_others = snitch(create_tender_contract_document_by_others)
test_put_tender_contract_document_by_supplier = snitch(put_tender_contract_document_by_supplier)
test_put_tender_contract_document_by_others = snitch(put_tender_contract_document_by_others)
test_patch_tender_contract_document_by_supplier = snitch(patch_tender_contract_document_by_supplier)


def suite():
suite = unittest.TestSuite()
Expand Down
Loading

0 comments on commit d8c12a8

Please sign in to comment.