def test_put_ok(self): contract, document = prepare_contract_with_document(self) contract_id = contract.data.id document_id = document.data.id target_title = 'test_put_ok' title_before_put = get_document(self, contract_id, document_id).title self.assertNotEqual(title_before_put, target_title, 'titles must differ') put_document(self, contract, document_id, data={'title': target_title}) title_after_put = get_document(self, contract_id, document_id).title self.assertEqual(target_title, title_after_put, 'title was not changed')
def test_patch_forbidden_field(self): new_id = 'abcd' * 8 contract, document = prepare_contract_with_document(self) contract_id = contract.data.id document_id = document.data.id pre_patch_document_id = get_document(self, contract_id, document_id).id self.app.patch_json( CORE_ENDPOINTS['documents'].format(contract_id=contract_id, document_id=document_id) + "?acc_token={}".format(contract.access.token), {'data': { 'id': new_id }}) document_id = get_document(self, contract_id, document_id).id assert document_id != new_id assert document_id == pre_patch_document_id, 'id must remain unchanged'
def test_patch_ok(self): target_tile = 'trololo' contract, document = prepare_contract_with_document(self) contract_id = contract.data.id document_id = document.data.id title_before_patch = get_document(self, contract_id, document_id).title response = self.app.patch_json( CORE_ENDPOINTS['documents'].format(contract_id=contract_id, document_id=document_id) + "?acc_token={}".format(contract.access.token), {'data': { 'title': target_tile }}) title_after_patch = response.json['data']['title'] assert response.status == '200 OK' assert title_before_patch != target_tile assert title_after_patch == target_tile