-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add historical #88
base: use_requests
Are you sure you want to change the base?
add historical #88
Conversation
Зміни мають іти з тестами |
@@ -242,8 +242,11 @@ def get_resource_item(self, id, headers=None): | |||
return self._get_resource_item('{}/{}'.format(self.prefix_path, id), | |||
headers=headers) | |||
|
|||
def get_resource_item_historical(self, id, headers=None): | |||
return self._get_resource_item('{}/{}/historical'.format(self.prefix_path, id), headers=headers) | |||
def get_resource_item_historical(self, id, revision, headers=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я б не робив revision
обовязковим
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Чому? Це викoристовується тільки для хісторікала, реквест без ревізії не має сенсу - щоб взяти актуальну версію документа, досить використати get_resource_item
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Щоб в еджі замінити ось це
response = client.request(
'GET', '{}/{}/historical'.format(api_client_dict['client'].prefix_path, id)
)
revisions_number = int(response.headers['x-revision-n'])
@vladkhard потрібно ще тести. |
def side_effect(_, headers): | ||
return item if headers["x-revision-n"] else response | ||
|
||
self.client._get_resource_item = MagicMock(side_effect=side_effect) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.client.get_resource_item_historical(item_id, revision=0) | ||
self.client.get_resource_item_historical(item_id, revision=revisions_limit + 1) | ||
self.client.get_resource_item_historical(item_id, revision=None) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут краще загорнути у for
і переконатись що ми дійсно отримуємо 404 всі рази.
@@ -1,12 +1,13 @@ | |||
import unittest | |||
|
|||
from openprocurement_client.tests import tests, tests_sync | |||
from openprocurement_client.tests import tests, tests_sync, tests_api_base_client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А де сам тест?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
упс
вже додав
@vladkhard тест провалився |
item_id, revision=revisions_limit - 1), actual_response) | ||
|
||
for revision in (0, revisions_limit + 1, None): | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for revision in (0, revisions_limit + 1, None):
with self.assertRaises(InvalidResponse) as e:
self.client.get_resource_item_historical(item_id, revision=revision)
self.assertEqual(e.exception.status_code, 404)
@vladkhard, дані зміни вже не акутальні оскільки |
This change is