# -*- coding: utf-8 -*-
from datetime import timedelta

from openprocurement.api.utils import get_now

# TenderContractResourceTest


def patch_tender_contract(self):
    response = self.app.get('/tenders/{}/contracts'.format(self.tender_id))
    contract = response.json['data'][0]

    fake_contractID = "myselfID"
    fake_items_data = [{"description": "New Description"}]
    fake_suppliers_data = [{"name": "New Name"}]

    response = self.app.patch_json('/tenders/{}/contracts/{}?acc_token={}'.format(
        self.tender_id, contract['id'], self.tender_token),
                                   {"data": {"contractID": fake_contractID,
                                             "items": fake_items_data,
                                             "suppliers": fake_suppliers_data}})

    response = self.app.get('/tenders/{}/contracts/{}'.format(self.tender_id, contract['id']))
    self.assertNotEqual(fake_contractID, response.json['data']['contractID'])
    self.assertNotEqual(fake_items_data, response.json['data']['items'])
    self.assertNotEqual(fake_suppliers_data, response.json['data']['suppliers'])