def fixture_created(self):
        contract = Contract(contract_data)
        contract.__parent__ = fixture_auction()
        contract.signingPeriod = Period({
            'startDate': '2000-01-01T10:00:00+02:00',
            'endDate': '2000-01-10T10:00:00+02:00'
        })

        prolongation = Prolongation(self.fixture_required_data())
        contract.prolongations.append(contract)
        prolongation.__parent__ = contract  # mock

        prolongation_doc = self.fixture_document()
        prolongation_doc.__parent__ = prolongation
        prolongation.documents.append(prolongation_doc)
        return (contract, prolongation)
def get_related_contract(test_case):
    """This is utility for testing, not a blank test
    """
    contract_response = test_case.app.get(PATHS['contract'].format(
        auction_id=test_case.auction_id,
        contract_id=test_case.contract_id,
        token=test_case.auction_token))
    return Contract(contract_response.json['data'])
 def test_datePaid_when_signingPeriod_None(self):
     contract = Contract(contract_data)
     period = Period()
     period.startDate = datetime(2000, 1, 1)
     period.endDate = datetime(2000, 1, 10)
     contract.signingPeriod = period
     contract.datePaid = None
     contract.validate()
    def test_datePaid_good_date(self):
        start_of_signing_period = datetime(2000, 1, 1)
        end_of_signing_period = datetime(2000, 1, 10)
        good_datepaid1 = datetime(2000, 1, 5)
        good_datepaid2 = datetime(2000, 1, 1)
        period = Period()

        period.startDate = start_of_signing_period
        period.endDate = end_of_signing_period

        contract = Contract(contract_data)
        contract.signingPeriod = period
        period.validate()

        contract.datePaid = good_datepaid1
        contract.validate()
        # datePaid must be not greater than start of signingPeriod
        contract.datePaid = good_datepaid2
        contract.validate()
 def test_datePaid_wrong_date(self):
     contract = Contract(contract_data)
     period = Period()
     period.startDate = datetime(2000, 1, 1)
     period.endDate = datetime(2000, 1, 10)
     contract.signingPeriod = period
     self.db.commit()
     with self.assertRaises(ValidationError) as _:  # noqa: F841
         contract.datePaid = datetime(1999, 12, 30)
         contract.validate()