|
4 | 4 | from webtest import AppError |
5 | 5 | import mock |
6 | 6 | import dateutil.parser |
7 | | - |
| 7 | +import re |
| 8 | +import ast |
8 | 9 | from openprocurement.api.utils import get_now |
9 | 10 | from openprocurement.tender.belowthreshold.tests.base import ( |
10 | | - test_organization, test_draft_claim, test_claim, test_cancellation |
| 11 | + test_organization, test_draft_claim, test_claim, test_cancellation, test_tender_document_data |
11 | 12 | ) |
12 | 13 |
|
13 | 14 |
|
@@ -591,6 +592,79 @@ def create_tender_award_no_scale(self): |
591 | 592 | self.assertNotIn("scale", response.json["data"]["suppliers"][0]) |
592 | 593 |
|
593 | 594 |
|
| 595 | +def create_tender_award_with_the_invalid_document_type(self): |
| 596 | + document_data = test_tender_document_data |
| 597 | + document_data["url"] = self.generate_docservice_url() |
| 598 | + document_data["hash"] = "md5:" + "0" * 32 |
| 599 | + document_data["documentType"] = "smth" |
| 600 | + |
| 601 | + response = self.app.post( |
| 602 | + "/tenders/{}/awards/{}/documents?acc_token={}".format(self.tender_id, self.award_id, self.tender_token), |
| 603 | + upload_files=[("file", "name.doc", "content")], |
| 604 | + ) |
| 605 | + self.assertEqual(response.status, "201 Created") |
| 606 | + self.assertEqual(response.content_type, "application/json") |
| 607 | + |
| 608 | + doc_id = response.json["data"]["id"] |
| 609 | + self.assertIn(doc_id, response.headers["Location"]) |
| 610 | + self.assertEqual(u"name.doc", response.json["data"]["title"]) |
| 611 | + response = self.app.patch_json( |
| 612 | + "/tenders/{}/awards/{}/documents/{}?acc_token={}".format(self.tender_id, self.award_id,doc_id, self.tender_token), |
| 613 | + {"data": {"documentType": "smth"}}, |
| 614 | + status=422, |
| 615 | + ) |
| 616 | + self.assertEqual(response.status, "422 Unprocessable Entity") |
| 617 | + self.assertEqual(response.content_type, "application/json") |
| 618 | + response_doctype_dict = re.findall(r"\[.*\]",response.json["errors"][0]["description"][0])[0] |
| 619 | + response_doctype_dict = ast.literal_eval(response_doctype_dict) |
| 620 | + response_doctype_dict = [n.strip() for n in response_doctype_dict] |
| 621 | + self.assertListEqual( |
| 622 | + response_doctype_dict, |
| 623 | + ["tenderNotice","awardNotice","contractNotice","notice","biddingDocuments","technicalSpecifications", |
| 624 | + "evaluationCriteria","clarifications","shortlistedFirms","riskProvisions","billOfQuantity","bidders", |
| 625 | + "conflictOfInterest","debarments","evaluationReports","winningBid","complaints","contractSigned", |
| 626 | + "contractArrangements","contractSchedule","contractAnnexe","contractGuarantees","subContract", |
| 627 | + "eligibilityCriteria","contractProforma","commercialProposal","qualificationDocuments", |
| 628 | + "eligibilityDocuments","registerExtract","registerFiscal","winningBid","contractTemplate", |
| 629 | + "contractSchema","contractForm","contractData","contractProforma"]) |
| 630 | + |
| 631 | + |
| 632 | +def put_tender_json_award_document_of_document(self): |
| 633 | + response = self.app.post( |
| 634 | + "/tenders/{}/awards/{}/documents?acc_token={}".format(self.tender_id, self.award_id, self.tender_token), |
| 635 | + upload_files=[("file", "name.doc", "content")], |
| 636 | + ) |
| 637 | + self.assertEqual(response.status, "201 Created") |
| 638 | + self.assertEqual(response.content_type, "application/json") |
| 639 | + document_id = response.json["data"]["id"] |
| 640 | + response = self.app.patch_json( |
| 641 | + "/tenders/{}/awards/{}/documents/{}?acc_token={}".format(self.tender_id, self.award_id,document_id, self.tender_token), |
| 642 | + {"data": { |
| 643 | + "title": u"укр.doc", |
| 644 | + "url": self.generate_docservice_url(), |
| 645 | + "hash": "md5:" + "0" * 32, |
| 646 | + "format": "application/msword", |
| 647 | + "documentOf": "document", |
| 648 | + "relatedItem": "0"*32, |
| 649 | + }}, status=422 |
| 650 | + ) |
| 651 | + self.assertEqual(response.status, "422 Unprocessable Entity") |
| 652 | + self.assertEqual(response.content_type, "application/json") |
| 653 | + self.assertEqual( |
| 654 | + response.json["errors"], |
| 655 | + [ |
| 656 | + { |
| 657 | + u"location": u"body", |
| 658 | + u"name": u"relatedItem", |
| 659 | + u"description": [ |
| 660 | + |
| 661 | + u'relatedItem should be one of documents' |
| 662 | + ] |
| 663 | + } |
| 664 | + ] |
| 665 | + ) |
| 666 | + |
| 667 | + |
594 | 668 | # TenderLotAwardResourceTest |
595 | 669 |
|
596 | 670 |
|
|
0 commit comments