From 8d06cc24399d42f51555738664a4b35e7401014b Mon Sep 17 00:00:00 2001 From: Vladyslav Velychko Date: Tue, 8 Aug 2017 14:23:55 +0300 Subject: [PATCH 1/3] Added client for the registry --- openprocurement_client/registry_client.py | 108 ++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 openprocurement_client/registry_client.py diff --git a/openprocurement_client/registry_client.py b/openprocurement_client/registry_client.py new file mode 100644 index 0000000..45368c5 --- /dev/null +++ b/openprocurement_client/registry_client.py @@ -0,0 +1,108 @@ +import logging + +from .api_base_client import APIBaseClient, APITemplateClient, verify_file +from .exceptions import InvalidResponse + +from iso8601 import parse_date +from munch import munchify +from retrying import retry +from simplejson import loads + + + + +class RegistryClient(APIBaseClient): + """ Client for validate members by EDR """ + + host_url = 'https://192.168.50.9' + api_version = '0.1' + + def __init__(self, + key, + resource='lots', # another possible value is 'assets' + host_url=None, + api_version=None, + params=None, + ds_client=None, + user_agent=None): + super(RegistryClient, self).__init__( + key, resource, host_url, api_version, params, ds_client, + user_agent + ) + self.host_url = host_url or self.host_url + self.api_version = api_version or self.api_version + + def get_assets(self, extra_headers=None): + self.headers.update(extra_headers or {}) + response = self.request( + 'GET', + '{}/api/{}/assets'.format(self.host_url, self.api_version) + ) + return process_response(response) + + def get_lots(self, extra_headers=None): + self.headers.update(extra_headers or {}) + response = self.request( + 'GET', + '{}/api/{}/lots'.format(self.host_url, self.api_version) + ) + return process_response(response) + + def get_asset(self, asset_id=None, extra_headers=None): + self.headers.update(extra_headers or {}) + response = self.request( + 'GET', + '{}/api/{}/asssets/{}'.format(self.host_url, self.api_version, asset_id) + ) + return process_response(response) + + def get_lot(self, lot_id=None, extra_headers=None): + self.headers.update(extra_headers or {}) + response = self.request( + 'GET', + '{}/api/{}/lot/{}'.format(self.host_url, self.api_version, lot_id) + ) + return process_response(response) + + def patch_asset(self, asset): + return self._patch_resource_item( + '{}/{}'.format(self.prefix_path, asset['data']['id']), + payload=asset, + headers={'X-Access-Token': self._get_access_token(asset)} + ) + def patch_lot(self, lot): + return self._patch_resource_item( + '{}/{}'.format(self.prefix_path, lot['data']['id']), + payload=lot, + headers={'X-Access-Token': self._get_access_token(lot)} + ) + +class RegistryClientSync(RegistryClient): + + def sync_item(self, params=None, extra_headers=None): + _params = (params or {}).copy() + _params['feed'] = 'changes' + self.headers.update(extra_headers or {}) + + response = self.request('GET', self.prefix_path, + params_dict=_params) + if response.status_code == 200: + item_list = munchify(loads(response.text)) + return item_list + + @retry(stop_max_attempt_number=5) + def get_lot_by_id(self, id, extra_headers=None): + self.headers.update(extra_headers or {}) + return super(RegistryClientSync, self).get_lot(id) + + @retry(stop_max_attempt_number=5) + def get_asset_by_id(self, id, extra_headers=None): + self.headers.update(extra_headers or {}) + return super(RegistryClientSync, self).get_asset(id) + + + +def process_response(response): + if response.status_code == 200: + return munchify(loads(response.text)) + raise InvalidResponse(response) From a3ebbe3deba06109b86db27082334a94cae5a8dc Mon Sep 17 00:00:00 2001 From: Vladyslav Velychko Date: Wed, 9 Aug 2017 17:35:46 +0300 Subject: [PATCH 2/3] RegistryClient tests and bugs fixing --- openprocurement_client/api_base_client.py | 1 + openprocurement_client/registry_client.py | 14 +- openprocurement_client/tests/_server.py | 14 +- ...sset_668c3156c8cb496fb28359909cde6e96.json | 272 ++++++++++ ...sset_823d50b3236247adad28a5a66f74db42.json | 504 ++++++++++++++++++ openprocurement_client/tests/data/assets.json | 153 ++++++ .../lot_668c3156c8cb496fb28359909cde6e96.json | 272 ++++++++++ .../lot_823d50b3236247adad28a5a66f74db42.json | 504 ++++++++++++++++++ openprocurement_client/tests/data/lots.json | 153 ++++++ openprocurement_client/tests/data_dict.py | 16 + .../tests/registry_tests.py | 165 ++++++ 11 files changed, 2062 insertions(+), 6 deletions(-) create mode 100644 openprocurement_client/tests/data/asset_668c3156c8cb496fb28359909cde6e96.json create mode 100644 openprocurement_client/tests/data/asset_823d50b3236247adad28a5a66f74db42.json create mode 100644 openprocurement_client/tests/data/assets.json create mode 100644 openprocurement_client/tests/data/lot_668c3156c8cb496fb28359909cde6e96.json create mode 100644 openprocurement_client/tests/data/lot_823d50b3236247adad28a5a66f74db42.json create mode 100644 openprocurement_client/tests/data/lots.json create mode 100644 openprocurement_client/tests/registry_tests.py diff --git a/openprocurement_client/api_base_client.py b/openprocurement_client/api_base_client.py index 3ccc095..70e8185 100644 --- a/openprocurement_client/api_base_client.py +++ b/openprocurement_client/api_base_client.py @@ -126,6 +126,7 @@ def __init__(self, @staticmethod def _get_access_token(obj): + return getattr(getattr(obj, 'access', ''), 'token', '') def _update_params(self, params): diff --git a/openprocurement_client/registry_client.py b/openprocurement_client/registry_client.py index 45368c5..e25f7fe 100644 --- a/openprocurement_client/registry_client.py +++ b/openprocurement_client/registry_client.py @@ -19,7 +19,7 @@ class RegistryClient(APIBaseClient): def __init__(self, key, - resource='lots', # another possible value is 'assets' + resource='assets', # another possible value is 'assets' host_url=None, api_version=None, params=None, @@ -41,6 +41,9 @@ def get_assets(self, extra_headers=None): return process_response(response) def get_lots(self, extra_headers=None): + + resp = self.request('GET', 'http://localhost:20602/api/0.10/lots') + self.headers.update(extra_headers or {}) response = self.request( 'GET', @@ -50,21 +53,25 @@ def get_lots(self, extra_headers=None): def get_asset(self, asset_id=None, extra_headers=None): self.headers.update(extra_headers or {}) + response = self.request( 'GET', - '{}/api/{}/asssets/{}'.format(self.host_url, self.api_version, asset_id) + '{}/api/{}/assets/{}'.format(self.host_url, self.api_version, asset_id) ) return process_response(response) def get_lot(self, lot_id=None, extra_headers=None): + self.headers.update(extra_headers or {}) + response = self.request( 'GET', - '{}/api/{}/lot/{}'.format(self.host_url, self.api_version, lot_id) + '{}/api/{}/lots/{}'.format(self.host_url, self.api_version, lot_id) ) return process_response(response) def patch_asset(self, asset): + return self._patch_resource_item( '{}/{}'.format(self.prefix_path, asset['data']['id']), payload=asset, @@ -103,6 +110,7 @@ def get_asset_by_id(self, id, extra_headers=None): def process_response(response): + if response.status_code == 200: return munchify(loads(response.text)) raise InvalidResponse(response) diff --git a/openprocurement_client/tests/_server.py b/openprocurement_client/tests/_server.py index 62e9dbf..00c77a3 100755 --- a/openprocurement_client/tests/_server.py +++ b/openprocurement_client/tests/_server.py @@ -1,10 +1,10 @@ -from bottle import request, response, redirect, static_file +from bottle import request, response, redirect, static_file, run from munch import munchify from simplejson import dumps, load from openprocurement_client.document_service_client \ import DocumentServiceClient from openprocurement_client.tests.data_dict import TEST_TENDER_KEYS, \ - TEST_PLAN_KEYS, TEST_CONTRACT_KEYS + TEST_PLAN_KEYS, TEST_CONTRACT_KEYS, TEST_LOT_KEYS, TEST_ASSET_KEYS import magic import os @@ -26,7 +26,9 @@ RESOURCE_DICT = \ {'tender': {'sublink': 'tenders', 'data': TEST_TENDER_KEYS}, 'contract': {'sublink': 'contracts', 'data': TEST_CONTRACT_KEYS}, - 'plan': {'sublink': 'plans', 'data': TEST_PLAN_KEYS}} + 'plan': {'sublink': 'plans', 'data': TEST_PLAN_KEYS}, + 'lot': {'sublink': 'lots', 'data': TEST_LOT_KEYS}, + 'asset': {'sublink': 'assets', 'data': TEST_ASSET_KEYS}} def resource_filter(resource_name): @@ -330,6 +332,12 @@ def contract_change_patch(contract_id, change_id): "contract_change_patch": (API_PATH.format('contracts') + '//changes/', 'PATCH', contract_change_patch), "contract_patch": (API_PATH.format('') + "/", 'PATCH', resource_patch), "contract_patch_credentials": (API_PATH.format('') + '//credentials', 'PATCH', patch_credentials), + "assets": (API_PATH.format(''), 'GET', resource_page_get), + "asset": (API_PATH.format('') + '/', 'GET', resource_page), + "asset_patch": (API_PATH.format('') + "/", 'PATCH', resource_patch), + "lots": (API_PATH.format(''), 'GET', resource_page_get), + "lot": (API_PATH.format('') + '/', 'GET', resource_page), + "lot_patch": (API_PATH.format('') + "/", 'PATCH', resource_patch), } diff --git a/openprocurement_client/tests/data/asset_668c3156c8cb496fb28359909cde6e96.json b/openprocurement_client/tests/data/asset_668c3156c8cb496fb28359909cde6e96.json new file mode 100644 index 0000000..27e133b --- /dev/null +++ b/openprocurement_client/tests/data/asset_668c3156c8cb496fb28359909cde6e96.json @@ -0,0 +1,272 @@ +{ + "access": { + "token": "0fc58c83963d42a692db4987df86640a" + }, + "data": { + "procurementMethod": "limited", + "status": "cancelled", + "documents": [ + { + "format": "text/plain", + "url": "https://api-sandbox.openprocurement.org/api/0.12/tenders/668c3156c8cb496fb28359909cde6e96/documents/3f82c7ef80a745119b6a6dec2670e5bc?download=0fc58c83963d42a692db4987df86640a", + "title": "/tmp/tmp5k4QEL", + "documentOf": "tender", + "datePublished": "2016-02-18T14:45:40.348569+02:00", + "dateModified": "2016-02-18T14:45:40.348612+02:00", + "id": "3f82c7ef80a745119b6a6dec2670e5bc" + } + ], + "title": "\u041f\u043e\u0441\u043b\u0443\u0433\u0438 \u0448\u043a\u0456\u043b\u044c\u043d\u0438\u0445 \u0457\u0434\u0430\u043b\u0435\u043d\u044c", + "contracts": [ + { + "status": "pending", + "awardID": "70eaaceee81e4f378e333c1ed8258652", + "id": "c65d3526cdc44f75b2457b4489970a7c" + } + ], + "items": [ + { + "description": "\u041f\u043e\u0441\u043b\u0443\u0433\u0438 \u0448\u043a\u0456\u043b\u044c\u043d\u0438\u0445 \u0457\u0434\u0430\u043b\u0435\u043d\u044c", + "classification": { + "scheme": "CPV", + "description": "\u041f\u043e\u0441\u043b\u0443\u0433\u0438 \u0437 \u0445\u0430\u0440\u0447\u0443\u0432\u0430\u043d\u043d\u044f \u0443 \u0448\u043a\u043e\u043b\u0430\u0445", + "id": "55523100-3" + }, + "additionalClassifications": [ + { + "scheme": "\u0414\u041a\u041f\u041f", + "id": "55.51.10.300", + "description": "\u041f\u043e\u0441\u043b\u0443\u0433\u0438 \u0448\u043a\u0456\u043b\u044c\u043d\u0438\u0445 \u0457\u0434\u0430\u043b\u0435\u043d\u044c" + } + ], + "deliveryLocation": { + "latitude": 49.85, + "longitude": 24.0167 + }, + "deliveryAddress": { + "locality": "\u043c. \u041a\u0438\u0457\u0432", + "region": "\u043c. \u041a\u0438\u0457\u0432", + "countryName_en": "Ukraine", + "countryName": "\u0423\u043a\u0440\u0430\u0457\u043d\u0430", + "streetAddress": "481 John Pine Suite 803", + "countryName_ru": "\u0423\u043a\u0440\u0430\u0438\u043d\u0430", + "postalCode": "58662" + }, + "deliveryDate": { + "endDate": "2016-02-23T14:42:28.297330+02:00" + }, + "id": "2dc54675d6364e2baffbc0f8e74432ac", + "unit": { + "code": "MON", + "name": "month" + }, + "quantity": 9 + } + ], + "complaints": [ + { + "status": "resolved", + "documents": [ + { + "author": "complaint_owner", + "format": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "url": "https://lb.api-sandbox.openprocurement.org/api/0.12/tenders/cdec9f009be44f53817754b12d292ef2/complaints/22b086222a7a4bc6a9cc8adeaa91a57f/documents/129f4013b33a45b8bc70699a62a81499?download=7a6787929a624dd8b7c067974b9e8a96", + "title": "/tmp/tmpcFrLvz.docx", + "documentOf": "tender", + "datePublished": "2016-02-29T15:05:54.557614+02:00", + "dateModified": "2016-02-29T15:05:54.557656+02:00", + "id": "129f4013b33a45b8bc70699a62a81499" + } + ], + "description": "Consequuntur sint cupiditate impedit et magnam aut odit eligendi dicta magnam dicta eveniet.", + "tendererActionDate": "2016-02-29T15:06:05.212783+02:00", + "title": "Hic laboriosam magni cupiditate enim placeat in dolorem.", + "resolutionType": "resolved", + "resolution": "Non ipsa accusantium iste et dolorum quo temporibus deserunt et provident suscipit.", + "satisfied": true, + "dateAnswered": "2016-02-29T15:06:05.212741+02:00", + "tendererAction": "Labore adipisci sequi corporis neque delectus ea aut dicta molestiae omnis voluptatem qui et.", + "dateSubmitted": "2016-02-29T15:06:01.956017+02:00", + "date": "2016-02-29T15:05:53.084688+02:00", + "type": "claim", + "id": "22b086222a7a4bc6a9cc8adeaa91a57f" + }, + { + "status": "cancelled", + "description": "Sit cumque iste eius corporis exercitationem voluptate.", + "title": "Commodi voluptatem earum sapiente doloremque.", + "cancellationReason": "prosto tak :)", + "dateCanceled": "2016-02-29T15:06:19.281225+02:00", + "date": "2016-02-29T15:06:17.694889+02:00", + "type": "claim", + "id": "d26fc2f475514652a53c0c551d984be3" + }, + { + "status": "cancelled", + "description": "Eos officia vel aliquid id qui provident suscipit eos nam amet.", + "title": "Voluptas debitis cupiditate deserunt inventore fugit quo nemo dicta.", + "cancellationReason": "prosto tak :)", + "dateCanceled": "2016-02-29T15:06:28.419955+02:00", + "dateSubmitted": "2016-02-29T15:06:26.927454+02:00", + "date": "2016-02-29T15:06:24.962751+02:00", + "type": "claim", + "id": "816eb0529d6d41148dac0edabc119407" + }, + { + "status": "cancelled", + "dateCanceled": "2016-02-29T15:06:37.390093+02:00", + "tendererActionDate": "2016-02-29T15:06:35.767209+02:00", + "description": "Non voluptas ipsa ex quibusdam dolorem rem dolores sequi.", + "title": "Et esse eos unde molestiae cum sunt.", + "resolutionType": "resolved", + "resolution": "Cumque magni vitae officiis odit et mollitia neque dolores reprehenderit.", + "cancellationReason": "prosto tak :)", + "dateAnswered": "2016-02-29T15:06:35.767171+02:00", + "tendererAction": "Architecto dolor dolorem ut labore esse possimus odit a unde hic quas error alias nulla.", + "dateSubmitted": "2016-02-29T15:06:34.170608+02:00", + "date": "2016-02-29T15:06:32.488624+02:00", + "type": "claim", + "id": "ec053962ce334bdaaab8b3bf2e6b3173" + }, + { + "status": "cancelled", + "dateCanceled": "2016-02-29T15:06:55.181473+02:00", + "tendererActionDate": "2016-02-29T15:06:45.067477+02:00", + "description": "Et autem reiciendis eaque dolorem adipisci aut.", + "title": "Ipsum cupiditate ipsam ut non.", + "resolutionType": "resolved", + "resolution": "Qui vitae placeat rerum officia quia aperiam illo nisi velit et fuga ducimus dolor.", + "author": { + "contactPoint": { + "name": "Варвара Талан", + "telephone": "+38 (268) 501-16-45" + }, + "identifier": { + "scheme": "UA-EDR", + "id": "00007460", + "uri": "http://dummyimage.com/506x880" + }, + "name": "Терещук-Приймак", + "address": { + "locality": "м. Вінниця", + "region": "Вінницька область", + "countryName_en": "Ukraine", + "countryName": "Україна", + "streetAddress": "73741 John Pass", + "countryName_ru": "Украина", + "postalCode": "21100" + } + }, + "satisfied": false, + "dateEscalated": "2016-02-29T15:06:46.828487+02:00", + "dateAnswered": "2016-02-29T15:06:45.067440+02:00", + "tendererAction": "Ex optio cumque assumenda iure consectetur unde iste et consequatur at quaerat dolor.", + "dateSubmitted": "2016-02-29T15:06:43.326331+02:00", + "date": "2016-02-29T15:06:41.513902+02:00", + "cancellationReason": "prosto tak :)", + "type": "complaint", + "id": "76f0f99cb643434da21b6a6350cc2d0e" + } + ], + "procurementMethodType": "reporting", + "cancellations": [ + { + "status": "active", + "documents": [ + { + "description": "test description", + "format": "text/plain", + "url": "https://api-sandbox.openprocurement.org/api/0.12/tenders/668c3156c8cb496fb28359909cde6e96/cancellations/0dd6f9e8cc4f4d1c9c404d842b56d0d7/documents/1afca9faaf2b4f9489ee264b136371c6?download=57e135c2f8d342c3a506be20940a3f3c", + "title": "/tmp/tmpdhdoax", + "documentOf": "tender", + "datePublished": "2016-02-18T14:46:05.348204+02:00", + "dateModified": "2016-02-18T14:46:05.348246+02:00", + "id": "1afca9faaf2b4f9489ee264b136371c6" + }, + { + "description": "test description", + "format": "text/plain", + "url": "https://api-sandbox.openprocurement.org/api/0.12/tenders/668c3156c8cb496fb28359909cde6e96/cancellations/0dd6f9e8cc4f4d1c9c404d842b56d0d7/documents/1afca9faaf2b4f9489ee264b136371c6?download=9208a5fa7cf140a2bb4751a42a1f1ea9", + "title": "/tmp/tmpOBUlWP", + "documentOf": "tender", + "datePublished": "2016-02-18T14:46:05.348204+02:00", + "dateModified": "2016-02-18T14:46:08.516130+02:00", + "id": "1afca9faaf2b4f9489ee264b136371c6" + } + ], + "reason": "prost :))", + "date": "2016-02-18T14:46:04.344125+02:00", + "cancellationOf": "tender", + "id": "0dd6f9e8cc4f4d1c9c404d842b56d0d7" + } + ], + "value": { + "currency": "UAH", + "amount": 500000.0, + "valueAddedTaxIncluded": true + }, + "id": "668c3156c8cb496fb28359909cde6e96", + "awards": [ + { + "status": "active", + "complaintPeriod": { + "startDate": "2016-02-18T14:45:41.212240+02:00", + "endDate": "2016-02-19T14:45:42.178932+02:00" + }, + "suppliers": [ + { + "contactPoint": { + "telephone": "+380 (432) 21-69-30", + "name": "\u0421\u0435\u0440\u0433\u0456\u0439 \u041e\u043b\u0435\u043a\u0441\u044e\u043a", + "email": "soleksuk@gmail.com" + }, + "identifier": { + "scheme": "UA-EDR", + "id": "13313462", + "uri": "http://sch10.edu.vn.ua/", + "legalName": "\u0414\u0435\u0440\u0436\u0430\u0432\u043d\u0435 \u043a\u043e\u043c\u0443\u043d\u0430\u043b\u044c\u043d\u0435 \u043f\u0456\u0434\u043f\u0440\u0438\u0454\u043c\u0441\u0442\u0432\u043e \u0433\u0440\u043e\u043c\u0430\u0434\u0441\u044c\u043a\u043e\u0433\u043e \u0445\u0430\u0440\u0447\u0443\u0432\u0430\u043d\u043d\u044f \u00ab\u0428\u043a\u043e\u043b\u044f\u0440\u00bb" + }, + "name": "\u0414\u041a\u041f \u00ab\u0428\u043a\u043e\u043b\u044f\u0440\u00bb", + "address": { + "postalCode": "21100", + "countryName": "\u0423\u043a\u0440\u0430\u0457\u043d\u0430", + "streetAddress": "\u0432\u0443\u043b. \u041e\u0441\u0442\u0440\u043e\u0432\u0441\u044c\u043a\u043e\u0433\u043e, 33", + "region": "\u043c. \u0412\u0456\u043d\u043d\u0438\u0446\u044f", + "locality": "\u043c. \u0412\u0456\u043d\u043d\u0438\u0446\u044f" + } + } + ], + "value": { + "currency": "UAH", + "amount": 475000.0, + "valueAddedTaxIncluded": true + }, + "date": "2016-02-18T14:45:41.210928+02:00", + "id": "70eaaceee81e4f378e333c1ed8258652" + } + ], + "tenderID": "UA-2016-02-18-000031", + "owner": "test.quintagroup.com", + "dateModified": "2016-02-18T14:46:09.940361+02:00", + "procuringEntity": { + "contactPoint": { + "url": "http://sch10.edu.vn.ua/", + "name": "\u041a\u0443\u0446\u0430 \u0421\u0432\u0456\u0442\u043b\u0430\u043d\u0430 \u0412\u0430\u043b\u0435\u043d\u0442\u0438\u043d\u0456\u0432\u043d\u0430", + "telephone": "+380 (432) 46-53-02" + }, + "identifier": { + "scheme": "UA-EDR", + "id": "21725150", + "legalName": "\u0417\u0430\u043a\u043b\u0430\u0434 \"\u0417\u0430\u0433\u0430\u043b\u044c\u043d\u043e\u043e\u0441\u0432\u0456\u0442\u043d\u044f \u0448\u043a\u043e\u043b\u0430 \u0406-\u0406\u0406\u0406 \u0441\u0442\u0443\u043f\u0435\u043d\u0456\u0432 \u2116 10 \u0412\u0456\u043d\u043d\u0438\u0446\u044c\u043a\u043e\u0457 \u043c\u0456\u0441\u044c\u043a\u043e\u0457 \u0440\u0430\u0434\u0438\"" + }, + "name": "\u0417\u041e\u0421\u0428 #10 \u043c.\u0412\u0456\u043d\u043d\u0438\u0446\u0456", + "address": { + "postalCode": "21027", + "countryName": "\u0423\u043a\u0440\u0430\u0457\u043d\u0430", + "streetAddress": "\u0432\u0443\u043b. \u0421\u0442\u0430\u0445\u0443\u0440\u0441\u044c\u043a\u043e\u0433\u043e. 22", + "region": "\u043c. \u0412\u0456\u043d\u043d\u0438\u0446\u044f", + "locality": "\u043c. \u0412\u0456\u043d\u043d\u0438\u0446\u044f" + } + } + } +} diff --git a/openprocurement_client/tests/data/asset_823d50b3236247adad28a5a66f74db42.json b/openprocurement_client/tests/data/asset_823d50b3236247adad28a5a66f74db42.json new file mode 100644 index 0000000..27b7f37 --- /dev/null +++ b/openprocurement_client/tests/data/asset_823d50b3236247adad28a5a66f74db42.json @@ -0,0 +1,504 @@ +{ + "data":{ + "procurementMethod":"open", + "status":"complete", + "tenderPeriod":{ + "startDate":"2015-12-30T03:05:00+02:00", + "endDate":"2015-12-31T03:05:00+02:00" + }, + "qualifications": [ + { + "status": "pending", + "id": "cec4b82d2708465291fb4af79f8a3e52", + "bidID": "c41709780fa8434399c62a1facf369cb", + "documents": [ + { + "confidentiality": "public", + "language": "uk", + "title": "Proposal.pdf", + "url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/e3e16eb63b584378b75d9eb01dc2f8b9/bids/c41709780fa8434399c62a1facf369cb/documents/a05aff4e91c942bbad7e49e551399ec7?download=d0984048f149465699fd402bfe20881c", + "format": "application/pdf", + "documentOf": "tender", + "datePublished": "2016-02-24T14:13:36.127526+02:00", + "id": "a05aff4e91c942bbad7e49e551399ec7", + "dateModified": "2016-02-24T14:13:36.127580+02:00" + }] + }, + { + "status": "pending", + "id": "9d562bbbf05e44f8a6a1f07ddb0415b1", + "bidID": "dda102997a4d4d5d8b5dac6ce2225e1c" + }, + { + "status": "pending", + "id": "36ac59607c434c8198730cc372672c8c", + "bidID": "6e0d218c8e964b42ac4a8ca086c100f9" + } + ], + "documents":[ + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.10/tenders/823d50b3236247adad28a5a66f74db42/documents/330822cbbd724671a1d2ff7c3a51dd52?download=5ff4917f29954e5f8dfea1feed8f7455", + "title":"test1.txt", + "documentOf":"tender", + "datePublished":"2015-12-12T03:06:53.209628+02:00", + "dateModified":"2015-12-12T03:06:53.209670+02:00", + "id":"330822cbbd724671a1d2ff7c3a51dd52" + }, + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.10/tenders/823d50b3236247adad28a5a66f74db42/documents/6badc6f313d2499794bd39a3a7182fc0?download=ab2d7cdd346342a6a0d7b40af39145e2", + "title":"test3.txt", + "documentOf":"tender", + "datePublished":"2015-12-12T03:06:53.724784+02:00", + "dateModified":"2015-12-12T03:06:53.724826+02:00", + "id":"6badc6f313d2499794bd39a3a7182fc0" + }, + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.10/tenders/823d50b3236247adad28a5a66f74db42/documents/08bcd56de9aa43faa684f8f8e7ab1c98?download=c7afbf3686cc441db7735d5ec284a0de", + "title":"test2.txt", + "documentOf":"tender", + "datePublished":"2015-12-12T03:06:54.280311+02:00", + "dateModified":"2015-12-12T03:06:54.280354+02:00", + "id":"08bcd56de9aa43faa684f8f8e7ab1c98" + } + ], + "description":"Multilot 4 descr", + "title":"Multilot 4 title", + "submissionMethodDetails":"quick", + "items":[ + { + "relatedLot":"7d774fbf1e86420484c7d1a005cc283f", + "description":"itelm descr", + "classification":{ + "scheme":"CPV", + "description":"\u041f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f \u0441\u0456\u043b\u044c\u0441\u044c\u043a\u043e\u0433\u043e \u0433\u043e\u0441\u043f\u043e\u0434\u0430\u0440\u0441\u0442\u0432\u0430, \u0444\u0435\u0440\u043c\u0435\u0440\u0441\u0442\u0432\u0430, \u0440\u0438\u0431\u0430\u043b\u044c\u0441\u0442\u0432\u0430, \u043b\u0456\u0441\u043d\u0438\u0446\u0442\u0432\u0430 \u0442\u0430 \u0441\u0443\u043c\u0456\u0436\u043d\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f", + "id":"03000000-1" + }, + "additionalClassifications":[ + { + "scheme":"\u0414\u041a\u041f\u041f", + "id":"01", + "description":"\u041f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f \u0441\u0456\u043b\u044c\u0441\u044c\u043a\u043e\u0433\u043e \u0433\u043e\u0441\u043f\u043e\u0434\u0430\u0440\u0441\u0442\u0432\u0430, \u043c\u0438\u0441\u043b\u0438\u0432\u0441\u0442\u0432\u0430 \u0442\u0430 \u043f\u043e\u0432\u2019\u044f\u0437\u0430\u043d\u0456 \u0437 \u0446\u0438\u043c \u043f\u043e\u0441\u043b\u0443\u0433\u0438" + } + ], + "deliveryDate":{ + "startDate":"2016-06-01T00:00:00+03:00" + }, + "id":"7caa3587fe9041da98f2744ef531d7ce", + "unit":{ + "code":"LO", + "name":"\u043b\u043e\u0442" + }, + "quantity":4 + }, + { + "relatedLot":"7d774fbf1e86420484c7d1a005cc283f", + "description":"itelm descr", + "classification":{ + "scheme":"CPV", + "description":"\u041f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f \u0441\u0456\u043b\u044c\u0441\u044c\u043a\u043e\u0433\u043e \u0433\u043e\u0441\u043f\u043e\u0434\u0430\u0440\u0441\u0442\u0432\u0430, \u0444\u0435\u0440\u043c\u0435\u0440\u0441\u0442\u0432\u0430, \u0440\u0438\u0431\u0430\u043b\u044c\u0441\u0442\u0432\u0430, \u043b\u0456\u0441\u043d\u0438\u0446\u0442\u0432\u0430 \u0442\u0430 \u0441\u0443\u043c\u0456\u0436\u043d\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f", + "id":"03000000-1" + }, + "additionalClassifications":[ + { + "scheme":"\u0414\u041a\u041f\u041f", + "id":"01", + "description":"\u041f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f \u0441\u0456\u043b\u044c\u0441\u044c\u043a\u043e\u0433\u043e \u0433\u043e\u0441\u043f\u043e\u0434\u0430\u0440\u0441\u0442\u0432\u0430, \u043c\u0438\u0441\u043b\u0438\u0432\u0441\u0442\u0432\u0430 \u0442\u0430 \u043f\u043e\u0432\u2019\u044f\u0437\u0430\u043d\u0456 \u0437 \u0446\u0438\u043c \u043f\u043e\u0441\u043b\u0443\u0433\u0438" + } + ], + "deliveryDate":{ + "startDate":"2016-06-01T00:00:00+03:00" + }, + "id":"563ef5d999f34d36a5a0e4e4d91d7be1", + "unit":{ + "code":"LO", + "name":"\u043b\u043e\u0442" + }, + "quantity":4 + } + ], + "id":"823d50b3236247adad28a5a66f74db42", + "value":{ + "currency":"UAH", + "amount":1000.0, + "valueAddedTaxIncluded":false + }, + "submissionMethod":"electronicAuction", + "procuringEntity":{ + "contactPoint":{ + "telephone":"", + "name":"Dmitry", + "email":"d.karnaukh+merchant1@smartweb.com.ua" + }, + "identifier":{ + "scheme":"UA-EDR", + "id":"66666692", + "legalName":"\u041d\u0410\u041a \"Testov Test\"" + }, + "name":"\u041d\u0410\u041a \"Testov Test\"", + "address":{ + "postalCode":"02121", + "countryName":"\u0423\u043a\u0440\u0430\u0438\u043d\u0430", + "streetAddress":"", + "region":"\u041a\u0438\u0435\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c", + "locality":"\u041a\u0438\u0435\u0432" + } + }, + "minimalStep":{ + "currency":"UAH", + "amount":1.0, + "valueAddedTaxIncluded":false + }, + "tenderID":"UA-2015-12-12-000003-1", + "questions":[ + { + "description":"Test lot question descr", + "title":"Test lot question title", + "relatedItem":"563ef5d999f34d36a5a0e4e4d91d7be1", + "answer":"Test answer", + "date":"2015-12-21T17:31:19.650440+02:00", + "id":"615ff8be8eba4a81b300036d6bec991c", + "questionOf":"lot" + }, + { + "description":"lot 2 question descr?", + "title":"lot 2 question title", + "relatedItem":"563ef5d999f34d36a5a0e4e4d91d7be1", + "answer":"lot 2 answer", + "date":"2015-12-21T17:36:30.680576+02:00", + "id":"278f269ee482434da6615a21f3deccf0", + "questionOf":"lot" + }, + { + "description":"lot 3 q descr?", + "title":"lot 3 q title", + "relatedItem":"563ef5d999f34d36a5a0e4e4d91d7be1", + "answer":"lot 3 answer", + "date":"2015-12-21T17:57:28.108596+02:00", + "id":"da6c1228f81e4c2e8451479d57b685dd", + "questionOf":"lot" + }, + { + "description":"Tender q 1 descr?", + "title":"Tender q 1 title", + "relatedItem":"ad681d050d0e42169a80b86d5b591c20", + "answer":"Tender q 1 answer", + "date":"2015-12-21T17:58:24.489846+02:00", + "id":"937b4b9ef3444782b9a3019fcc5c072a", + "questionOf":"tender" + }, + { + "description":"Item descr?", + "title":"Item title?", + "relatedItem":"7caa3587fe9041da98f2744ef531d7ce", + "answer":"Item answer", + "date":"2015-12-21T18:04:35.349936+02:00", + "id":"a2d14f4faf9b4ba180b40f08a2be3bd9", + "questionOf":"item" + } + ], + "enquiryPeriod":{ + "startDate":"2015-12-12T03:06:52.664385+02:00", + "endDate":"2015-12-30T03:05:00+02:00" + }, + "owner":"prom.ua", + "lots":[ + { + "status":"complete", + "description":"lot descr1", + "title":"lot title", + "minimalStep":{ + "currency":"UAH", + "amount":1.0, + "valueAddedTaxIncluded":false + }, + "value":{ + "currency":"UAH", + "amount":1000.0, + "valueAddedTaxIncluded":false + }, + "id":"7d774fbf1e86420484c7d1a005cc283f" + }, + { + "status":"active", + "description":"lot descr2", + "title":"lot title", + "minimalStep":{ + "currency":"UAH", + "amount":1.0, + "valueAddedTaxIncluded":false + }, + "value":{ + "currency":"UAH", + "amount":2000.0, + "valueAddedTaxIncluded":false + }, + "id":"563ef5d999f34d36a5a0e4e4d91d7be1" + } + ], + "bids":[ + { + "date": "2014-12-16T04:44:23.569815+02:00", + "documents": [ + { + "dateModified": "2014-12-16T04:44:25.010930+02:00", + "datePublished": "2014-12-16T04:44:25.010885+02:00", + "format": "text/plain", + "id": "ff001412c60c4164a0f57101e4eaf8aa", + "title": "Proposal.pdf", + "url": "http://api-sandbox.openprocurement.org/api/0/tenders/6f73bf0f7f734f459f7e37e3787054a0/bids/f7fc1212f9f140bba5c4e3cd4f2b62d9/documents/ff001412c60c4164a0f57101e4eaf8aa?download=4f45bbd414104cd78faf620208efd824" + } + ], + "qualificationDocuments": [ + { + "confidentiality": "public", + "language": "uk", + "title": "qualification_document.pdf", + "url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/e3e16eb63b584378b75d9eb01dc2f8b9/bids/c41709780fa8434399c62a1facf369cb/financial_documents/7519d21b32af432396acd6e2c9e18ee5?download=5db59ae05361427b84c4caddb0b6d92b", + "format": "application/pdf", + "documentOf": "tender", + "datePublished": "2016-02-24T14:13:36.625252+02:00", + "id": "7519d21b32af432396acd6e2c9e18ee5", + "dateModified": "2016-02-24T14:13:36.625290+02:00" + } + ], + "financial_documens": [ + { + "confidentiality": "public", + "language": "uk", + "title": "financial_doc.pdf", + "url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/e3e16eb63b584378b75d9eb01dc2f8b9/bids/c41709780fa8434399c62a1facf369cb/financial_documents/7519d21b32af432396acd6e2c9e18ee5?download=5db59ae05361427b84c4caddb0b6d92b", + "format": "application/pdf", + "documentOf": "tender", + "datePublished": "2016-02-24T14:13:36.625252+02:00", + "id": "7519d21b32af432396acd6e2c9e18ee5", + "dateModified": "2016-02-24T14:13:36.625290+02:00" + } + ], + "eligibility_documents": [ + { + "confidentiality": "public", + "language": "uk", + "title": "eligibility_doc.pdf", + "url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/e3e16eb63b584378b75d9eb01dc2f8b9/bids/c41709780fa8434399c62a1facf369cb/financial_documents/7519d21b32af432396acd6e2c9e18ee5?download=5db59ae05361427b84c4caddb0b6d92b", + "format": "application/pdf", + "documentOf": "tender", + "datePublished": "2016-02-24T14:13:36.625252+02:00", + "id": "7519d21b32af432396acd6e2c9e18ee5", + "dateModified": "2016-02-24T14:13:36.625290+02:00" + } + ], + "id": "f7fc1212f9f140bba5c4e3cd4f2b62d9", + "lotValues": [ + { + "value": {"currency": "UAH", "amount": 7750.0, "valueAddedTaxIncluded": true}, + "reatedLot": "7d774fbf1e86420484c7d1a005cc283f", + "date": "2015-11-01T12:43:12.482645+02:00" + }, { + "value": {"currency": "UAH", "amount": 8125.0, "valueAddedTaxIncluded": true}, + "reatedLot": "563ef5d999f34d36a5a0e4e4d91d7be1", + "date": "2015-11-01T12:43:12.482645+02:00" + } + ], + "tenderers": [ + { + "address": { + "countryName": "Україна", + "locality": "м. Вінниця", + "postalCode": "21100", + "region": "м. Вінниця", + "streetAddress": "вул. Островського, 33" + }, + "contactPoint": { + "email": "soleksuk@gmail.com", + "name": "Сергій Олексюк", + "telephone": "+380 (432) 21-69-30" + }, + "identifier": { + "id": "13313462", + "legalName": "Державне комунальне підприємство громадського харчування «Школяр»", + "scheme": "UA-EDR", + "uri": "http://sch10.edu.vn.ua/" + }, + "name": "ДКП «Школяр»" + } + ] + }, + { + "date": "2014-12-16T04:44:27.976478+02:00", + "id": "7ec725815ef448a9b857129024395638", + "lotValues": [ + { + "value": {"currency": "UAH", "amount": 7750.0, "valueAddedTaxIncluded": true}, + "reatedLot": "7d774fbf1e86420484c7d1a005cc283f", + "date": "2015-11-01T12:43:12.482645+02:00" + }, { + "value": {"currency": "UAH", "amount": 8125.0, "valueAddedTaxIncluded": true}, + "reatedLot": "563ef5d999f34d36a5a0e4e4d91d7be1", + "date": "2015-11-01T12:43:12.482645+02:00" + } + ], + "tenderers": [ + { + "address": { + "countryName": "Україна", + "locality": "м. Вінниця", + "postalCode": "21018", + "region": "м. Вінниця", + "streetAddress": "вул. Юності, 30" + }, + "contactPoint": { + "email": "alla.myhailova@i.ua", + "name": "Алла Михайлова", + "telephone": "+380 (432) 460-665" + }, + "identifier": { + "id": "13306232", + "legalName": "Державне комунальне підприємство громадського харчування «Меридіан»", + "scheme": "UA-EDR", + "uri": "http://sch10.edu.vn.ua/" + }, + "name": "ДКП «Меридіан2»" + } + ] + } + + ], + "awards":[ + { + "status":"active", + "documents":[ + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.9/tenders/3216137f17fb452db202daad1f9e73ad/awards/7054491a5e514699a56e44d32e23edf7/documents/c7ac894e4ca34e618e03a02d8799dc69?download=8c4053b0942949f4bd6e998a51e177c5", + "title":"2.jpg", + "datePublished":"2015-11-13T16:31:03.691781+02:00", + "dateModified":"2015-11-13T16:31:03.691829+02:00", + "id":"c7ac894e4ca34e618e03a02d8799dc69" + } + ], + "complaintPeriod":{ + "startDate":"2015-11-13T16:17:00.375880+02:00", + "endDate":"2015-11-14T16:31:06.979761+02:00" + }, + "contracts":[ + { + "status":"active", + "documents":[ + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.9/tenders/3216137f17fb452db202daad1f9e73ad/awards/7054491a5e514699a56e44d32e23edf7/contracts/045c478807c04215950b4d74e6861cb1/documents/14dbf158b9ed4a478a59d19c90dbdf5d?download=9d948173e65441409f06e0b81674b39a", + "title":"3.jpg", + "datePublished":"2015-11-13T19:01:16.748785+02:00", + "dateModified":"2015-11-13T19:01:16.748829+02:00", + "id":"14dbf158b9ed4a478a59d19c90dbdf5d" + } + ], + "awardID":"7054491a5e514699a56e44d32e23edf7", + "id":"045c478807c04215950b4d74e6861cb1" + } + ], + "suppliers":[ + { + "contactPoint":{ + "telephone":"", + "name":"some6", + "email":"some6@mailinator.com" + }, + "identifier":{ + "scheme":"UA-EDR", + "id":"62123463", + "legalName":"some6" + }, + "name":"some6", + "address":{ + "postalCode":"04119", + "countryName":"\u0423\u043a\u0440\u0430\u0438\u043d\u0430", + "streetAddress":"", + "region":"\u0410\u0420 \u041a\u0440\u044b\u043c", + "locality":"ffff" + } + } + ], + "bid_id":"ad9ac917ff0049178acc3613bb14a691", + "value":{ + "currency":"UAH", + "amount":300.0, + "valueAddedTaxIncluded":false + }, + "date":"2015-11-13T16:17:00.376251+02:00", + "id":"7054491a5e514699a56e44d32e23edf7", + "lotId": "563ef5d999f34d36a5a0e4e4d91d7be1" + }, + { + "status":"active", + "documents":[ + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.9/tenders/3216137f17fb452db202daad1f9e73ad/awards/7054491a5e514699a56e44d32e23edf7/documents/c7ac894e4ca34e618e03a02d8799dc69?download=8c4053b0942949f4bd6e998a51e177c5", + "title":"2.jpg", + "datePublished":"2015-11-13T16:31:03.691781+02:00", + "dateModified":"2015-11-13T16:31:03.691829+02:00", + "id":"c7ac894e4ca34e618e03a02d8799dc69" + } + ], + "complaintPeriod":{ + "startDate":"2015-11-13T16:17:00.375880+02:00", + "endDate":"2015-11-14T16:31:06.979761+02:00" + }, + "contracts":[ + { + "status":"active", + "documents":[ + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.9/tenders/3216137f17fb452db202daad1f9e73ad/awards/7054491a5e514699a56e44d32e23edf7/contracts/045c478807c04215950b4d74e6861cb1/documents/14dbf158b9ed4a478a59d19c90dbdf5d?download=9d948173e65441409f06e0b81674b39a", + "title":"3.jpg", + "datePublished":"2015-11-13T19:01:16.748785+02:00", + "dateModified":"2015-11-13T19:01:16.748829+02:00", + "id":"14dbf158b9ed4a478a59d19c90dbdf5d" + } + ], + "awardID":"7054491a5e514699a56e44d32e23edf7", + "id":"045c478807c04215950b4d74e6861cb1" + } + ], + "suppliers":[ + { + "contactPoint":{ + "telephone":"", + "name":"some6", + "email":"some6@mailinator.com" + }, + "identifier":{ + "scheme":"UA-EDR", + "id":"62123463", + "legalName":"some6" + }, + "name":"some6", + "address":{ + "postalCode":"04119", + "countryName":"\u0423\u043a\u0440\u0430\u0438\u043d\u0430", + "streetAddress":"", + "region":"\u0410\u0420 \u041a\u0440\u044b\u043c", + "locality":"ffff" + } + } + ], + "bid_id":"ad9ac917ff0049178acc3613bb14a691", + "value":{ + "currency":"UAH", + "amount":300.0, + "valueAddedTaxIncluded":false + }, + "date":"2015-11-13T16:17:00.376251+02:00", + "id":"7054491a5e514699a56e44d32e23edf7", + "lotId": "7d774fbf1e86420484c7d1a005cc283f" + } + ], + "dateModified":"2015-12-12T03:06:54.370277+02:00", + "awardCriteria":"lowestCost" + } +} diff --git a/openprocurement_client/tests/data/assets.json b/openprocurement_client/tests/data/assets.json new file mode 100644 index 0000000..384ef8a --- /dev/null +++ b/openprocurement_client/tests/data/assets.json @@ -0,0 +1,153 @@ +{ + "next_page":{ + "path":"/api/0.10/tenders?offset=2015-12-25T18%3A04%3A36.264176%2B02%3A00", + "uri":"https://lb.api-sandbox.openprocurement.org/api/0.10/tenders?offset=2015-12-25T18%3A04%3A36.264176%2B02%3A00", + "offset":"2015-12-25T18:04:36.264176+02:00" + }, + "data":[ + { + "id":"823d50b3236247adad28a5a66f74db42", + "dateModified":"2015-11-13T18:50:00.753811+02:00" + }, + { + "id":"f3849ade33534174b8402579152a5f41", + "dateModified":"2015-11-16T01:15:00.469896+02:00" + }, + { + "id":"f3849ade33534174b8402579152a5f41", + "dateModified":"2015-11-16T12:00:00.960077+02:00" + }, + { + "id":"3be3664065994d1e8847beb597c014bf", + "dateModified":"2015-11-16T21:15:00.404214+02:00" + }, + { + "id":"711cfa82c54147b686f6755adb22364d", + "dateModified":"2015-11-17T18:02:00.456050+02:00" + }, + { + "id":"730fe73cb7be4f92bce472484236e9ee", + "dateModified":"2015-11-18T18:30:00.410770+02:00" + }, + { + "id":"496ec128323f45679daf9ebcb1ec62f6", + "dateModified":"2015-11-20T16:20:37.977312+02:00" + }, + { + "id":"18d566bed8cc4f2e846ca5d64c6bdfed", + "dateModified":"2015-12-01T11:48:33.784585+02:00" + }, + { + "id":"21733c5ed0be4b259c3345310f425a82", + "dateModified":"2015-12-02T13:54:13.656648+02:00" + }, + { + "id":"b35a1151b7a84562addb47f66193a309", + "dateModified":"2015-12-12T02:45:36.355426+02:00" + }, + { + "id":"ce9751da26a84c2390368ffa5adfd74c", + "dateModified":"2015-12-12T03:04:16.059667+02:00" + }, + { + "id":"823d50b3236247adad28a5a66f74db42", + "dateModified":"2015-12-12T03:06:54.370277+02:00" + }, + { + "id":"0085cf76ad444ad0ae625fc17f366dd2", + "dateModified":"2015-12-12T14:30:38.596246+02:00" + }, + { + "id":"d97613278dd547f2be5523cdc5614880", + "dateModified":"2015-12-12T14:31:51.342309+02:00" + }, + { + "id":"71161344890c4231b1487296f56aa910", + "dateModified":"2015-12-14T13:10:38.771625+02:00" + }, + { + "id":"759a81e58cf04b5ea0587942d0925faa", + "dateModified":"2015-12-16T19:56:53.874070+02:00" + }, + { + "id":"ad681d050d0e42169a80b86d5b591c20", + "dateModified":"2015-12-22T13:14:25.253453+02:00" + }, + { + "id":"a2e4464a08d64addb6c7a63da48ddb87", + "dateModified":"2015-12-23T17:09:15.145867+02:00" + }, + { + "id":"eea0c2f3cf3f4206b8cbba813b9a527b", + "dateModified":"2015-12-23T17:15:23.479628+02:00" + }, + { + "id":"847411c7b03f4f91b97fecb70c6e6275", + "dateModified":"2015-12-23T17:54:39.470396+02:00" + }, + { + "id":"599e63e6fb1349078fb01e4f9e8a812c", + "dateModified":"2015-12-23T17:55:36.317529+02:00" + }, + { + "id":"d63a7302316c4d15b46aeb7bcd4f1dbe", + "dateModified":"2015-12-23T17:56:01.709307+02:00" + }, + { + "id":"6496299a3c8e482f9017d855483a97b5", + "dateModified":"2015-12-23T17:57:57.376623+02:00" + }, + { + "id":"a513848583cc4d1d806c78e5131ad068", + "dateModified":"2015-12-23T17:59:52.101031+02:00" + }, + { + "id":"79aa9fd2bb43471cbcb0b97f6965e5f6", + "dateModified":"2015-12-24T11:39:09.071184+02:00" + }, + { + "id":"b2cdcda417434c7b889c82a81927bb73", + "dateModified":"2015-12-24T11:40:20.172257+02:00" + }, + { + "id":"58eca935e0e24805b561a1588ae64ef3", + "dateModified":"2015-12-24T11:48:57.584694+02:00" + }, + { + "id":"78b889ec869544b9b47c8740549ed20a", + "dateModified":"2015-12-24T11:51:07.149689+02:00" + }, + { + "id":"258ef598759946dbb30e7ed67bfc2346", + "dateModified":"2015-12-24T11:52:16.196052+02:00" + }, + { + "id":"639ecaca9db24228a9fe0eb3494aa0e3", + "dateModified":"2015-12-25T13:28:22.136939+02:00" + }, + { + "id":"ca10599dfcbe416bb513416c13073c5f", + "dateModified":"2015-12-25T15:19:53.913160+02:00" + }, + { + "id":"21e551bf7f194d8aaba29bf2e4949b90", + "dateModified":"2015-12-25T16:00:00.319589+02:00" + }, + { + "id":"dd7b13a956b44a34bbaeb2bfa1910c03", + "dateModified":"2015-12-25T16:07:19.809837+02:00" + }, + { + "id":"f8f21e8b0c104747b8abf5ece4fb5d72", + "dateModified":"2015-12-25T17:06:32.885207+02:00" + }, + { + "id":"48dcb014d003454b8875975bb531147f", + "dateModified":"2015-12-25T17:16:05.208447+02:00" + }, + { + "id":"7f35a555d5c64b34a7cbc454fab5628c", + "dateModified":"2015-12-25T18:04:36.264176+02:00" + } + ] +} diff --git a/openprocurement_client/tests/data/lot_668c3156c8cb496fb28359909cde6e96.json b/openprocurement_client/tests/data/lot_668c3156c8cb496fb28359909cde6e96.json new file mode 100644 index 0000000..27e133b --- /dev/null +++ b/openprocurement_client/tests/data/lot_668c3156c8cb496fb28359909cde6e96.json @@ -0,0 +1,272 @@ +{ + "access": { + "token": "0fc58c83963d42a692db4987df86640a" + }, + "data": { + "procurementMethod": "limited", + "status": "cancelled", + "documents": [ + { + "format": "text/plain", + "url": "https://api-sandbox.openprocurement.org/api/0.12/tenders/668c3156c8cb496fb28359909cde6e96/documents/3f82c7ef80a745119b6a6dec2670e5bc?download=0fc58c83963d42a692db4987df86640a", + "title": "/tmp/tmp5k4QEL", + "documentOf": "tender", + "datePublished": "2016-02-18T14:45:40.348569+02:00", + "dateModified": "2016-02-18T14:45:40.348612+02:00", + "id": "3f82c7ef80a745119b6a6dec2670e5bc" + } + ], + "title": "\u041f\u043e\u0441\u043b\u0443\u0433\u0438 \u0448\u043a\u0456\u043b\u044c\u043d\u0438\u0445 \u0457\u0434\u0430\u043b\u0435\u043d\u044c", + "contracts": [ + { + "status": "pending", + "awardID": "70eaaceee81e4f378e333c1ed8258652", + "id": "c65d3526cdc44f75b2457b4489970a7c" + } + ], + "items": [ + { + "description": "\u041f\u043e\u0441\u043b\u0443\u0433\u0438 \u0448\u043a\u0456\u043b\u044c\u043d\u0438\u0445 \u0457\u0434\u0430\u043b\u0435\u043d\u044c", + "classification": { + "scheme": "CPV", + "description": "\u041f\u043e\u0441\u043b\u0443\u0433\u0438 \u0437 \u0445\u0430\u0440\u0447\u0443\u0432\u0430\u043d\u043d\u044f \u0443 \u0448\u043a\u043e\u043b\u0430\u0445", + "id": "55523100-3" + }, + "additionalClassifications": [ + { + "scheme": "\u0414\u041a\u041f\u041f", + "id": "55.51.10.300", + "description": "\u041f\u043e\u0441\u043b\u0443\u0433\u0438 \u0448\u043a\u0456\u043b\u044c\u043d\u0438\u0445 \u0457\u0434\u0430\u043b\u0435\u043d\u044c" + } + ], + "deliveryLocation": { + "latitude": 49.85, + "longitude": 24.0167 + }, + "deliveryAddress": { + "locality": "\u043c. \u041a\u0438\u0457\u0432", + "region": "\u043c. \u041a\u0438\u0457\u0432", + "countryName_en": "Ukraine", + "countryName": "\u0423\u043a\u0440\u0430\u0457\u043d\u0430", + "streetAddress": "481 John Pine Suite 803", + "countryName_ru": "\u0423\u043a\u0440\u0430\u0438\u043d\u0430", + "postalCode": "58662" + }, + "deliveryDate": { + "endDate": "2016-02-23T14:42:28.297330+02:00" + }, + "id": "2dc54675d6364e2baffbc0f8e74432ac", + "unit": { + "code": "MON", + "name": "month" + }, + "quantity": 9 + } + ], + "complaints": [ + { + "status": "resolved", + "documents": [ + { + "author": "complaint_owner", + "format": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "url": "https://lb.api-sandbox.openprocurement.org/api/0.12/tenders/cdec9f009be44f53817754b12d292ef2/complaints/22b086222a7a4bc6a9cc8adeaa91a57f/documents/129f4013b33a45b8bc70699a62a81499?download=7a6787929a624dd8b7c067974b9e8a96", + "title": "/tmp/tmpcFrLvz.docx", + "documentOf": "tender", + "datePublished": "2016-02-29T15:05:54.557614+02:00", + "dateModified": "2016-02-29T15:05:54.557656+02:00", + "id": "129f4013b33a45b8bc70699a62a81499" + } + ], + "description": "Consequuntur sint cupiditate impedit et magnam aut odit eligendi dicta magnam dicta eveniet.", + "tendererActionDate": "2016-02-29T15:06:05.212783+02:00", + "title": "Hic laboriosam magni cupiditate enim placeat in dolorem.", + "resolutionType": "resolved", + "resolution": "Non ipsa accusantium iste et dolorum quo temporibus deserunt et provident suscipit.", + "satisfied": true, + "dateAnswered": "2016-02-29T15:06:05.212741+02:00", + "tendererAction": "Labore adipisci sequi corporis neque delectus ea aut dicta molestiae omnis voluptatem qui et.", + "dateSubmitted": "2016-02-29T15:06:01.956017+02:00", + "date": "2016-02-29T15:05:53.084688+02:00", + "type": "claim", + "id": "22b086222a7a4bc6a9cc8adeaa91a57f" + }, + { + "status": "cancelled", + "description": "Sit cumque iste eius corporis exercitationem voluptate.", + "title": "Commodi voluptatem earum sapiente doloremque.", + "cancellationReason": "prosto tak :)", + "dateCanceled": "2016-02-29T15:06:19.281225+02:00", + "date": "2016-02-29T15:06:17.694889+02:00", + "type": "claim", + "id": "d26fc2f475514652a53c0c551d984be3" + }, + { + "status": "cancelled", + "description": "Eos officia vel aliquid id qui provident suscipit eos nam amet.", + "title": "Voluptas debitis cupiditate deserunt inventore fugit quo nemo dicta.", + "cancellationReason": "prosto tak :)", + "dateCanceled": "2016-02-29T15:06:28.419955+02:00", + "dateSubmitted": "2016-02-29T15:06:26.927454+02:00", + "date": "2016-02-29T15:06:24.962751+02:00", + "type": "claim", + "id": "816eb0529d6d41148dac0edabc119407" + }, + { + "status": "cancelled", + "dateCanceled": "2016-02-29T15:06:37.390093+02:00", + "tendererActionDate": "2016-02-29T15:06:35.767209+02:00", + "description": "Non voluptas ipsa ex quibusdam dolorem rem dolores sequi.", + "title": "Et esse eos unde molestiae cum sunt.", + "resolutionType": "resolved", + "resolution": "Cumque magni vitae officiis odit et mollitia neque dolores reprehenderit.", + "cancellationReason": "prosto tak :)", + "dateAnswered": "2016-02-29T15:06:35.767171+02:00", + "tendererAction": "Architecto dolor dolorem ut labore esse possimus odit a unde hic quas error alias nulla.", + "dateSubmitted": "2016-02-29T15:06:34.170608+02:00", + "date": "2016-02-29T15:06:32.488624+02:00", + "type": "claim", + "id": "ec053962ce334bdaaab8b3bf2e6b3173" + }, + { + "status": "cancelled", + "dateCanceled": "2016-02-29T15:06:55.181473+02:00", + "tendererActionDate": "2016-02-29T15:06:45.067477+02:00", + "description": "Et autem reiciendis eaque dolorem adipisci aut.", + "title": "Ipsum cupiditate ipsam ut non.", + "resolutionType": "resolved", + "resolution": "Qui vitae placeat rerum officia quia aperiam illo nisi velit et fuga ducimus dolor.", + "author": { + "contactPoint": { + "name": "Варвара Талан", + "telephone": "+38 (268) 501-16-45" + }, + "identifier": { + "scheme": "UA-EDR", + "id": "00007460", + "uri": "http://dummyimage.com/506x880" + }, + "name": "Терещук-Приймак", + "address": { + "locality": "м. Вінниця", + "region": "Вінницька область", + "countryName_en": "Ukraine", + "countryName": "Україна", + "streetAddress": "73741 John Pass", + "countryName_ru": "Украина", + "postalCode": "21100" + } + }, + "satisfied": false, + "dateEscalated": "2016-02-29T15:06:46.828487+02:00", + "dateAnswered": "2016-02-29T15:06:45.067440+02:00", + "tendererAction": "Ex optio cumque assumenda iure consectetur unde iste et consequatur at quaerat dolor.", + "dateSubmitted": "2016-02-29T15:06:43.326331+02:00", + "date": "2016-02-29T15:06:41.513902+02:00", + "cancellationReason": "prosto tak :)", + "type": "complaint", + "id": "76f0f99cb643434da21b6a6350cc2d0e" + } + ], + "procurementMethodType": "reporting", + "cancellations": [ + { + "status": "active", + "documents": [ + { + "description": "test description", + "format": "text/plain", + "url": "https://api-sandbox.openprocurement.org/api/0.12/tenders/668c3156c8cb496fb28359909cde6e96/cancellations/0dd6f9e8cc4f4d1c9c404d842b56d0d7/documents/1afca9faaf2b4f9489ee264b136371c6?download=57e135c2f8d342c3a506be20940a3f3c", + "title": "/tmp/tmpdhdoax", + "documentOf": "tender", + "datePublished": "2016-02-18T14:46:05.348204+02:00", + "dateModified": "2016-02-18T14:46:05.348246+02:00", + "id": "1afca9faaf2b4f9489ee264b136371c6" + }, + { + "description": "test description", + "format": "text/plain", + "url": "https://api-sandbox.openprocurement.org/api/0.12/tenders/668c3156c8cb496fb28359909cde6e96/cancellations/0dd6f9e8cc4f4d1c9c404d842b56d0d7/documents/1afca9faaf2b4f9489ee264b136371c6?download=9208a5fa7cf140a2bb4751a42a1f1ea9", + "title": "/tmp/tmpOBUlWP", + "documentOf": "tender", + "datePublished": "2016-02-18T14:46:05.348204+02:00", + "dateModified": "2016-02-18T14:46:08.516130+02:00", + "id": "1afca9faaf2b4f9489ee264b136371c6" + } + ], + "reason": "prost :))", + "date": "2016-02-18T14:46:04.344125+02:00", + "cancellationOf": "tender", + "id": "0dd6f9e8cc4f4d1c9c404d842b56d0d7" + } + ], + "value": { + "currency": "UAH", + "amount": 500000.0, + "valueAddedTaxIncluded": true + }, + "id": "668c3156c8cb496fb28359909cde6e96", + "awards": [ + { + "status": "active", + "complaintPeriod": { + "startDate": "2016-02-18T14:45:41.212240+02:00", + "endDate": "2016-02-19T14:45:42.178932+02:00" + }, + "suppliers": [ + { + "contactPoint": { + "telephone": "+380 (432) 21-69-30", + "name": "\u0421\u0435\u0440\u0433\u0456\u0439 \u041e\u043b\u0435\u043a\u0441\u044e\u043a", + "email": "soleksuk@gmail.com" + }, + "identifier": { + "scheme": "UA-EDR", + "id": "13313462", + "uri": "http://sch10.edu.vn.ua/", + "legalName": "\u0414\u0435\u0440\u0436\u0430\u0432\u043d\u0435 \u043a\u043e\u043c\u0443\u043d\u0430\u043b\u044c\u043d\u0435 \u043f\u0456\u0434\u043f\u0440\u0438\u0454\u043c\u0441\u0442\u0432\u043e \u0433\u0440\u043e\u043c\u0430\u0434\u0441\u044c\u043a\u043e\u0433\u043e \u0445\u0430\u0440\u0447\u0443\u0432\u0430\u043d\u043d\u044f \u00ab\u0428\u043a\u043e\u043b\u044f\u0440\u00bb" + }, + "name": "\u0414\u041a\u041f \u00ab\u0428\u043a\u043e\u043b\u044f\u0440\u00bb", + "address": { + "postalCode": "21100", + "countryName": "\u0423\u043a\u0440\u0430\u0457\u043d\u0430", + "streetAddress": "\u0432\u0443\u043b. \u041e\u0441\u0442\u0440\u043e\u0432\u0441\u044c\u043a\u043e\u0433\u043e, 33", + "region": "\u043c. \u0412\u0456\u043d\u043d\u0438\u0446\u044f", + "locality": "\u043c. \u0412\u0456\u043d\u043d\u0438\u0446\u044f" + } + } + ], + "value": { + "currency": "UAH", + "amount": 475000.0, + "valueAddedTaxIncluded": true + }, + "date": "2016-02-18T14:45:41.210928+02:00", + "id": "70eaaceee81e4f378e333c1ed8258652" + } + ], + "tenderID": "UA-2016-02-18-000031", + "owner": "test.quintagroup.com", + "dateModified": "2016-02-18T14:46:09.940361+02:00", + "procuringEntity": { + "contactPoint": { + "url": "http://sch10.edu.vn.ua/", + "name": "\u041a\u0443\u0446\u0430 \u0421\u0432\u0456\u0442\u043b\u0430\u043d\u0430 \u0412\u0430\u043b\u0435\u043d\u0442\u0438\u043d\u0456\u0432\u043d\u0430", + "telephone": "+380 (432) 46-53-02" + }, + "identifier": { + "scheme": "UA-EDR", + "id": "21725150", + "legalName": "\u0417\u0430\u043a\u043b\u0430\u0434 \"\u0417\u0430\u0433\u0430\u043b\u044c\u043d\u043e\u043e\u0441\u0432\u0456\u0442\u043d\u044f \u0448\u043a\u043e\u043b\u0430 \u0406-\u0406\u0406\u0406 \u0441\u0442\u0443\u043f\u0435\u043d\u0456\u0432 \u2116 10 \u0412\u0456\u043d\u043d\u0438\u0446\u044c\u043a\u043e\u0457 \u043c\u0456\u0441\u044c\u043a\u043e\u0457 \u0440\u0430\u0434\u0438\"" + }, + "name": "\u0417\u041e\u0421\u0428 #10 \u043c.\u0412\u0456\u043d\u043d\u0438\u0446\u0456", + "address": { + "postalCode": "21027", + "countryName": "\u0423\u043a\u0440\u0430\u0457\u043d\u0430", + "streetAddress": "\u0432\u0443\u043b. \u0421\u0442\u0430\u0445\u0443\u0440\u0441\u044c\u043a\u043e\u0433\u043e. 22", + "region": "\u043c. \u0412\u0456\u043d\u043d\u0438\u0446\u044f", + "locality": "\u043c. \u0412\u0456\u043d\u043d\u0438\u0446\u044f" + } + } + } +} diff --git a/openprocurement_client/tests/data/lot_823d50b3236247adad28a5a66f74db42.json b/openprocurement_client/tests/data/lot_823d50b3236247adad28a5a66f74db42.json new file mode 100644 index 0000000..27b7f37 --- /dev/null +++ b/openprocurement_client/tests/data/lot_823d50b3236247adad28a5a66f74db42.json @@ -0,0 +1,504 @@ +{ + "data":{ + "procurementMethod":"open", + "status":"complete", + "tenderPeriod":{ + "startDate":"2015-12-30T03:05:00+02:00", + "endDate":"2015-12-31T03:05:00+02:00" + }, + "qualifications": [ + { + "status": "pending", + "id": "cec4b82d2708465291fb4af79f8a3e52", + "bidID": "c41709780fa8434399c62a1facf369cb", + "documents": [ + { + "confidentiality": "public", + "language": "uk", + "title": "Proposal.pdf", + "url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/e3e16eb63b584378b75d9eb01dc2f8b9/bids/c41709780fa8434399c62a1facf369cb/documents/a05aff4e91c942bbad7e49e551399ec7?download=d0984048f149465699fd402bfe20881c", + "format": "application/pdf", + "documentOf": "tender", + "datePublished": "2016-02-24T14:13:36.127526+02:00", + "id": "a05aff4e91c942bbad7e49e551399ec7", + "dateModified": "2016-02-24T14:13:36.127580+02:00" + }] + }, + { + "status": "pending", + "id": "9d562bbbf05e44f8a6a1f07ddb0415b1", + "bidID": "dda102997a4d4d5d8b5dac6ce2225e1c" + }, + { + "status": "pending", + "id": "36ac59607c434c8198730cc372672c8c", + "bidID": "6e0d218c8e964b42ac4a8ca086c100f9" + } + ], + "documents":[ + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.10/tenders/823d50b3236247adad28a5a66f74db42/documents/330822cbbd724671a1d2ff7c3a51dd52?download=5ff4917f29954e5f8dfea1feed8f7455", + "title":"test1.txt", + "documentOf":"tender", + "datePublished":"2015-12-12T03:06:53.209628+02:00", + "dateModified":"2015-12-12T03:06:53.209670+02:00", + "id":"330822cbbd724671a1d2ff7c3a51dd52" + }, + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.10/tenders/823d50b3236247adad28a5a66f74db42/documents/6badc6f313d2499794bd39a3a7182fc0?download=ab2d7cdd346342a6a0d7b40af39145e2", + "title":"test3.txt", + "documentOf":"tender", + "datePublished":"2015-12-12T03:06:53.724784+02:00", + "dateModified":"2015-12-12T03:06:53.724826+02:00", + "id":"6badc6f313d2499794bd39a3a7182fc0" + }, + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.10/tenders/823d50b3236247adad28a5a66f74db42/documents/08bcd56de9aa43faa684f8f8e7ab1c98?download=c7afbf3686cc441db7735d5ec284a0de", + "title":"test2.txt", + "documentOf":"tender", + "datePublished":"2015-12-12T03:06:54.280311+02:00", + "dateModified":"2015-12-12T03:06:54.280354+02:00", + "id":"08bcd56de9aa43faa684f8f8e7ab1c98" + } + ], + "description":"Multilot 4 descr", + "title":"Multilot 4 title", + "submissionMethodDetails":"quick", + "items":[ + { + "relatedLot":"7d774fbf1e86420484c7d1a005cc283f", + "description":"itelm descr", + "classification":{ + "scheme":"CPV", + "description":"\u041f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f \u0441\u0456\u043b\u044c\u0441\u044c\u043a\u043e\u0433\u043e \u0433\u043e\u0441\u043f\u043e\u0434\u0430\u0440\u0441\u0442\u0432\u0430, \u0444\u0435\u0440\u043c\u0435\u0440\u0441\u0442\u0432\u0430, \u0440\u0438\u0431\u0430\u043b\u044c\u0441\u0442\u0432\u0430, \u043b\u0456\u0441\u043d\u0438\u0446\u0442\u0432\u0430 \u0442\u0430 \u0441\u0443\u043c\u0456\u0436\u043d\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f", + "id":"03000000-1" + }, + "additionalClassifications":[ + { + "scheme":"\u0414\u041a\u041f\u041f", + "id":"01", + "description":"\u041f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f \u0441\u0456\u043b\u044c\u0441\u044c\u043a\u043e\u0433\u043e \u0433\u043e\u0441\u043f\u043e\u0434\u0430\u0440\u0441\u0442\u0432\u0430, \u043c\u0438\u0441\u043b\u0438\u0432\u0441\u0442\u0432\u0430 \u0442\u0430 \u043f\u043e\u0432\u2019\u044f\u0437\u0430\u043d\u0456 \u0437 \u0446\u0438\u043c \u043f\u043e\u0441\u043b\u0443\u0433\u0438" + } + ], + "deliveryDate":{ + "startDate":"2016-06-01T00:00:00+03:00" + }, + "id":"7caa3587fe9041da98f2744ef531d7ce", + "unit":{ + "code":"LO", + "name":"\u043b\u043e\u0442" + }, + "quantity":4 + }, + { + "relatedLot":"7d774fbf1e86420484c7d1a005cc283f", + "description":"itelm descr", + "classification":{ + "scheme":"CPV", + "description":"\u041f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f \u0441\u0456\u043b\u044c\u0441\u044c\u043a\u043e\u0433\u043e \u0433\u043e\u0441\u043f\u043e\u0434\u0430\u0440\u0441\u0442\u0432\u0430, \u0444\u0435\u0440\u043c\u0435\u0440\u0441\u0442\u0432\u0430, \u0440\u0438\u0431\u0430\u043b\u044c\u0441\u0442\u0432\u0430, \u043b\u0456\u0441\u043d\u0438\u0446\u0442\u0432\u0430 \u0442\u0430 \u0441\u0443\u043c\u0456\u0436\u043d\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f", + "id":"03000000-1" + }, + "additionalClassifications":[ + { + "scheme":"\u0414\u041a\u041f\u041f", + "id":"01", + "description":"\u041f\u0440\u043e\u0434\u0443\u043a\u0446\u0456\u044f \u0441\u0456\u043b\u044c\u0441\u044c\u043a\u043e\u0433\u043e \u0433\u043e\u0441\u043f\u043e\u0434\u0430\u0440\u0441\u0442\u0432\u0430, \u043c\u0438\u0441\u043b\u0438\u0432\u0441\u0442\u0432\u0430 \u0442\u0430 \u043f\u043e\u0432\u2019\u044f\u0437\u0430\u043d\u0456 \u0437 \u0446\u0438\u043c \u043f\u043e\u0441\u043b\u0443\u0433\u0438" + } + ], + "deliveryDate":{ + "startDate":"2016-06-01T00:00:00+03:00" + }, + "id":"563ef5d999f34d36a5a0e4e4d91d7be1", + "unit":{ + "code":"LO", + "name":"\u043b\u043e\u0442" + }, + "quantity":4 + } + ], + "id":"823d50b3236247adad28a5a66f74db42", + "value":{ + "currency":"UAH", + "amount":1000.0, + "valueAddedTaxIncluded":false + }, + "submissionMethod":"electronicAuction", + "procuringEntity":{ + "contactPoint":{ + "telephone":"", + "name":"Dmitry", + "email":"d.karnaukh+merchant1@smartweb.com.ua" + }, + "identifier":{ + "scheme":"UA-EDR", + "id":"66666692", + "legalName":"\u041d\u0410\u041a \"Testov Test\"" + }, + "name":"\u041d\u0410\u041a \"Testov Test\"", + "address":{ + "postalCode":"02121", + "countryName":"\u0423\u043a\u0440\u0430\u0438\u043d\u0430", + "streetAddress":"", + "region":"\u041a\u0438\u0435\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c", + "locality":"\u041a\u0438\u0435\u0432" + } + }, + "minimalStep":{ + "currency":"UAH", + "amount":1.0, + "valueAddedTaxIncluded":false + }, + "tenderID":"UA-2015-12-12-000003-1", + "questions":[ + { + "description":"Test lot question descr", + "title":"Test lot question title", + "relatedItem":"563ef5d999f34d36a5a0e4e4d91d7be1", + "answer":"Test answer", + "date":"2015-12-21T17:31:19.650440+02:00", + "id":"615ff8be8eba4a81b300036d6bec991c", + "questionOf":"lot" + }, + { + "description":"lot 2 question descr?", + "title":"lot 2 question title", + "relatedItem":"563ef5d999f34d36a5a0e4e4d91d7be1", + "answer":"lot 2 answer", + "date":"2015-12-21T17:36:30.680576+02:00", + "id":"278f269ee482434da6615a21f3deccf0", + "questionOf":"lot" + }, + { + "description":"lot 3 q descr?", + "title":"lot 3 q title", + "relatedItem":"563ef5d999f34d36a5a0e4e4d91d7be1", + "answer":"lot 3 answer", + "date":"2015-12-21T17:57:28.108596+02:00", + "id":"da6c1228f81e4c2e8451479d57b685dd", + "questionOf":"lot" + }, + { + "description":"Tender q 1 descr?", + "title":"Tender q 1 title", + "relatedItem":"ad681d050d0e42169a80b86d5b591c20", + "answer":"Tender q 1 answer", + "date":"2015-12-21T17:58:24.489846+02:00", + "id":"937b4b9ef3444782b9a3019fcc5c072a", + "questionOf":"tender" + }, + { + "description":"Item descr?", + "title":"Item title?", + "relatedItem":"7caa3587fe9041da98f2744ef531d7ce", + "answer":"Item answer", + "date":"2015-12-21T18:04:35.349936+02:00", + "id":"a2d14f4faf9b4ba180b40f08a2be3bd9", + "questionOf":"item" + } + ], + "enquiryPeriod":{ + "startDate":"2015-12-12T03:06:52.664385+02:00", + "endDate":"2015-12-30T03:05:00+02:00" + }, + "owner":"prom.ua", + "lots":[ + { + "status":"complete", + "description":"lot descr1", + "title":"lot title", + "minimalStep":{ + "currency":"UAH", + "amount":1.0, + "valueAddedTaxIncluded":false + }, + "value":{ + "currency":"UAH", + "amount":1000.0, + "valueAddedTaxIncluded":false + }, + "id":"7d774fbf1e86420484c7d1a005cc283f" + }, + { + "status":"active", + "description":"lot descr2", + "title":"lot title", + "minimalStep":{ + "currency":"UAH", + "amount":1.0, + "valueAddedTaxIncluded":false + }, + "value":{ + "currency":"UAH", + "amount":2000.0, + "valueAddedTaxIncluded":false + }, + "id":"563ef5d999f34d36a5a0e4e4d91d7be1" + } + ], + "bids":[ + { + "date": "2014-12-16T04:44:23.569815+02:00", + "documents": [ + { + "dateModified": "2014-12-16T04:44:25.010930+02:00", + "datePublished": "2014-12-16T04:44:25.010885+02:00", + "format": "text/plain", + "id": "ff001412c60c4164a0f57101e4eaf8aa", + "title": "Proposal.pdf", + "url": "http://api-sandbox.openprocurement.org/api/0/tenders/6f73bf0f7f734f459f7e37e3787054a0/bids/f7fc1212f9f140bba5c4e3cd4f2b62d9/documents/ff001412c60c4164a0f57101e4eaf8aa?download=4f45bbd414104cd78faf620208efd824" + } + ], + "qualificationDocuments": [ + { + "confidentiality": "public", + "language": "uk", + "title": "qualification_document.pdf", + "url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/e3e16eb63b584378b75d9eb01dc2f8b9/bids/c41709780fa8434399c62a1facf369cb/financial_documents/7519d21b32af432396acd6e2c9e18ee5?download=5db59ae05361427b84c4caddb0b6d92b", + "format": "application/pdf", + "documentOf": "tender", + "datePublished": "2016-02-24T14:13:36.625252+02:00", + "id": "7519d21b32af432396acd6e2c9e18ee5", + "dateModified": "2016-02-24T14:13:36.625290+02:00" + } + ], + "financial_documens": [ + { + "confidentiality": "public", + "language": "uk", + "title": "financial_doc.pdf", + "url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/e3e16eb63b584378b75d9eb01dc2f8b9/bids/c41709780fa8434399c62a1facf369cb/financial_documents/7519d21b32af432396acd6e2c9e18ee5?download=5db59ae05361427b84c4caddb0b6d92b", + "format": "application/pdf", + "documentOf": "tender", + "datePublished": "2016-02-24T14:13:36.625252+02:00", + "id": "7519d21b32af432396acd6e2c9e18ee5", + "dateModified": "2016-02-24T14:13:36.625290+02:00" + } + ], + "eligibility_documents": [ + { + "confidentiality": "public", + "language": "uk", + "title": "eligibility_doc.pdf", + "url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/e3e16eb63b584378b75d9eb01dc2f8b9/bids/c41709780fa8434399c62a1facf369cb/financial_documents/7519d21b32af432396acd6e2c9e18ee5?download=5db59ae05361427b84c4caddb0b6d92b", + "format": "application/pdf", + "documentOf": "tender", + "datePublished": "2016-02-24T14:13:36.625252+02:00", + "id": "7519d21b32af432396acd6e2c9e18ee5", + "dateModified": "2016-02-24T14:13:36.625290+02:00" + } + ], + "id": "f7fc1212f9f140bba5c4e3cd4f2b62d9", + "lotValues": [ + { + "value": {"currency": "UAH", "amount": 7750.0, "valueAddedTaxIncluded": true}, + "reatedLot": "7d774fbf1e86420484c7d1a005cc283f", + "date": "2015-11-01T12:43:12.482645+02:00" + }, { + "value": {"currency": "UAH", "amount": 8125.0, "valueAddedTaxIncluded": true}, + "reatedLot": "563ef5d999f34d36a5a0e4e4d91d7be1", + "date": "2015-11-01T12:43:12.482645+02:00" + } + ], + "tenderers": [ + { + "address": { + "countryName": "Україна", + "locality": "м. Вінниця", + "postalCode": "21100", + "region": "м. Вінниця", + "streetAddress": "вул. Островського, 33" + }, + "contactPoint": { + "email": "soleksuk@gmail.com", + "name": "Сергій Олексюк", + "telephone": "+380 (432) 21-69-30" + }, + "identifier": { + "id": "13313462", + "legalName": "Державне комунальне підприємство громадського харчування «Школяр»", + "scheme": "UA-EDR", + "uri": "http://sch10.edu.vn.ua/" + }, + "name": "ДКП «Школяр»" + } + ] + }, + { + "date": "2014-12-16T04:44:27.976478+02:00", + "id": "7ec725815ef448a9b857129024395638", + "lotValues": [ + { + "value": {"currency": "UAH", "amount": 7750.0, "valueAddedTaxIncluded": true}, + "reatedLot": "7d774fbf1e86420484c7d1a005cc283f", + "date": "2015-11-01T12:43:12.482645+02:00" + }, { + "value": {"currency": "UAH", "amount": 8125.0, "valueAddedTaxIncluded": true}, + "reatedLot": "563ef5d999f34d36a5a0e4e4d91d7be1", + "date": "2015-11-01T12:43:12.482645+02:00" + } + ], + "tenderers": [ + { + "address": { + "countryName": "Україна", + "locality": "м. Вінниця", + "postalCode": "21018", + "region": "м. Вінниця", + "streetAddress": "вул. Юності, 30" + }, + "contactPoint": { + "email": "alla.myhailova@i.ua", + "name": "Алла Михайлова", + "telephone": "+380 (432) 460-665" + }, + "identifier": { + "id": "13306232", + "legalName": "Державне комунальне підприємство громадського харчування «Меридіан»", + "scheme": "UA-EDR", + "uri": "http://sch10.edu.vn.ua/" + }, + "name": "ДКП «Меридіан2»" + } + ] + } + + ], + "awards":[ + { + "status":"active", + "documents":[ + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.9/tenders/3216137f17fb452db202daad1f9e73ad/awards/7054491a5e514699a56e44d32e23edf7/documents/c7ac894e4ca34e618e03a02d8799dc69?download=8c4053b0942949f4bd6e998a51e177c5", + "title":"2.jpg", + "datePublished":"2015-11-13T16:31:03.691781+02:00", + "dateModified":"2015-11-13T16:31:03.691829+02:00", + "id":"c7ac894e4ca34e618e03a02d8799dc69" + } + ], + "complaintPeriod":{ + "startDate":"2015-11-13T16:17:00.375880+02:00", + "endDate":"2015-11-14T16:31:06.979761+02:00" + }, + "contracts":[ + { + "status":"active", + "documents":[ + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.9/tenders/3216137f17fb452db202daad1f9e73ad/awards/7054491a5e514699a56e44d32e23edf7/contracts/045c478807c04215950b4d74e6861cb1/documents/14dbf158b9ed4a478a59d19c90dbdf5d?download=9d948173e65441409f06e0b81674b39a", + "title":"3.jpg", + "datePublished":"2015-11-13T19:01:16.748785+02:00", + "dateModified":"2015-11-13T19:01:16.748829+02:00", + "id":"14dbf158b9ed4a478a59d19c90dbdf5d" + } + ], + "awardID":"7054491a5e514699a56e44d32e23edf7", + "id":"045c478807c04215950b4d74e6861cb1" + } + ], + "suppliers":[ + { + "contactPoint":{ + "telephone":"", + "name":"some6", + "email":"some6@mailinator.com" + }, + "identifier":{ + "scheme":"UA-EDR", + "id":"62123463", + "legalName":"some6" + }, + "name":"some6", + "address":{ + "postalCode":"04119", + "countryName":"\u0423\u043a\u0440\u0430\u0438\u043d\u0430", + "streetAddress":"", + "region":"\u0410\u0420 \u041a\u0440\u044b\u043c", + "locality":"ffff" + } + } + ], + "bid_id":"ad9ac917ff0049178acc3613bb14a691", + "value":{ + "currency":"UAH", + "amount":300.0, + "valueAddedTaxIncluded":false + }, + "date":"2015-11-13T16:17:00.376251+02:00", + "id":"7054491a5e514699a56e44d32e23edf7", + "lotId": "563ef5d999f34d36a5a0e4e4d91d7be1" + }, + { + "status":"active", + "documents":[ + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.9/tenders/3216137f17fb452db202daad1f9e73ad/awards/7054491a5e514699a56e44d32e23edf7/documents/c7ac894e4ca34e618e03a02d8799dc69?download=8c4053b0942949f4bd6e998a51e177c5", + "title":"2.jpg", + "datePublished":"2015-11-13T16:31:03.691781+02:00", + "dateModified":"2015-11-13T16:31:03.691829+02:00", + "id":"c7ac894e4ca34e618e03a02d8799dc69" + } + ], + "complaintPeriod":{ + "startDate":"2015-11-13T16:17:00.375880+02:00", + "endDate":"2015-11-14T16:31:06.979761+02:00" + }, + "contracts":[ + { + "status":"active", + "documents":[ + { + "format":"text/plain", + "url":"https://lb.api-sandbox.openprocurement.org/api/0.9/tenders/3216137f17fb452db202daad1f9e73ad/awards/7054491a5e514699a56e44d32e23edf7/contracts/045c478807c04215950b4d74e6861cb1/documents/14dbf158b9ed4a478a59d19c90dbdf5d?download=9d948173e65441409f06e0b81674b39a", + "title":"3.jpg", + "datePublished":"2015-11-13T19:01:16.748785+02:00", + "dateModified":"2015-11-13T19:01:16.748829+02:00", + "id":"14dbf158b9ed4a478a59d19c90dbdf5d" + } + ], + "awardID":"7054491a5e514699a56e44d32e23edf7", + "id":"045c478807c04215950b4d74e6861cb1" + } + ], + "suppliers":[ + { + "contactPoint":{ + "telephone":"", + "name":"some6", + "email":"some6@mailinator.com" + }, + "identifier":{ + "scheme":"UA-EDR", + "id":"62123463", + "legalName":"some6" + }, + "name":"some6", + "address":{ + "postalCode":"04119", + "countryName":"\u0423\u043a\u0440\u0430\u0438\u043d\u0430", + "streetAddress":"", + "region":"\u0410\u0420 \u041a\u0440\u044b\u043c", + "locality":"ffff" + } + } + ], + "bid_id":"ad9ac917ff0049178acc3613bb14a691", + "value":{ + "currency":"UAH", + "amount":300.0, + "valueAddedTaxIncluded":false + }, + "date":"2015-11-13T16:17:00.376251+02:00", + "id":"7054491a5e514699a56e44d32e23edf7", + "lotId": "7d774fbf1e86420484c7d1a005cc283f" + } + ], + "dateModified":"2015-12-12T03:06:54.370277+02:00", + "awardCriteria":"lowestCost" + } +} diff --git a/openprocurement_client/tests/data/lots.json b/openprocurement_client/tests/data/lots.json new file mode 100644 index 0000000..384ef8a --- /dev/null +++ b/openprocurement_client/tests/data/lots.json @@ -0,0 +1,153 @@ +{ + "next_page":{ + "path":"/api/0.10/tenders?offset=2015-12-25T18%3A04%3A36.264176%2B02%3A00", + "uri":"https://lb.api-sandbox.openprocurement.org/api/0.10/tenders?offset=2015-12-25T18%3A04%3A36.264176%2B02%3A00", + "offset":"2015-12-25T18:04:36.264176+02:00" + }, + "data":[ + { + "id":"823d50b3236247adad28a5a66f74db42", + "dateModified":"2015-11-13T18:50:00.753811+02:00" + }, + { + "id":"f3849ade33534174b8402579152a5f41", + "dateModified":"2015-11-16T01:15:00.469896+02:00" + }, + { + "id":"f3849ade33534174b8402579152a5f41", + "dateModified":"2015-11-16T12:00:00.960077+02:00" + }, + { + "id":"3be3664065994d1e8847beb597c014bf", + "dateModified":"2015-11-16T21:15:00.404214+02:00" + }, + { + "id":"711cfa82c54147b686f6755adb22364d", + "dateModified":"2015-11-17T18:02:00.456050+02:00" + }, + { + "id":"730fe73cb7be4f92bce472484236e9ee", + "dateModified":"2015-11-18T18:30:00.410770+02:00" + }, + { + "id":"496ec128323f45679daf9ebcb1ec62f6", + "dateModified":"2015-11-20T16:20:37.977312+02:00" + }, + { + "id":"18d566bed8cc4f2e846ca5d64c6bdfed", + "dateModified":"2015-12-01T11:48:33.784585+02:00" + }, + { + "id":"21733c5ed0be4b259c3345310f425a82", + "dateModified":"2015-12-02T13:54:13.656648+02:00" + }, + { + "id":"b35a1151b7a84562addb47f66193a309", + "dateModified":"2015-12-12T02:45:36.355426+02:00" + }, + { + "id":"ce9751da26a84c2390368ffa5adfd74c", + "dateModified":"2015-12-12T03:04:16.059667+02:00" + }, + { + "id":"823d50b3236247adad28a5a66f74db42", + "dateModified":"2015-12-12T03:06:54.370277+02:00" + }, + { + "id":"0085cf76ad444ad0ae625fc17f366dd2", + "dateModified":"2015-12-12T14:30:38.596246+02:00" + }, + { + "id":"d97613278dd547f2be5523cdc5614880", + "dateModified":"2015-12-12T14:31:51.342309+02:00" + }, + { + "id":"71161344890c4231b1487296f56aa910", + "dateModified":"2015-12-14T13:10:38.771625+02:00" + }, + { + "id":"759a81e58cf04b5ea0587942d0925faa", + "dateModified":"2015-12-16T19:56:53.874070+02:00" + }, + { + "id":"ad681d050d0e42169a80b86d5b591c20", + "dateModified":"2015-12-22T13:14:25.253453+02:00" + }, + { + "id":"a2e4464a08d64addb6c7a63da48ddb87", + "dateModified":"2015-12-23T17:09:15.145867+02:00" + }, + { + "id":"eea0c2f3cf3f4206b8cbba813b9a527b", + "dateModified":"2015-12-23T17:15:23.479628+02:00" + }, + { + "id":"847411c7b03f4f91b97fecb70c6e6275", + "dateModified":"2015-12-23T17:54:39.470396+02:00" + }, + { + "id":"599e63e6fb1349078fb01e4f9e8a812c", + "dateModified":"2015-12-23T17:55:36.317529+02:00" + }, + { + "id":"d63a7302316c4d15b46aeb7bcd4f1dbe", + "dateModified":"2015-12-23T17:56:01.709307+02:00" + }, + { + "id":"6496299a3c8e482f9017d855483a97b5", + "dateModified":"2015-12-23T17:57:57.376623+02:00" + }, + { + "id":"a513848583cc4d1d806c78e5131ad068", + "dateModified":"2015-12-23T17:59:52.101031+02:00" + }, + { + "id":"79aa9fd2bb43471cbcb0b97f6965e5f6", + "dateModified":"2015-12-24T11:39:09.071184+02:00" + }, + { + "id":"b2cdcda417434c7b889c82a81927bb73", + "dateModified":"2015-12-24T11:40:20.172257+02:00" + }, + { + "id":"58eca935e0e24805b561a1588ae64ef3", + "dateModified":"2015-12-24T11:48:57.584694+02:00" + }, + { + "id":"78b889ec869544b9b47c8740549ed20a", + "dateModified":"2015-12-24T11:51:07.149689+02:00" + }, + { + "id":"258ef598759946dbb30e7ed67bfc2346", + "dateModified":"2015-12-24T11:52:16.196052+02:00" + }, + { + "id":"639ecaca9db24228a9fe0eb3494aa0e3", + "dateModified":"2015-12-25T13:28:22.136939+02:00" + }, + { + "id":"ca10599dfcbe416bb513416c13073c5f", + "dateModified":"2015-12-25T15:19:53.913160+02:00" + }, + { + "id":"21e551bf7f194d8aaba29bf2e4949b90", + "dateModified":"2015-12-25T16:00:00.319589+02:00" + }, + { + "id":"dd7b13a956b44a34bbaeb2bfa1910c03", + "dateModified":"2015-12-25T16:07:19.809837+02:00" + }, + { + "id":"f8f21e8b0c104747b8abf5ece4fb5d72", + "dateModified":"2015-12-25T17:06:32.885207+02:00" + }, + { + "id":"48dcb014d003454b8875975bb531147f", + "dateModified":"2015-12-25T17:16:05.208447+02:00" + }, + { + "id":"7f35a555d5c64b34a7cbc454fab5628c", + "dateModified":"2015-12-25T18:04:36.264176+02:00" + } + ] +} diff --git a/openprocurement_client/tests/data_dict.py b/openprocurement_client/tests/data_dict.py index 2e2938f..06605c5 100644 --- a/openprocurement_client/tests/data_dict.py +++ b/openprocurement_client/tests/data_dict.py @@ -45,3 +45,19 @@ "patch_change_rationale": u'Друга і третя поставка має бути розфасована', "new_token": 'new0contract0token123412341234' }) + +TEST_LOT_KEYS = munchify({ + "asset_id": '823d50b3236247adad28a5a66f74db42', + "lot_id": '823d50b3236247adad28a5a66f74db42', + "token": 'f6247c315d2744f1aa18c7c3de523bc3', + "new_token": '4fa3e89efbaa46f0a1b86b911bec76e7' + +}) + +TEST_ASSET_KEYS = munchify({ + "asset_id": '823d50b3236247adad28a5a66f74db42', + "lot_id": '823d50b3236247adad28a5a66f74db42', + "token": 'f6247c315d2744f1aa18c7c3de523bc3', + "new_token": '4fa3e89efbaa46f0a1b86b911bec76e7' + +}) \ No newline at end of file diff --git a/openprocurement_client/tests/registry_tests.py b/openprocurement_client/tests/registry_tests.py new file mode 100644 index 0000000..3081fdd --- /dev/null +++ b/openprocurement_client/tests/registry_tests.py @@ -0,0 +1,165 @@ +from __future__ import print_function +from gevent import monkey; monkey.patch_all() +from gevent.pywsgi import WSGIServer +from bottle import Bottle +from StringIO import StringIO +from collections import Iterable +from simplejson import loads, load +from munch import munchify +import mock +import sys +import unittest +from openprocurement_client.registry_client import RegistryClient, RegistryClientSync + +from openprocurement_client.document_service_client \ + import DocumentServiceClient +from openprocurement_client.exceptions import InvalidResponse, ResourceNotFound + +from openprocurement_client.tests.data_dict import TEST_ASSET_KEYS, TEST_LOT_KEYS, \ + TEST_TENDER_KEYS_LIMITED, TEST_PLAN_KEYS, TEST_CONTRACT_KEYS +from openprocurement_client.tests._server import \ + API_KEY, API_VERSION, AUTH_DS_FAKE, DS_HOST_URL, DS_PORT, \ + HOST_URL, location_error, PORT, ROOT, setup_routing, setup_routing_ds, \ + resource_partition, resource_filter + +class BaseTestClass(unittest.TestCase): + + def setting_up(self, client, resource=None): + self.app = Bottle() + self.app.router.add_filter('resource_filter', resource_filter) + setup_routing(self.app) + self.server = WSGIServer(('localhost', PORT), self.app, log=None) + try: + self.server.start() + except Exception as error: + print(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], + file=sys.stderr) + raise error + ds_client = getattr(self, 'ds_client', None) + self.client = client('', host_url=HOST_URL, api_version=API_VERSION, + ds_client=ds_client) + if resource: + self.client = client('', host_url=HOST_URL, api_version=API_VERSION, + ds_client=ds_client, resource=resource) + + @classmethod + def setting_up_ds(cls): + cls.app_ds = Bottle() + cls.server_ds \ + = WSGIServer(('localhost', DS_PORT), cls.app_ds, log=None) + try: + cls.server_ds.start() + except Exception as error: + print(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], + file=sys.stderr) + raise error + + cls.ds_client = DocumentServiceClient(host_url=DS_HOST_URL, + auth_ds=AUTH_DS_FAKE) + # to test units performing file operations outside the DS uncomment + # following lines: + # import logging + # logging.basicConfig() + # cls.ds_client = None + + setup_routing_ds(cls.app_ds) + + @classmethod + def setUpClass(cls): + cls.setting_up_ds() + + + @classmethod + def tearDownClass(cls): + cls.server_ds.stop() + + +class AssetsRegistryTestCase(BaseTestClass): + def setUp(self): + self.setting_up(client=RegistryClient) + + with open(ROOT + 'assets.json') as assets: + self.assets = munchify(load(assets)) + with open(ROOT + 'asset_{}.json'.format(TEST_ASSET_KEYS.asset_id)) as asset: + self.asset = munchify(load(asset)) + + + def tearDown(self): + self.server.stop() + + def test_get_assets(self): + setup_routing(self.app, routes=["assets"]) + assets = self.client.get_assets() + self.assertIsInstance(assets, Iterable) + self.assertEqual(assets['data'], self.assets.data) + + @mock.patch('openprocurement_client.registry_client.RegistryClient.request') + def test_get_assets_failed(self, mock_request): + mock_request.return_value = munchify({'status_code': 404}) + self.client.params['offset'] = 'offset_value' + with self.assertRaises(InvalidResponse) as e: + self.client.get_assets() + + def test_get_asset(self): + setup_routing(self.app, routes=["asset"]) + asset = self.client.get_asset(TEST_ASSET_KEYS.asset_id) + self.assertEqual(asset, self.asset) + + def test_patch_asset(self): + setup_routing(self.app, routes=["asset_patch"]) + self.asset.data.description = 'test_patch_asset' + + patched_asset = self.client.patch_asset(self.asset) + self.assertEqual(patched_asset.data.id, self.asset.data.id) + self.assertEqual(patched_asset.data.description, self.asset.data.description) + +class LotRegistryTestCase(BaseTestClass): + def setUp(self): + self.setting_up(client=RegistryClient, resource='lots') + + with open(ROOT + 'lots.json') as lots: + self.lots = munchify(load(lots)) + with open(ROOT + 'lot_{}.json'.format(TEST_LOT_KEYS.lot_id)) as lot: + + self.lot = munchify(load(lot)) + + + def tearDown(self): + self.server.stop() + + def test_get_lots(self): + setup_routing(self.app, routes=["lots"]) + lots = self.client.get_lots() + self.assertIsInstance(lots, Iterable) + self.assertEqual(lots['data'], self.lots.data) + + @mock.patch('openprocurement_client.registry_client.RegistryClient.request') + def test_get_lots_failed(self, mock_request): + mock_request.return_value = munchify({'status_code': 404}) + self.client.params['offset'] = 'offset_value' + with self.assertRaises(InvalidResponse) as e: + self.client.get_lots() + + def test_get_lot(self): + + setup_routing(self.app, routes=["lot"]) + lot = self.client.get_lot(TEST_LOT_KEYS.lot_id) + self.assertEqual(lot, self.lot) + + def test_patch_lot(self): + setup_routing(self.app, routes=["lot_patch"]) + self.lot.data.description = 'test_patch_lot' + + patched_lot = self.client.patch_lot(self.lot) + self.assertEqual(patched_lot.data.id, self.lot.data.id) + self.assertEqual(patched_lot.data.description, self.lot.data.description) + +def suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(AssetsRegistryTestCase)) + suite.addTest(unittest.makeSuite(LotRegistryTestCase)) + return suite + + +if __name__ == '__main__': + unittest.main(defaultTest='suite') From da2de63d491dd910f29fc1083e72911881fbcaf2 Mon Sep 17 00:00:00 2001 From: Vladyslav Velychko Date: Wed, 9 Aug 2017 17:56:38 +0300 Subject: [PATCH 3/3] RegistryClientSync tests and codestyle --- openprocurement_client/registry_client.py | 12 +--- .../tests/registry_tests.py | 63 +++++++++++++++---- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/openprocurement_client/registry_client.py b/openprocurement_client/registry_client.py index e25f7fe..e94ed2e 100644 --- a/openprocurement_client/registry_client.py +++ b/openprocurement_client/registry_client.py @@ -9,8 +9,6 @@ from simplejson import loads - - class RegistryClient(APIBaseClient): """ Client for validate members by EDR """ @@ -19,7 +17,7 @@ class RegistryClient(APIBaseClient): def __init__(self, key, - resource='assets', # another possible value is 'assets' + resource='lots', # another possible value is 'assets' host_url=None, api_version=None, params=None, @@ -41,7 +39,6 @@ def get_assets(self, extra_headers=None): return process_response(response) def get_lots(self, extra_headers=None): - resp = self.request('GET', 'http://localhost:20602/api/0.10/lots') self.headers.update(extra_headers or {}) @@ -61,7 +58,6 @@ def get_asset(self, asset_id=None, extra_headers=None): return process_response(response) def get_lot(self, lot_id=None, extra_headers=None): - self.headers.update(extra_headers or {}) response = self.request( @@ -71,12 +67,12 @@ def get_lot(self, lot_id=None, extra_headers=None): return process_response(response) def patch_asset(self, asset): - return self._patch_resource_item( '{}/{}'.format(self.prefix_path, asset['data']['id']), payload=asset, headers={'X-Access-Token': self._get_access_token(asset)} ) + def patch_lot(self, lot): return self._patch_resource_item( '{}/{}'.format(self.prefix_path, lot['data']['id']), @@ -84,8 +80,8 @@ def patch_lot(self, lot): headers={'X-Access-Token': self._get_access_token(lot)} ) -class RegistryClientSync(RegistryClient): +class RegistryClientSync(RegistryClient): def sync_item(self, params=None, extra_headers=None): _params = (params or {}).copy() _params['feed'] = 'changes' @@ -108,9 +104,7 @@ def get_asset_by_id(self, id, extra_headers=None): return super(RegistryClientSync, self).get_asset(id) - def process_response(response): - if response.status_code == 200: return munchify(loads(response.text)) raise InvalidResponse(response) diff --git a/openprocurement_client/tests/registry_tests.py b/openprocurement_client/tests/registry_tests.py index 3081fdd..5b71a60 100644 --- a/openprocurement_client/tests/registry_tests.py +++ b/openprocurement_client/tests/registry_tests.py @@ -1,5 +1,7 @@ from __future__ import print_function -from gevent import monkey; monkey.patch_all() +from gevent import monkey; + +monkey.patch_all() from gevent.pywsgi import WSGIServer from bottle import Bottle from StringIO import StringIO @@ -19,11 +21,11 @@ TEST_TENDER_KEYS_LIMITED, TEST_PLAN_KEYS, TEST_CONTRACT_KEYS from openprocurement_client.tests._server import \ API_KEY, API_VERSION, AUTH_DS_FAKE, DS_HOST_URL, DS_PORT, \ - HOST_URL, location_error, PORT, ROOT, setup_routing, setup_routing_ds, \ + HOST_URL, location_error, PORT, ROOT, setup_routing, setup_routing_ds, \ resource_partition, resource_filter -class BaseTestClass(unittest.TestCase): +class BaseTestClass(unittest.TestCase): def setting_up(self, client, resource=None): self.app = Bottle() self.app.router.add_filter('resource_filter', resource_filter) @@ -68,7 +70,6 @@ def setting_up_ds(cls): def setUpClass(cls): cls.setting_up_ds() - @classmethod def tearDownClass(cls): cls.server_ds.stop() @@ -76,14 +77,13 @@ def tearDownClass(cls): class AssetsRegistryTestCase(BaseTestClass): def setUp(self): - self.setting_up(client=RegistryClient) + self.setting_up(client=RegistryClient, resource='assets') with open(ROOT + 'assets.json') as assets: self.assets = munchify(load(assets)) with open(ROOT + 'asset_{}.json'.format(TEST_ASSET_KEYS.asset_id)) as asset: self.asset = munchify(load(asset)) - def tearDown(self): self.server.stop() @@ -113,17 +113,16 @@ def test_patch_asset(self): self.assertEqual(patched_asset.data.id, self.asset.data.id) self.assertEqual(patched_asset.data.description, self.asset.data.description) -class LotRegistryTestCase(BaseTestClass): + +class LotsRegistryTestCase(BaseTestClass): def setUp(self): self.setting_up(client=RegistryClient, resource='lots') with open(ROOT + 'lots.json') as lots: self.lots = munchify(load(lots)) with open(ROOT + 'lot_{}.json'.format(TEST_LOT_KEYS.lot_id)) as lot: - self.lot = munchify(load(lot)) - def tearDown(self): self.server.stop() @@ -141,7 +140,6 @@ def test_get_lots_failed(self, mock_request): self.client.get_lots() def test_get_lot(self): - setup_routing(self.app, routes=["lot"]) lot = self.client.get_lot(TEST_LOT_KEYS.lot_id) self.assertEqual(lot, self.lot) @@ -154,10 +152,53 @@ def test_patch_lot(self): self.assertEqual(patched_lot.data.id, self.lot.data.id) self.assertEqual(patched_lot.data.description, self.lot.data.description) + +class AssetsClientSyncTestCase(BaseTestClass): + """""" + + def setUp(self): + self.setting_up(client=RegistryClientSync, resource='assets') + + with open(ROOT + 'assets.json') as assets: + self.assets = munchify(load(assets)) + with open(ROOT + 'asset_' + TEST_ASSET_KEYS.asset_id + '.json') as asset: + self.asset = munchify(load(asset)) + + def tearDown(self): + self.server.stop() + + def test_sync_assets(self): + setup_routing(self.app, routes=['assets']) + assets = self.client.sync_item() + self.assertIsInstance(assets.data, Iterable) + self.assertEqual(assets.data, self.assets.data) + + +class LotsClientSyncTestCase(BaseTestClass): + """""" + + def setUp(self): + self.setting_up(client=RegistryClientSync) + + with open(ROOT + 'lots.json') as lots: + self.lots = munchify(load(lots)) + with open(ROOT + 'lot_' + TEST_ASSET_KEYS.lot_id + '.json') as lot: + self.lot = munchify(load(lot)) + + def tearDown(self): + self.server.stop() + + def test_sync_lots(self): + setup_routing(self.app, routes=['lots']) + lots = self.client.sync_item() + self.assertIsInstance(lots.data, Iterable) + self.assertEqual(lots.data, self.lots.data) + + def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(AssetsRegistryTestCase)) - suite.addTest(unittest.makeSuite(LotRegistryTestCase)) + suite.addTest(unittest.makeSuite(LotsRegistryTestCase)) return suite