Skip to content

Commit

Permalink
Fix pagination in objects_endpoint (#120)
Browse files Browse the repository at this point in the history
* Fix pagination in objects_endpoint

* PubNub SDK v6.3.1 release.

Co-authored-by: Client Engineering Bot <60980775+Client Engineering [email protected]>
  • Loading branch information
seba-aln and Client Engineering Bot authored Apr 28, 2022
1 parent e08fdd7 commit 6a3440d
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 9 deletions.
13 changes: 9 additions & 4 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: python
version: 6.3.0
version: 6.3.1
schema: 1
scm: github.com/pubnub/python
sdks:
Expand All @@ -18,7 +18,7 @@ sdks:
distributions:
- distribution-type: library
distribution-repository: package
package-name: pubnub-6.3.0
package-name: pubnub-6.3.1
location: https://pypi.org/project/pubnub/
supported-platforms:
supported-operating-systems:
Expand Down Expand Up @@ -97,8 +97,8 @@ sdks:
-
distribution-type: library
distribution-repository: git release
package-name: pubnub-6.3.0
location: https://github.com/pubnub/python/releases/download/v6.3.0/pubnub-6.3.0.tar.gz
package-name: pubnub-6.3.1
location: https://github.com/pubnub/python/releases/download/v6.3.1/pubnub-6.3.1.tar.gz
supported-platforms:
supported-operating-systems:
Linux:
Expand Down Expand Up @@ -169,6 +169,11 @@ sdks:
license-url: https://github.com/aio-libs/aiohttp/blob/master/LICENSE.txt
is-required: Required
changelog:
- date: 2022-04-27
version: v6.3.1
changes:
- type: bug
text: "This issue was mentioned in issue #118 and replaces PR #119 to match our PR policy."
- date: 2022-04-01
version: v6.3.0
changes:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v6.3.1
April 27 2022

#### Fixed
- This issue was mentioned in issue #118 and replaces PR #119 to match our PR policy. Fixed the following issues reported by [@tjazsilovsek](https://github.com/tjazsilovsek) and [@tjazsilovsek](https://github.com/tjazsilovsek): [#118](https://github.com/pubnub/python/issues/118) and [#119](https://github.com/pubnub/python/issues/119).

## v6.3.0
April 01 2022

Expand Down
4 changes: 2 additions & 2 deletions pubnub/endpoints/objects_v2/objects_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ def custom_params(self):

if self._page:
if isinstance(self._page, Next):
params["start"] = self._page.hash()
params["start"] = self._page.hash
elif isinstance(self._page, Previous):
params["end"] = self._page.hash()
params["end"] = self._page.hash
else:
raise ValueError()

Expand Down
2 changes: 1 addition & 1 deletion pubnub/pubnub_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

class PubNubCore:
"""A base class for PubNub Python API implementations"""
SDK_VERSION = "6.3.0"
SDK_VERSION = "6.3.1"
SDK_NAME = "PubNub-Python"

TIMESTAMP_DIVIDER = 1000
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='pubnub',
version='6.3.0',
version='6.3.1',
description='PubNub Real-time push service in the cloud',
author='PubNub',
author_email='[email protected]',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
interactions:
- request:
body: '{"set": [{"uuid": {"id": "test-fix-118-0"}}, {"uuid": {"id": "test-fix-118-1"}},
{"uuid": {"id": "test-fix-118-2"}}, {"uuid": {"id": "test-fix-118-3"}}, {"uuid":
{"id": "test-fix-118-4"}}, {"uuid": {"id": "test-fix-118-5"}}, {"uuid": {"id":
"test-fix-118-6"}}, {"uuid": {"id": "test-fix-118-7"}}, {"uuid": {"id": "test-fix-118-8"}},
{"uuid": {"id": "test-fix-118-9"}}, {"uuid": {"id": "test-fix-118-10"}}, {"uuid":
{"id": "test-fix-118-11"}}, {"uuid": {"id": "test-fix-118-12"}}, {"uuid": {"id":
"test-fix-118-13"}}, {"uuid": {"id": "test-fix-118-14"}}], "delete": []}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '568'
User-Agent:
- PubNub-Python/6.3.0
method: PATCH
uri: https://ps.pndsn.com/v2/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/channels/somechannelid/uuids
response:
body:
string: '{"status":200,"data":[{"uuid":{"id":"test-fix-118-0"},"updated":"2022-04-21T10:05:14.580127Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-1"},"updated":"2022-04-21T10:05:14.58336Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-10"},"updated":"2022-04-21T10:05:14.605349Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-11"},"updated":"2022-04-21T10:05:14.608585Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-12"},"updated":"2022-04-21T10:05:14.597527Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-13"},"updated":"2022-04-21T10:05:14.576398Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-14"},"updated":"2022-04-21T10:05:14.611731Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-2"},"updated":"2022-04-21T10:05:14.586304Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-3"},"updated":"2022-04-21T10:05:14.58986Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-4"},"updated":"2022-04-21T10:05:14.593492Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-5"},"updated":"2022-04-21T10:05:14.567831Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-6"},"updated":"2022-04-21T10:05:14.572508Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-7"},"updated":"2022-04-21T10:05:14.601774Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-8"},"updated":"2022-04-21T10:05:14.615379Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-9"},"updated":"2022-04-21T10:05:14.618906Z","eTag":"AY39mJKK//C0VA"}],"next":"MTU"}'
headers:
Access-Control-Allow-Credentials:
- 'true'
Access-Control-Allow-Origin:
- '*'
Connection:
- keep-alive
Content-Length:
- '1494'
Content-Type:
- application/json
Date:
- Thu, 21 Apr 2022 10:31:13 GMT
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- PubNub-Python/6.3.0
method: GET
uri: https://ps.pndsn.com/v2/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/channels/somechannelid/uuids?limit=10
response:
body:
string: '{"status":200,"data":[{"uuid":{"id":"test-fix-118-0"},"updated":"2022-04-21T10:05:14.580127Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-1"},"updated":"2022-04-21T10:05:14.58336Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-10"},"updated":"2022-04-21T10:05:14.605349Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-11"},"updated":"2022-04-21T10:05:14.608585Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-12"},"updated":"2022-04-21T10:05:14.597527Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-13"},"updated":"2022-04-21T10:05:14.576398Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-14"},"updated":"2022-04-21T10:05:14.611731Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-2"},"updated":"2022-04-21T10:05:14.586304Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-3"},"updated":"2022-04-21T10:05:14.58986Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-4"},"updated":"2022-04-21T10:05:14.593492Z","eTag":"AY39mJKK//C0VA"}],"next":"MTA"}'
headers:
Access-Control-Allow-Credentials:
- 'true'
Access-Control-Allow-Origin:
- '*'
Connection:
- keep-alive
Content-Length:
- '1009'
Content-Type:
- application/json
Date:
- Thu, 21 Apr 2022 10:31:13 GMT
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- PubNub-Python/6.3.0
method: GET
uri: https://ps.pndsn.com/v2/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/channels/somechannelid/uuids?limit=10&start=MTA
response:
body:
string: '{"status":200,"data":[{"uuid":{"id":"test-fix-118-5"},"updated":"2022-04-21T10:05:14.567831Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-6"},"updated":"2022-04-21T10:05:14.572508Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-7"},"updated":"2022-04-21T10:05:14.601774Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-8"},"updated":"2022-04-21T10:05:14.615379Z","eTag":"AY39mJKK//C0VA"},{"uuid":{"id":"test-fix-118-9"},"updated":"2022-04-21T10:05:14.618906Z","eTag":"AY39mJKK//C0VA"}],"next":"MTU","prev":"MTA"}'
headers:
Access-Control-Allow-Credentials:
- 'true'
Access-Control-Allow-Origin:
- '*'
Connection:
- keep-alive
Content-Length:
- '534'
Content-Type:
- application/json
Date:
- Thu, 21 Apr 2022 10:31:13 GMT
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from pubnub.endpoints.objects_v2.members.remove_channel_members import RemoveChannelMembers
from pubnub.endpoints.objects_v2.members.set_channel_members import SetChannelMembers
from pubnub.models.consumer.common import PNStatus
from pubnub.models.consumer.objects_v2.channel_members import PNUUID, PNSetChannelMembersResult, \
from pubnub.models.consumer.objects_v2.channel_members import PNUUID, JustUUID, PNSetChannelMembersResult, \
PNGetChannelMembersResult, PNRemoveChannelMembersResult, PNManageChannelMembersResult
from pubnub.models.consumer.objects_v2.page import PNPage
from pubnub.pubnub import PubNub
from pubnub.structures import Envelope
from tests.helper import pnconf_copy
Expand Down Expand Up @@ -131,6 +132,45 @@ def test_get_channel_members_happy_path(self):
assert len([e for e in data if e['uuid']['custom'] == custom_1]) != 0
assert len([e for e in data if e['custom'] == custom_2]) != 0

@pn_vcr.use_cassette(
'tests/integrational/fixtures/native_sync/objects_v2/channel_members/get_channel_members_with_pagination.yaml',
filter_query_parameters=['uuid', 'pnsdk'])
def test_get_channel_members_with_pagination(self):
pn = _pubnub()

pn.set_channel_members().channel(TestObjectsV2ChannelMembers._some_channel_id) \
.uuids([JustUUID(f'test-fix-118-{x}') for x in range(15)]) \
.sync()

get_channel_members_result_page_1 = pn.get_channel_members()\
.channel(TestObjectsV2ChannelMembers._some_channel_id)\
.limit(10) \
.sync()

assert isinstance(get_channel_members_result_page_1, Envelope)
assert isinstance(get_channel_members_result_page_1.result, PNGetChannelMembersResult)
assert isinstance(get_channel_members_result_page_1.status, PNStatus)
assert isinstance(get_channel_members_result_page_1.result.next, PNPage)

assert not get_channel_members_result_page_1.status.is_error()
data = get_channel_members_result_page_1.result.data
assert len(data) == 10

get_channel_members_result_page_2 = pn.get_channel_members() \
.channel(TestObjectsV2ChannelMembers._some_channel_id) \
.limit(10) \
.page(get_channel_members_result_page_1.result.next) \
.sync()

assert isinstance(get_channel_members_result_page_2, Envelope)
assert isinstance(get_channel_members_result_page_2.result, PNGetChannelMembersResult)
assert isinstance(get_channel_members_result_page_2.status, PNStatus)
assert isinstance(get_channel_members_result_page_2.result.next, PNPage)

assert not get_channel_members_result_page_2.status.is_error()
data = get_channel_members_result_page_2.result.data
assert len(data) == 5

def test_remove_channel_members_endpoint_available(self):
pn = _pubnub()
remove_channel_members = pn.remove_channel_members()
Expand Down

0 comments on commit 6a3440d

Please sign in to comment.