text: # -*- coding: utf-8 -*-
  import unittest
  from copy import deepcopy
  
  from openprocurement.api.tests.base import snitch
  
  from openprocurement.tender.belowthreshold.tests.base import test_organization, test_author
  from openprocurement.tender.belowthreshold.tests.contract import (
      TenderContractResourceTestMixin,
      TenderContractDocumentResourceTestMixin,
  )
  from openprocurement.tender.belowthreshold.tests.contract_blanks import (
      patch_tender_contract_value,
      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 (
      # TenderContractResourceTest
      create_tender_contract,
      patch_tender_contract_datesigned,
  )
  
  from openprocurement.tender.openeu.tests.base import BaseTenderContentWebTest, test_tender_data, test_bids
  from openprocurement.tender.openeu.tests.contract_blanks import (
      # TenderContractResourceTest
      contract_termination,
      patch_tender_contract,
  )
  
  
  class TenderContractResourceTest(BaseTenderContentWebTest, TenderContractResourceTestMixin):
      # initial_data = tender_data
      initial_status = "active.qualification"
      initial_bids = test_bids
      initial_auth = ("Basic", ("broker", ""))
      author_data = test_author
  
      def setUp(self):
          super(TenderContractResourceTest, self).setUp()
          # Create award
          self.supplier_info = deepcopy(test_organization)
          self.app.authorization = ("Basic", ("token", ""))
          response = self.app.post_json(
              "/tenders/{}/awards".format(self.tender_id),
              {
                  "data": {
                      "suppliers": [self.supplier_info],
                      "status": "pending",
                      "bid_id": self.initial_bids[0]["id"],
                      "value": {"amount": 500, "currency": "UAH", "valueAddedTaxIncluded": True},
                      "items": test_tender_data["items"],
                  }
              },
          )
          award = response.json["data"]
          self.award_id = award["id"]
          self.app.authorization = ("Basic", ("broker", ""))
          self.app.patch_json(
              "/tenders/{}/awards/{}?acc_token={}".format(self.tender_id, self.award_id, self.tender_token),
              {"data": {"status": "active", "qualified": True, "eligible": True}},
          )
  
      test_contract_termination = snitch(contract_termination)
      test_create_tender_contract = snitch(create_tender_contract)
      test_patch_tender_contract_datesigned = snitch(patch_tender_contract_datesigned)
      test_patch_tender_contract = snitch(patch_tender_contract)
      test_patch_tender_contract_value = snitch(patch_tender_contract_value)
      test_patch_tender_contract_status_by_owner = snitch(patch_tender_contract_status_by_owner)
      test_patch_tender_contract_status_by_others = snitch(patch_tender_contract_status_by_others)
      test_patch_tender_contract_status_by_supplier = snitch(patch_tender_contract_status_by_supplier)
  
  
  class TenderContractDocumentResourceTest(BaseTenderContentWebTest, TenderContractDocumentResourceTestMixin):
      # initial_data = tender_data
      initial_status = "active.qualification"
      initial_bids = test_bids
      initial_auth = ("Basic", ("broker", ""))
  
      def setUp(self):
          super(TenderContractDocumentResourceTest, self).setUp()
          # Create award
          supplier_info = deepcopy(test_organization)
          self.app.authorization = ("Basic", ("token", ""))
          response = self.app.post_json(
              "/tenders/{}/awards".format(self.tender_id),
              {"data": {"suppliers": [supplier_info], "status": "pending", "bid_id": self.initial_bids[0]["id"]}},
          )
          award = response.json["data"]
          self.award_id = award["id"]
          self.app.patch_json(
              "/tenders/{}/awards/{}".format(self.tender_id, self.award_id),
              {"data": {"status": "active", "qualified": True, "eligible": True}},
          )
          # Create contract for award
          response = self.app.post_json(
              "/tenders/{}/contracts".format(self.tender_id),
              {"data": {"title": "contract title", "description": "contract description", "awardID": self.award_id}},
          )
          contract = response.json["data"]
          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()
      suite.addTest(unittest.makeSuite(TenderContractResourceTest))
      suite.addTest(unittest.makeSuite(TenderContractDocumentResourceTest))
      return suite
  
  
  if __name__ == "__main__":
      unittest.main(defaultTest="suite")
  