Skip to content

Commit

Permalink
Merge pull request #40 from ITVaan/add_field_status
Browse files Browse the repository at this point in the history
Додали поля  registrationStatusDetails, registrationStatus
  • Loading branch information
kroman0 committed May 29, 2017
2 parents 3377762 + 4b95345 commit 0bcd956
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 15 deletions.
24 changes: 12 additions & 12 deletions docs.py
Expand Up @@ -9,6 +9,7 @@
from openprocurement.integrations.edr.tests._server import (setup_routing, response_code, response_details,
payment_required, too_many_requests, response_passport,
check_headers)
from openprocurement.integrations.edr.utils import ROUTE_PREFIX
from webtest import TestApp

now = datetime.now()
Expand All @@ -25,7 +26,6 @@ class DumpsTestAppwebtest(TestApp):
def do_request(self, req, status=None, expect_errors=None):
req.headers.environ["HTTP_HOST"] = "api-sandbox.openprocurement.org"
origin_path = req.headers.environ["PATH_INFO"] # save original path
req.headers.environ["PATH_INFO"] = '/api/1.0{original_path}'.format(original_path=origin_path) # add version

if hasattr(self, 'file_obj') and not self.file_obj.closed:
self.file_obj.write(req.as_bytes(True))
Expand Down Expand Up @@ -67,15 +67,15 @@ def setUp(self):
self.app.authorization = ('Basic', ('platform', 'platform'))

def test_docs_tutorial(self):
request_path = '/verify?{}={}'
details_path = '/details/{}'
request_path = '{}/verify?{}={}'
details_path = '{}/details/{}'
setup_routing(self.edr_api_app, func=response_code)

# Basic request

with open('docs/source/tutorial/basic_request.http', 'w') as self.app.file_obj:
self.app.authorization = ('Basic', ('platform', 'platform'))
response = self.app.get(request_path.format('id', edrpou))
response = self.app.get(request_path.format(ROUTE_PREFIX, 'id', edrpou))
self.assertEqual(response.status, '200 OK')
self.app.file_obj.write("\n")

Expand All @@ -85,7 +85,7 @@ def test_docs_tutorial(self):

with open('docs/source/tutorial/ipn.http', 'w') as self.app.file_obj:
self.app.authorization = ('Basic', ('platform', 'platform'))
response = self.app.get(request_path.format('id', ipn))
response = self.app.get(request_path.format(ROUTE_PREFIX, 'id', ipn))
self.assertEqual(response.status, '200 OK')
self.app.file_obj.write("\n")

Expand All @@ -95,7 +95,7 @@ def test_docs_tutorial(self):

with open('docs/source/tutorial/payment_requests.http', 'w') as self.app.file_obj:
self.app.authorization = ('Basic', ('platform', 'platform'))
response = self.app.get(request_path.format('id', edrpou), status=403)
response = self.app.get(request_path.format(ROUTE_PREFIX, 'id', edrpou), status=403)
self.assertEqual(response.status, '403 Forbidden')
self.app.file_obj.write("\n")

Expand All @@ -104,7 +104,7 @@ def test_docs_tutorial(self):
# empty response
with open('docs/source/tutorial/empty_response.http', 'w') as self.app.file_obj:
self.app.authorization = ('Basic', ('platform', 'platform'))
response = self.app.get(request_path.format('id', invalid_edrpou), status=404)
response = self.app.get(request_path.format(ROUTE_PREFIX, 'id', invalid_edrpou), status=404)
self.assertEqual(response.status, '404 Not Found')
self.app.file_obj.write("\n")

Expand All @@ -114,7 +114,7 @@ def test_docs_tutorial(self):

with open('docs/source/tutorial/too_many_requests.http', 'w') as self.app.file_obj:
self.app.authorization = ('Basic', ('platform', 'platform'))
response = self.app.get(request_path.format('id', edrpou), status=429)
response = self.app.get(request_path.format(ROUTE_PREFIX, 'id', edrpou), status=429)
self.assertEqual(response.status, '429 Too Many Requests')
self.app.file_obj.write("\n")

Expand All @@ -124,7 +124,7 @@ def test_docs_tutorial(self):

with open('docs/source/tutorial/without_param.http', 'w') as self.app.file_obj:
self.app.authorization = ('Basic', ('platform', 'platform'))
response = self.app.get('/verify', status=403)
response = self.app.get('{}/verify'.format(ROUTE_PREFIX), status=403)
self.assertEqual(response.status, '403 Forbidden')
self.app.file_obj.write("\n")

Expand All @@ -133,20 +133,20 @@ def test_docs_tutorial(self):
# details
with open('docs/source/tutorial/details.http', 'w') as self.app.file_obj:
self.app.authorization = ('Basic', ('robot', 'robot'))
response = self.app.get(details_path.format(x_edrInternalId))
response = self.app.get(details_path.format(ROUTE_PREFIX, x_edrInternalId))
self.assertEqual(response.status, '200 OK')
self.app.file_obj.write("\n")

def test_auth_errors(self):
request_path = '/verify?{}={}'
request_path = '{}/verify?{}={}'

setup_routing(self.edr_api_app, func=check_headers)
# Invalid token
self.app = DumpsTestAppwebtest("config:test_conf/tests_copy_2.ini",
relative_to=os.path.dirname(base_test.__file__))
with open('docs/source/tutorial/invalid_token.http', 'w') as self.app.file_obj:
self.app.authorization = ('Basic', ('platform', 'platform'))
response = self.app.get(request_path.format('id', edrpou), status=403)
response = self.app.get(request_path.format(ROUTE_PREFIX, 'id', edrpou), status=403)
self.assertEqual(response.status, '403 Forbidden')
self.app.file_obj.write("\n")

7 changes: 6 additions & 1 deletion docs/source/bot.rst
Expand Up @@ -31,4 +31,9 @@ File-reference also includes service information in `meta`.
Value `meta.version` now have value 1.1.1. First number - major version (delete field, rename, remove), second number -
minor version (add field), third number - bugfix version (changes that do not change fields, but fix bugs).
For example, changing of file-reference name from `edr_request.yaml` to `edr_identification.yaml` increased
first number(major version), adding `meta.author` field increased second number (minor version).
first number(major version), adding `meta.author` field increased second number (minor version).

Change value of `meta.version` filed to 1.2.1 after adding fields to file-reference:

* `registrationStatusDetails` - text state of the entity (uk),
* `registrationStatus` - text state of the entity.
19 changes: 17 additions & 2 deletions docs/source/locale/uk/LC_MESSAGES/bot.po
Expand Up @@ -3,12 +3,11 @@
# This file is distributed under the same license as the
# openprocurement.integrations.edr package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2017.

msgid ""
msgstr ""
"Project-Id-Version: openprocurement.integrations.edr 0.1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-24 12:24+0300\n"
"POT-Creation-Date: 2017-05-29 16:33+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -111,3 +110,19 @@ msgstr ""
"зміна назви файлу з `edr_request.yaml` на `edr_identification.yaml` це "
"збільшення major версії, а додавання поля `meta.author` це збільшення "
"minor версії."

#: ../../source/bot.rst:36
msgid ""
"Change value of `meta.version` filed to 1.2.1 after adding fields to "
"file-reference:"
msgstr ""
"Змінено значення поля `meta.version` на 1.2.1 у зв'язку з додаванням в файл-довідку наступних полів"

#: ../../source/bot.rst:38
msgid "`registrationStatusDetails` - text state of the entity (uk),"
msgstr "`registrationStatusDetails` - текстове відображення стану суб'єкта(укр),"

#: ../../source/bot.rst:39
msgid "`registrationStatus` - text state of the entity."
msgstr "`registrationStatus` - текстове відображення стану суб'єкта."

2 changes: 2 additions & 0 deletions docs/source/tutorial/details.http
Expand Up @@ -38,6 +38,8 @@ Content-Type: application/json; charset=UTF-8
],
"management": "ЗАГАЛЬНІ ЗБОРИ",
"name": "ПАТ КБ \"ПРИВАТБАНК\"",
"registrationStatusDetails": "зареєстровано",
"registrationStatus": "registered",
"identification": {
"scheme": "UA-EDR",
"id": "14360570",
Expand Down
2 changes: 2 additions & 0 deletions openprocurement/integrations/edr/tests/test_data_details.yaml
Expand Up @@ -35,5 +35,7 @@ data:
scheme: UA-EDR
management: ЗАГАЛЬНІ ЗБОРИ
name: ПАТ КБ "ПРИВАТБАНК"
registrationStatus: registered
registrationStatusDetails: зареєстровано
meta:
sourceDate: '2017-04-25T11:56:36+00:00'
8 changes: 8 additions & 0 deletions openprocurement/integrations/edr/tests/verify.py
Expand Up @@ -310,6 +310,8 @@ def test_details(self):
u"description": u"Інша допоміжна діяльність у сфері фінансових послуг, крім страхування та пенсійного забезпечення"}],
u"management": u"ЗАГАЛЬНІ ЗБОРИ",
u"name": u"ПАТ КБ \"ПРИВАТБАНК\"",
u"registrationStatus": u"registered",
u"registrationStatusDetails": u"зареєстровано",
u"identification": {u"scheme": u"UA-EDR",
u"id": u"14360570",
u"legalName": u"АКЦІОНЕРНЕ ТОВАРИСТВО КОМЕРЦІЙНИЙ БАНК \"ПРИВАТБАНК\""},
Expand Down Expand Up @@ -368,6 +370,8 @@ def test_null_fields(self):
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['data'], {
u"management": u"ЗАГАЛЬНІ ЗБОРИ",
u"registrationStatus": u"registered",
u"registrationStatusDetails": u"зареєстровано",
u"identification": {u"scheme": u"UA-EDR",
u"id": u"14360570"},
u"address": {u"postalCode": u"49094",
Expand All @@ -394,6 +398,8 @@ def test_sandbox_mode_data_details(self):
self.assertEqual(response.json['data'], {
u"management": u"КЕРІВНИК",
u"name": u"ДЕРЖАВНЕ УПРАВЛІННЯ СПРАВАМИ",
u"registrationStatus": u"registered",
u"registrationStatusDetails": u"зареєстровано",
u"identification": {
u"scheme": u"UA-EDR",
u"id": u"00037256",
Expand Down Expand Up @@ -426,6 +432,8 @@ def test_sandbox_mode_data_details(self):
self.assertEqual(response.json['data'], {
u"management": u"КЕРІВНИК",
u"name": u"ДЕРЖАВНЕ УПРАВЛІННЯ СПРАВАМИ",
u"registrationStatus": u"registered",
u"registrationStatusDetails": u"зареєстровано",
u"identification": {
u"scheme": u"UA-EDR",
u"id": u"00037256",
Expand Down
2 changes: 2 additions & 0 deletions openprocurement/integrations/edr/utils.py
Expand Up @@ -207,6 +207,8 @@ def prepare_data_details(data):
'scheme': activityKind_scheme,
'description': activity_kind.get('name')})
result = {'name': data.get('names').get('short') if data.get('names') else None,
'registrationStatus': registration_status_by_code(data.get('state')),
'registrationStatusDetails': data.get('state_text'),
'identification': {'scheme': identification_schema,
'id': data.get('code'),
'legalName': data.get('names').get('display') if data.get('names') else None},
Expand Down

0 comments on commit 0bcd956

Please sign in to comment.