Skip to content

Commit

Permalink
Fix base url pkk client, actualize README and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GregEremeev committed Apr 15, 2020
1 parent 9cec529 commit 29c090d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## rosreestr-api

#### `rosreestr-api` is an BSD licensed library written in Python. It will be helpful for you if you need to work with rosreestr.ru/api or pkk5.rosreestr.ru/api to obtain info related to realty objects.
#### `rosreestr-api` is an BSD licensed library written in Python. It will be helpful for you if you need to work with rosreestr.ru/api or pkk.rosreestr.ru/api to obtain info related to realty objects.

### Quick start

Expand Down Expand Up @@ -45,13 +45,19 @@ api_client.get_region_types(region_id=region_id)

3 Different ways how to get geo info about realty objects:
```python
from rosreestr_api.clients import PKK5RosreestrAPIClient
from rosreestr_api.clients import PKKRosreestrAPIClient

api_client = PKK5RosreestrAPIClient()
api_client = PKKRosreestrAPIClient()

# get objects by cadastral id
api_client.get_object_by_cadastral_id('77:17:0000000:11471')
# get building by cadastral id
api_client.get_building_by_cadastral_id('16:50:110108:2815')

# get objects by coordinates
api_client.get_object_by_coordinates(lat=55.542, long=37.483)
# get parcel by cadastral id
api_client.get_parcel_by_cadastral_id('77:17:0000000:11471')

# get parcel by coordinates
api_client.get_parcel_by_coordinates(lat=55.542, long=37.483)

# get building by coordinates
api_client.get_building_by_coordinates(lat=55.828952, long=49.097076)
```
4 changes: 2 additions & 2 deletions rosreestr_api/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,14 @@ def get_object(self, obj_id: str):
return self._get_response_body(response)


class PKK5RosreestrAPIClient:
class PKKRosreestrAPIClient:

# about rosreestr's coordinate system
# http://holmogori.ru/govinfo/rosreestr/media/2017/4/12/o-primenyaemyih-sistemah-koordinat-dlya-vedeniya-egrn/
# about МСК
# https://geostart.ru/post/312

BASE_URL = 'https://pkk5.rosreestr.ru/api'
BASE_URL = 'https://pkk.rosreestr.ru/api'
SEARCH_OBJECT_BY_CADASTRAL_ID = (
BASE_URL + '/features/{object_type}?text={{cadastral_id}}&limit={{limit}}&'
+ 'tolerance={{tolerance}}')
Expand Down
File renamed without changes.
32 changes: 16 additions & 16 deletions rosreestr_api/tests/test_api_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import pytest
import httpretty

from rosreestr_api.tests import rosreestr_client_fixtures, pkk5_client_fixtures
from rosreestr_api.tests import rosreestr_client_fixtures, pkk_client_fixtures
from rosreestr_api.clients import (
AddressWrapper, RosreestrAPIClient, PKK5RosreestrAPIClient)
AddressWrapper, RosreestrAPIClient, PKKRosreestrAPIClient)


def test_fill_address_wrapper_without_macro_region():
Expand Down Expand Up @@ -144,9 +144,9 @@ def test_get_object_strip_cadastral_id(self):
mock_http_client_instance.get.assert_called_once_with(expected_arg)


class TestPKK5RosreestrAPIClient:
class TestPKKRosreestrAPIClient:

BASE_URL = 'https://pkk5.rosreestr.ru/api'
BASE_URL = 'https://pkk.rosreestr.ru/api'
SEARCH_OBJECT_BY_CADASTRAL_ID = (
BASE_URL + '/features/{object_type}?text={{cadastral_id}}&limit={{limit}}&'
+ 'tolerance={{tolerance}}')
Expand All @@ -168,13 +168,13 @@ def test_get_parcel_by_coordinates(self):
url = self.SEARCH_PARCEL_BY_COORDINATES_URL.format(**search_params)
httpretty.register_uri(
method=httpretty.GET, uri=url,
body=pkk5_client_fixtures.PARCEL_BY_COORDINATES_RESPONSE,
body=pkk_client_fixtures.PARCEL_BY_COORDINATES_RESPONSE,
content_type=self.CONTENT_TYPE_JSON)

api_client = PKK5RosreestrAPIClient()
api_client = PKKRosreestrAPIClient()
obj = api_client.get_parcel_by_coordinates(**search_params)

assert pkk5_client_fixtures.PARCEL_BY_COORDINATES == obj
assert pkk_client_fixtures.PARCEL_BY_COORDINATES == obj

@httpretty.activate
def test_get_parcel_by_cadastral_id(self):
Expand All @@ -183,13 +183,13 @@ def test_get_parcel_by_cadastral_id(self):
url = self.SEARCH_PARCEL_BY_CADASTRAL_ID_URL.format(**search_params)
httpretty.register_uri(
method=httpretty.GET, uri=url,
body=pkk5_client_fixtures.PARCEL_BY_CADASTRAL_ID_RESPONSE,
body=pkk_client_fixtures.PARCEL_BY_CADASTRAL_ID_RESPONSE,
content_type=self.CONTENT_TYPE_JSON)

api_client = PKK5RosreestrAPIClient()
api_client = PKKRosreestrAPIClient()
obj = api_client.get_parcel_by_cadastral_id(**search_params)

assert pkk5_client_fixtures.PARCEL_BY_CADASTRAL_ID == obj
assert pkk_client_fixtures.PARCEL_BY_CADASTRAL_ID == obj

@httpretty.activate
def test_get_building_by_coordinates(self):
Expand All @@ -199,13 +199,13 @@ def test_get_building_by_coordinates(self):
url = self.SEARCH_BUILDING_BY_COORDINATES_URL.format(**search_params)
httpretty.register_uri(
method=httpretty.GET, uri=url,
body=pkk5_client_fixtures.BUILDING_BY_COORDINATES_RESPONSE,
body=pkk_client_fixtures.BUILDING_BY_COORDINATES_RESPONSE,
content_type=self.CONTENT_TYPE_JSON)

api_client = PKK5RosreestrAPIClient()
api_client = PKKRosreestrAPIClient()
obj = api_client.get_building_by_coordinates(**search_params)

assert pkk5_client_fixtures.BUILDING_BY_COORDINATES == obj
assert pkk_client_fixtures.BUILDING_BY_COORDINATES == obj

@httpretty.activate
def test_get_building_by_cadastral_id(self):
Expand All @@ -214,10 +214,10 @@ def test_get_building_by_cadastral_id(self):
url = self.SEARCH_BUILDING_BY_CADASTRAL_ID_URL.format(**search_params)
httpretty.register_uri(
method=httpretty.GET, uri=url,
body=pkk5_client_fixtures.BUILDING_BY_CADASTRAL_ID_RESPONSE,
body=pkk_client_fixtures.BUILDING_BY_CADASTRAL_ID_RESPONSE,
content_type=self.CONTENT_TYPE_JSON)

api_client = PKK5RosreestrAPIClient()
api_client = PKKRosreestrAPIClient()
obj = api_client.get_building_by_cadastral_id(**search_params)

assert pkk5_client_fixtures.BUILDING_BY_CADASTRAL_ID == obj
assert pkk_client_fixtures.BUILDING_BY_CADASTRAL_ID == obj
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
name='rosreestr-api',
author='Greg Eremeev',
author_email='gregory.eremeev@gmail.com',
version='0.3.3',
version='0.3.4',
license='BSD-3-Clause',
url='https://github.com/GregEremeev/rosreestr-api',
install_requires=requirements,
description='Toolset to work with rosreestr.ru/api',
packages=find_packages(),
extras_require={'dev': ['ipdb==0.12', 'pytest==4.6.3', 'httpretty==0.9.6']},
extras_require={'dev': ['ipdb>=0.13.2', 'pytest>=5.4.1', 'httpretty>=1.0.2']},
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
Expand Down

0 comments on commit 29c090d

Please sign in to comment.