From f05e9680939faa4e1f3bc7618c72b690d31608b0 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sun, 14 Jul 2019 18:16:06 +0200 Subject: [PATCH 01/26] Implement GetUsers endpoint. --- pubnub/endpoints/users/get_users.py | 88 +++++++++++++++++++++++++++++ pubnub/enums.py | 1 + pubnub/managers.py | 1 + pubnub/models/consumer/user.py | 12 ++++ pubnub/pubnub_core.py | 4 ++ 5 files changed, 106 insertions(+) create mode 100644 pubnub/endpoints/users/get_users.py create mode 100644 pubnub/models/consumer/user.py diff --git a/pubnub/endpoints/users/get_users.py b/pubnub/endpoints/users/get_users.py new file mode 100644 index 00000000..c43536ef --- /dev/null +++ b/pubnub/endpoints/users/get_users.py @@ -0,0 +1,88 @@ +import six +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.user import PNGetUsersResult +from pubnub.enums import HttpMethod, PNOperationType + + +class GetUsers(Endpoint): + GET_USERS_PATH = '/v1/objects/%s/users' + MAX_LIMIT = 100 + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._start = None + self._end = None + self._limit = GetUsers.MAX_LIMIT + self._count = False + self._include = None + + def start(self, start): + assert isinstance(start, six.string_types) + self._start = start + return self + + def end(self, end): + assert isinstance(end, six.string_types) + self._end = end + return self + + def limit(self, limit): + assert isinstance(limit, six.integer_types) + self._limit = limit + return self + + def count(self, count): + self._count = bool(count) + return self + + def include(self, data): + self._include = data + return self + + def custom_params(self): + params = {} + + if self._start is not None: + params['start'] = self._start + + if self._end is not None and self._start is None: + params['end'] = self._end + + if self._count is True: + params['count'] = True + + if self._limit != GetUsers.MAX_LIMIT: + params['limit'] = self._limit + + if self._include: + params['include'] = utils.url_write(self._include) + + return params + + def build_path(self): + return GetUsers.GET_USERS_PATH % (self.pubnub.config.subscribe_key) + + def http_method(self): + return HttpMethod.GET + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + + def create_response(self, envelope): + return PNGetUsersResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNGetUsersOperation + + def name(self): + return "Get users" diff --git a/pubnub/enums.py b/pubnub/enums.py index 4ae04e40..551bc4e5 100644 --- a/pubnub/enums.py +++ b/pubnub/enums.py @@ -62,6 +62,7 @@ class PNOperationType(object): PNMessageCountOperation = 24 PNFireOperation = 25 PNSignalOperation = 26 + PNGetUsersOperation = 27 class PNHeartbeatNotificationOptions(object): diff --git a/pubnub/managers.py b/pubnub/managers.py index 060ab812..d3d9e401 100644 --- a/pubnub/managers.py +++ b/pubnub/managers.py @@ -451,6 +451,7 @@ def endpoint_name_for_operation(operation_type): PNOperationType.PNTimeOperation: 'pam', PNOperationType.PNSignalOperation: 'sig', + PNOperationType.PNGetUsersOperation: 'user', }[operation_type] return endpoint diff --git a/pubnub/models/consumer/user.py b/pubnub/models/consumer/user.py new file mode 100644 index 00000000..e38c4f8e --- /dev/null +++ b/pubnub/models/consumer/user.py @@ -0,0 +1,12 @@ +class PNGetUsersResult(object): + def __init__(self, result): + """ + Representation of get users server response + + :param result: result of signal operation + """ + self.data = result['data'] + self.status = result['status'] + + def __str__(self): + return "Get users success with data: %s" % self.data diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index 44982839..2f0f251d 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -25,6 +25,7 @@ from .endpoints.history_delete import HistoryDelete from .endpoints.message_count import MessageCount from .endpoints.signal import Signal +from .endpoints.users.get_users import GetUsers from .endpoints.push.add_channels_to_push import AddChannelsToPush from .endpoints.push.remove_channels_from_push import RemoveChannelsFromPush @@ -169,6 +170,9 @@ def fire(self): def signal(self): return Signal(self) + def get_users(self): + return GetUsers(self) + def time(self): return Time(self) From d6edc1f39dacea4fe931adea79fae40bf9c998ad Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sun, 14 Jul 2019 19:27:10 +0200 Subject: [PATCH 02/26] Add tests for GetUsers API endpoint. --- tests/functional/users/__init__.py | 0 tests/functional/users/test_get_users.py | 31 +++++++++++++ tests/integrational/asyncio/test_user.py | 27 ++++++++++++ .../fixtures/asyncio/user/users_get.yaml | 38 ++++++++++++++++ .../fixtures/native_sync/user/users_get.yaml | 40 +++++++++++++++++ .../fixtures/tornado/user/users_get.yaml | 44 +++++++++++++++++++ tests/integrational/native_sync/test_user.py | 26 +++++++++++ tests/integrational/tornado/test_user.py | 34 ++++++++++++++ 8 files changed, 240 insertions(+) create mode 100644 tests/functional/users/__init__.py create mode 100644 tests/functional/users/test_get_users.py create mode 100644 tests/integrational/asyncio/test_user.py create mode 100644 tests/integrational/fixtures/asyncio/user/users_get.yaml create mode 100644 tests/integrational/fixtures/native_sync/user/users_get.yaml create mode 100644 tests/integrational/fixtures/tornado/user/users_get.yaml create mode 100644 tests/integrational/native_sync/test_user.py create mode 100644 tests/integrational/tornado/test_user.py diff --git a/tests/functional/users/__init__.py b/tests/functional/users/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/functional/users/test_get_users.py b/tests/functional/users/test_get_users.py new file mode 100644 index 00000000..f7655bfe --- /dev/null +++ b/tests/functional/users/test_get_users.py @@ -0,0 +1,31 @@ +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.users.get_users import GetUsers + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_get_users(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + users = PubNub(config).get_users() + users.include(['a', 'b']).limit(30).end('XXX') + + assert users.build_path() == GetUsers.GET_USERS_PATH % SUB_KEY + + params = users.custom_params() + assert params['include'] == ['a', 'b'] + assert params['limit'] == 30 + assert params['end'] == 'XXX' + assert 'count' not in params + + users.start('YYY').count(True) + params = users.custom_params() + assert 'end' not in params + assert params['start'] == 'YYY' + assert params['count'] is True + + assert AUTH == users.build_params_callback()({})['auth'] diff --git a/tests/integrational/asyncio/test_user.py b/tests/integrational/asyncio/test_user.py new file mode 100644 index 00000000..b8552760 --- /dev/null +++ b/tests/integrational/asyncio/test_user.py @@ -0,0 +1,27 @@ +import pytest + +from tests.helper import pnconf_copy +from tests.integrational.vcr_helper import pn_vcr +from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope +from pubnub.models.consumer.user import PNGetUsersResult +from pubnub.models.consumer.common import PNStatus + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/user/users_get.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_get_users(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + envelope = yield from pn.get_users().include(['externalId', 'profileUrl', 'email', + 'custom', 'created', 'updated', 'eTag']).future() + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetUsersResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'custom', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'custom', 'created', 'updated', 'eTag']) == set(data[1]) diff --git a/tests/integrational/fixtures/asyncio/user/users_get.yaml b/tests/integrational/fixtures/asyncio/user/users_get.yaml new file mode 100644 index 00000000..10a14dd3 --- /dev/null +++ b/tests/integrational/fixtures/asyncio/user/users_get.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ + ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \ + \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n\ + \ \"created\": \"2019-02-19T13:10:20.893755\",\n \"custom\": {\n\ + \ \"phone\": \"999-999-9999\"\n },\n \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ + ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n \ + \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n ],\n\ + \ \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '738' + Content-Type: application/json + Date: Sun, 14 Jul 2019 17:15:25 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users + - include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=dd63672b-cec0-49e0-af1c-1b0e38204154 + - '' +version: 1 diff --git a/tests/integrational/fixtures/native_sync/user/users_get.yaml b/tests/integrational/fixtures/native_sync/user/users_get.yaml new file mode 100644 index 00000000..16fe1db4 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/user/users_get.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - PubNub-Python/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%27externalId%27%2C+%27profileUrl%27%2C+%27email%27%2C+%27custom%27%2C+%27created%27%2C+%27updated%27%2C+%27eTag%27%5D + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ + ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \ + \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n\ + \ \"created\": \"2019-02-19T13:10:20.893755\",\n \"custom\": {\n\ + \ \"phone\": \"999-999-9999\"\n },\n \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ + ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n \ + \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n ],\n\ + \ \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '738' + Content-Type: + - application/json + Date: + - Sun, 14 Jul 2019 17:09:32 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/tornado/user/users_get.yaml b/tests/integrational/fixtures/tornado/user/users_get.yaml new file mode 100644 index 00000000..25a29c9c --- /dev/null +++ b/tests/integrational/fixtures/tornado/user/users_get.yaml @@ -0,0 +1,44 @@ +interactions: +- request: + body: null + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ + ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \ + \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n\ + \ \"created\": \"2019-02-19T13:10:20.893755\",\n \"custom\": {\n\ + \ \"phone\": \"999-999-9999\"\n },\n \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ + ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n \ + \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n ],\n\ + \ \"status\": \"ok\"\n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Sun, 14 Jul 2019 17:22:20 GMT + - !!python/tuple + - Content-Length + - - '738' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=ea9a47a0-e983-43a9-88d5-ce85f275361f +version: 1 diff --git a/tests/integrational/native_sync/test_user.py b/tests/integrational/native_sync/test_user.py new file mode 100644 index 00000000..cc8e2cbd --- /dev/null +++ b/tests/integrational/native_sync/test_user.py @@ -0,0 +1,26 @@ +from tests.helper import pnconf_copy +from tests.integrational.vcr_helper import pn_vcr +from pubnub.structures import Envelope +from pubnub.pubnub import PubNub +from pubnub.models.consumer.user import PNGetUsersResult +from pubnub.models.consumer.common import PNStatus + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/user/users_get.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_get_users(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.get_users().include(['externalId', 'profileUrl', 'email', + 'custom', 'created', 'updated', 'eTag']).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetUsersResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'custom', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'custom', 'created', 'updated', 'eTag']) == set(data[1]) diff --git a/tests/integrational/tornado/test_user.py b/tests/integrational/tornado/test_user.py new file mode 100644 index 00000000..7f079565 --- /dev/null +++ b/tests/integrational/tornado/test_user.py @@ -0,0 +1,34 @@ +import tornado +from tornado.testing import AsyncTestCase + +from pubnub.pubnub_tornado import PubNubTornado, TornadoEnvelope +from pubnub.models.consumer.user import PNGetUsersResult +from pubnub.models.consumer.common import PNStatus +from tests.helper import pnconf_copy +from tests.integrational.vcr_helper import pn_vcr + + +class TestGetUsers(AsyncTestCase): + def setUp(self): + AsyncTestCase.setUp(self) + config = pnconf_copy() + self.pn = PubNubTornado(config, custom_ioloop=self.io_loop) + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/user/users_get.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_single_channel(self): + envelope = yield self.pn.get_users().include(['externalId', 'profileUrl', 'email', + 'custom', 'created', 'updated', 'eTag']).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetUsersResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'custom', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'custom', 'created', 'updated', 'eTag']) == set(data[1]) + self.pn.stop() From 1b787a951cede05775c907c05a91e4cda94b590b Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sun, 14 Jul 2019 22:46:14 +0200 Subject: [PATCH 03/26] Implement and test CreateUser API endpoint. --- pubnub/endpoints/users/create_user.py | 52 +++++++++++++++++++ pubnub/endpoints/users/get_users.py | 2 +- pubnub/enums.py | 1 + pubnub/managers.py | 1 + pubnub/models/consumer/user.py | 16 +++++- pubnub/pubnub_core.py | 4 ++ pubnub/pubnub_tornado.py | 5 +- tests/functional/users/test_create_user.py | 29 +++++++++++ tests/integrational/asyncio/test_user.py | 26 +++++++++- .../fixtures/asyncio/user/create_user.yaml | 33 ++++++++++++ .../native_sync/user/create_user.yaml | 37 +++++++++++++ .../fixtures/tornado/user/create_user.yaml | 19 +++++++ tests/integrational/native_sync/test_user.py | 24 ++++++++- tests/integrational/tornado/test_user.py | 24 ++++++++- 14 files changed, 265 insertions(+), 8 deletions(-) create mode 100644 pubnub/endpoints/users/create_user.py create mode 100644 tests/functional/users/test_create_user.py create mode 100644 tests/integrational/fixtures/asyncio/user/create_user.yaml create mode 100644 tests/integrational/fixtures/native_sync/user/create_user.yaml create mode 100644 tests/integrational/fixtures/tornado/user/create_user.yaml diff --git a/pubnub/endpoints/users/create_user.py b/pubnub/endpoints/users/create_user.py new file mode 100644 index 00000000..d49ef424 --- /dev/null +++ b/pubnub/endpoints/users/create_user.py @@ -0,0 +1,52 @@ +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.user import PNCreateUserResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class CreateUser(Endpoint): + CREATE_USER_PATH = '/v1/objects/%s/users' + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._include = {} + + def include(self, data): + assert isinstance(data, dict) + self._include = data + return self + + def custom_params(self): + params = {} + params['include'] = utils.url_write(self._include) + return params + + def validate_params(self): + self.validate_subscribe_key() + if 'id' not in self._include or 'name' not in self._include: + raise PubNubException('"id" or "name" not found in include data.') + + def build_path(self): + return CreateUser.CREATE_USER_PATH % (self.pubnub.config.subscribe_key) + + def http_method(self): + return HttpMethod.POST + + def is_auth_required(self): + return True + + def create_response(self, envelope): + return PNCreateUserResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNCreateUserOperation + + def name(self): + return 'Create user' diff --git a/pubnub/endpoints/users/get_users.py b/pubnub/endpoints/users/get_users.py index c43536ef..5d2e2360 100644 --- a/pubnub/endpoints/users/get_users.py +++ b/pubnub/endpoints/users/get_users.py @@ -85,4 +85,4 @@ def operation_type(self): return PNOperationType.PNGetUsersOperation def name(self): - return "Get users" + return 'Get users' diff --git a/pubnub/enums.py b/pubnub/enums.py index 551bc4e5..c1883c5e 100644 --- a/pubnub/enums.py +++ b/pubnub/enums.py @@ -63,6 +63,7 @@ class PNOperationType(object): PNFireOperation = 25 PNSignalOperation = 26 PNGetUsersOperation = 27 + PNCreateUserOperation = 28 class PNHeartbeatNotificationOptions(object): diff --git a/pubnub/managers.py b/pubnub/managers.py index d3d9e401..5165dab3 100644 --- a/pubnub/managers.py +++ b/pubnub/managers.py @@ -452,6 +452,7 @@ def endpoint_name_for_operation(operation_type): PNOperationType.PNTimeOperation: 'pam', PNOperationType.PNSignalOperation: 'sig', PNOperationType.PNGetUsersOperation: 'user', + PNOperationType.PNCreateUserOperation: 'user', }[operation_type] return endpoint diff --git a/pubnub/models/consumer/user.py b/pubnub/models/consumer/user.py index e38c4f8e..565a10fb 100644 --- a/pubnub/models/consumer/user.py +++ b/pubnub/models/consumer/user.py @@ -3,10 +3,24 @@ def __init__(self, result): """ Representation of get users server response - :param result: result of signal operation + :param result: result of get users operation """ self.data = result['data'] self.status = result['status'] def __str__(self): return "Get users success with data: %s" % self.data + + +class PNCreateUserResult(object): + def __init__(self, result): + """ + Representation of create user server response + + :param result: result of create user operation + """ + self.data = result['data'] + self.status = result['status'] + + def __str__(self): + return "User created with data: %s" % self.data diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index 2f0f251d..f9ed91aa 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -26,6 +26,7 @@ from .endpoints.message_count import MessageCount from .endpoints.signal import Signal from .endpoints.users.get_users import GetUsers +from .endpoints.users.create_user import CreateUser from .endpoints.push.add_channels_to_push import AddChannelsToPush from .endpoints.push.remove_channels_from_push import RemoveChannelsFromPush @@ -173,6 +174,9 @@ def signal(self): def get_users(self): return GetUsers(self) + def create_user(self): + return CreateUser(self) + def time(self): return Time(self) diff --git a/pubnub/pubnub_tornado.py b/pubnub/pubnub_tornado.py index f30ff537..7be1ea3a 100644 --- a/pubnub/pubnub_tornado.py +++ b/pubnub/pubnub_tornado.py @@ -158,7 +158,6 @@ def response_callback(response): body = response.body response_info = None status_category = PNStatusCategory.PNUnknownCategory - if response is not None: request_url = six.moves.urllib.parse.urlparse(response.effective_url) query = six.moves.urllib.parse.parse_qs(request_url.query) @@ -639,7 +638,7 @@ def wait_for_disconnect(self): def wait_for_message_on(self, *channel_names): channel_names = list(channel_names) while True: - try: # NOQA + try: # NOQA env = yield self._wait_for(self.message_queue.get()) if env.channel in channel_names: raise tornado.gen.Return(env) @@ -655,7 +654,7 @@ def wait_for_presence_on(self, *channel_names): try: try: env = yield self._wait_for(self.presence_queue.get()) - except: # NOQA E722 pylint: disable=W0702 + except: # NOQA E722 pylint: disable=W0702 break if env.channel in channel_names: raise tornado.gen.Return(env) diff --git a/tests/functional/users/test_create_user.py b/tests/functional/users/test_create_user.py new file mode 100644 index 00000000..f0de4f0a --- /dev/null +++ b/tests/functional/users/test_create_user.py @@ -0,0 +1,29 @@ +import pytest +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.users.create_user import CreateUser +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_get_users(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + user = PubNub(config).create_user() + with pytest.raises(PubNubException): + user.validate_params() + user.include({'name': 'a'}) + with pytest.raises(PubNubException): + user.validate_params() + user.include({'id': 'x'}) + with pytest.raises(PubNubException): + user.validate_params() + user.include({'id': 'x', 'name': 'a'}) + user.validate_params() + + assert user.build_path() == CreateUser.CREATE_USER_PATH % SUB_KEY + assert AUTH == user.build_params_callback()({})['auth'] diff --git a/tests/integrational/asyncio/test_user.py b/tests/integrational/asyncio/test_user.py index b8552760..235eb572 100644 --- a/tests/integrational/asyncio/test_user.py +++ b/tests/integrational/asyncio/test_user.py @@ -3,7 +3,7 @@ from tests.helper import pnconf_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope -from pubnub.models.consumer.user import PNGetUsersResult +from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult from pubnub.models.consumer.common import PNStatus @@ -25,3 +25,27 @@ def test_get_users(event_loop): 'custom', 'created', 'updated', 'eTag']) == set(data[0]) assert set(['name', 'id', 'externalId', 'profileUrl', 'email', 'custom', 'created', 'updated', 'eTag']) == set(data[1]) + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/user/create_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_create_user(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config) + data = {'id': 'user-1', 'name': 'John Doe', + 'externalId': None, 'profileUrl': None, 'email': 'jack@twitter.com'} + envelope = yield from pn.create_user().include(data).future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNCreateUserResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert data['id'] == 'user-1' + assert data['name'] == 'John Doe' + assert data['externalId'] is None + assert data['profileUrl'] is None + assert data['email'] == 'jack@twitter.com' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' diff --git a/tests/integrational/fixtures/asyncio/user/create_user.yaml b/tests/integrational/fixtures/asyncio/user/create_user.yaml new file mode 100644 index 00000000..fb777064 --- /dev/null +++ b/tests/integrational/fixtures/asyncio/user/create_user.yaml @@ -0,0 +1,33 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: POST + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%7B%22id%22%3A+%22user-1%22%2C+%22name%22%3A+%22John+Doe%22%2C+%22externalId%22%3A+null%2C+%22profileUrl%22%3A+null%2C+%22email%22%3A+%22jack%40twitter.com%22%7D + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ + \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ + : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ + \n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '319' + Content-Type: application/json + Date: Sun, 14 Jul 2019 20:29:48 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users + - include=%7B%22id%22%3A%20%22user-1%22%2C%20%22name%22%3A%20%22John%20Doe%22%2C%20%22externalId%22%3A%20null%2C%20%22profileUrl%22%3A%20null%2C%20%22email%22%3A%20%22jack%40twitter.com%22%7D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=6217bb6b-01b1-466a-a3ff-61625f616999 + - '' +version: 1 diff --git a/tests/integrational/fixtures/native_sync/user/create_user.yaml b/tests/integrational/fixtures/native_sync/user/create_user.yaml new file mode 100644 index 00000000..d3af9a85 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/user/create_user.yaml @@ -0,0 +1,37 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - PubNub-Python/4.1.0 + method: POST + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%7B%22id%22%3A+%22user-1%22%2C+%22name%22%3A+%22John+Doe%22%2C+%22externalId%22%3A+null%2C+%22profileUrl%22%3A+null%2C+%22email%22%3A+%22jack%40twitter.com%22%7D + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ + \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ + : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ + \n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '319' + Content-Type: + - application/json + Date: + - Sun, 14 Jul 2019 20:25:20 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/tornado/user/create_user.yaml b/tests/integrational/fixtures/tornado/user/create_user.yaml new file mode 100644 index 00000000..373363db --- /dev/null +++ b/tests/integrational/fixtures/tornado/user/create_user.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: null + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: POST + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%7B%22id%22%3A+%22user-1%22%2C+%22name%22%3A+%22John+Doe%22%2C+%22externalId%22%3A+null%2C+%22profileUrl%22%3A+null%2C+%22email%22%3A+%22jack%40twitter.com%22%7D + response: + body: + string: null + headers: [] + status: + code: 599 + message: Unknown + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%7B%22id%22%3A%20%22user-1%22%2C%20%22name%22%3A%20%22John%20Doe%22%2C%20%22externalId%22%3A%20null%2C%20%22profileUrl%22%3A%20null%2C%20%22email%22%3A%20%22jack%40twitter.com%22%7D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=be69abb5-71e0-4427-a101-00fb84130dd2 +version: 1 diff --git a/tests/integrational/native_sync/test_user.py b/tests/integrational/native_sync/test_user.py index cc8e2cbd..bd9fdf89 100644 --- a/tests/integrational/native_sync/test_user.py +++ b/tests/integrational/native_sync/test_user.py @@ -2,7 +2,7 @@ from tests.integrational.vcr_helper import pn_vcr from pubnub.structures import Envelope from pubnub.pubnub import PubNub -from pubnub.models.consumer.user import PNGetUsersResult +from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult from pubnub.models.consumer.common import PNStatus @@ -24,3 +24,25 @@ def test_get_users(): 'custom', 'created', 'updated', 'eTag']) == set(data[0]) assert set(['name', 'id', 'externalId', 'profileUrl', 'email', 'custom', 'created', 'updated', 'eTag']) == set(data[1]) + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/user/create_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_create_user(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.create_user().include({'id': 'user-1', 'name': 'John Doe', + 'externalId': None, 'profileUrl': None, 'email': 'jack@twitter.com'}).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNCreateUserResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert data['id'] == 'user-1' + assert data['name'] == 'John Doe' + assert data['externalId'] is None + assert data['profileUrl'] is None + assert data['email'] == 'jack@twitter.com' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' diff --git a/tests/integrational/tornado/test_user.py b/tests/integrational/tornado/test_user.py index 7f079565..b60edce6 100644 --- a/tests/integrational/tornado/test_user.py +++ b/tests/integrational/tornado/test_user.py @@ -2,7 +2,7 @@ from tornado.testing import AsyncTestCase from pubnub.pubnub_tornado import PubNubTornado, TornadoEnvelope -from pubnub.models.consumer.user import PNGetUsersResult +from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult from pubnub.models.consumer.common import PNStatus from tests.helper import pnconf_copy from tests.integrational.vcr_helper import pn_vcr @@ -32,3 +32,25 @@ def test_single_channel(self): assert set(['name', 'id', 'externalId', 'profileUrl', 'email', 'custom', 'created', 'updated', 'eTag']) == set(data[1]) self.pn.stop() + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/user/create_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_create_user(self): + data = {'id': 'user-1', 'name': 'John Doe', + 'externalId': None, 'profileUrl': None, 'email': 'jack@twitter.com'} + envelope = yield self.pn.create_user().include(data).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNCreateUserResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert data['id'] == 'user-1' + assert data['name'] == 'John Doe' + assert data['externalId'] is None + assert data['profileUrl'] is None + assert data['email'] == 'jack@twitter.com' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' + self.pn.stop() From 60f3c9cb06841b65c88754daeddc0856400066d9 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sun, 14 Jul 2019 22:53:26 +0200 Subject: [PATCH 04/26] Declare users as package, disable pylint errors. --- pubnub/endpoints/users/__init__.py | 0 pubnub/endpoints/users/create_user.py | 2 +- pubnub/endpoints/users/get_users.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 pubnub/endpoints/users/__init__.py diff --git a/pubnub/endpoints/users/__init__.py b/pubnub/endpoints/users/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pubnub/endpoints/users/create_user.py b/pubnub/endpoints/users/create_user.py index d49ef424..1a4fbeab 100644 --- a/pubnub/endpoints/users/create_user.py +++ b/pubnub/endpoints/users/create_user.py @@ -36,7 +36,7 @@ def http_method(self): def is_auth_required(self): return True - def create_response(self, envelope): + def create_response(self, envelope): # pylint: disable=W0221 return PNCreateUserResult(envelope) def request_timeout(self): diff --git a/pubnub/endpoints/users/get_users.py b/pubnub/endpoints/users/get_users.py index 5d2e2360..08074b24 100644 --- a/pubnub/endpoints/users/get_users.py +++ b/pubnub/endpoints/users/get_users.py @@ -72,7 +72,7 @@ def is_auth_required(self): def validate_params(self): self.validate_subscribe_key() - def create_response(self, envelope): + def create_response(self, envelope): # pylint: disable=W0221 return PNGetUsersResult(envelope) def request_timeout(self): From 0a527c14d5cc5b1ff53f041a568f498ddb512ffd Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sun, 14 Jul 2019 23:32:25 +0200 Subject: [PATCH 05/26] Update the cassettes. Fix endpoint issues. --- pubnub/endpoints/users/create_user.py | 7 ++-- tests/functional/users/test_get_users.py | 2 +- .../fixtures/asyncio/user/create_user.yaml | 9 ++--- .../fixtures/asyncio/user/users_get.yaml | 4 +-- .../native_sync/user/create_user.yaml | 9 ++--- .../fixtures/native_sync/user/users_get.yaml | 4 +-- .../fixtures/tornado/user/create_user.yaml | 35 +++++++++++++++---- .../fixtures/tornado/user/users_get.yaml | 4 +-- 8 files changed, 49 insertions(+), 25 deletions(-) diff --git a/pubnub/endpoints/users/create_user.py b/pubnub/endpoints/users/create_user.py index 1a4fbeab..6abe16c0 100644 --- a/pubnub/endpoints/users/create_user.py +++ b/pubnub/endpoints/users/create_user.py @@ -18,9 +18,10 @@ def include(self, data): return self def custom_params(self): - params = {} - params['include'] = utils.url_write(self._include) - return params + return {} + + def build_data(self): + return utils.write_value_as_string(self._include) def validate_params(self): self.validate_subscribe_key() diff --git a/tests/functional/users/test_get_users.py b/tests/functional/users/test_get_users.py index f7655bfe..22bb393c 100644 --- a/tests/functional/users/test_get_users.py +++ b/tests/functional/users/test_get_users.py @@ -17,7 +17,7 @@ def test_get_users(): assert users.build_path() == GetUsers.GET_USERS_PATH % SUB_KEY params = users.custom_params() - assert params['include'] == ['a', 'b'] + assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' assert params['limit'] == 30 assert params['end'] == 'XXX' assert 'count' not in params diff --git a/tests/integrational/fixtures/asyncio/user/create_user.yaml b/tests/integrational/fixtures/asyncio/user/create_user.yaml index fb777064..a57f19d1 100644 --- a/tests/integrational/fixtures/asyncio/user/create_user.yaml +++ b/tests/integrational/fixtures/asyncio/user/create_user.yaml @@ -1,11 +1,12 @@ interactions: - request: - body: null + body: '{"id": "user-1", "name": "John Doe", "externalId": null, "profileUrl": + null, "email": "jack@twitter.com"}' headers: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: POST - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%7B%22id%22%3A+%22user-1%22%2C+%22name%22%3A+%22John+Doe%22%2C+%22externalId%22%3A+null%2C+%22profileUrl%22%3A+null%2C+%22email%22%3A+%22jack%40twitter.com%22%7D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users response: body: string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ @@ -18,7 +19,7 @@ interactions: Access-Control-Allow-Origin: '*' Content-Length: '319' Content-Type: application/json - Date: Sun, 14 Jul 2019 20:29:48 GMT + Date: Sun, 14 Jul 2019 21:56:58 GMT status: code: 200 message: OK @@ -28,6 +29,6 @@ interactions: - http - ps.pndsn.com - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users - - include=%7B%22id%22%3A%20%22user-1%22%2C%20%22name%22%3A%20%22John%20Doe%22%2C%20%22externalId%22%3A%20null%2C%20%22profileUrl%22%3A%20null%2C%20%22email%22%3A%20%22jack%40twitter.com%22%7D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=6217bb6b-01b1-466a-a3ff-61625f616999 + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=4a32bdb1-122d-4c1d-902b-2ee854c3b151 - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/user/users_get.yaml b/tests/integrational/fixtures/asyncio/user/users_get.yaml index 10a14dd3..2ee58c38 100644 --- a/tests/integrational/fixtures/asyncio/user/users_get.yaml +++ b/tests/integrational/fixtures/asyncio/user/users_get.yaml @@ -23,7 +23,7 @@ interactions: Access-Control-Allow-Origin: '*' Content-Length: '738' Content-Type: application/json - Date: Sun, 14 Jul 2019 17:15:25 GMT + Date: Sun, 14 Jul 2019 21:31:55 GMT status: code: 200 message: OK @@ -33,6 +33,6 @@ interactions: - http - ps.pndsn.com - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users - - include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=dd63672b-cec0-49e0-af1c-1b0e38204154 + - include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=ce392d26-151b-4eac-8143-c7e8b9c5cdf9 - '' version: 1 diff --git a/tests/integrational/fixtures/native_sync/user/create_user.yaml b/tests/integrational/fixtures/native_sync/user/create_user.yaml index d3af9a85..c934edcb 100644 --- a/tests/integrational/fixtures/native_sync/user/create_user.yaml +++ b/tests/integrational/fixtures/native_sync/user/create_user.yaml @@ -1,6 +1,7 @@ interactions: - request: - body: null + body: '{"id": "user-1", "name": "John Doe", "externalId": null, "profileUrl": + null, "email": "jack@twitter.com"}' headers: Accept: - '*/*' @@ -9,11 +10,11 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '105' User-Agent: - PubNub-Python/4.1.0 method: POST - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%7B%22id%22%3A+%22user-1%22%2C+%22name%22%3A+%22John+Doe%22%2C+%22externalId%22%3A+null%2C+%22profileUrl%22%3A+null%2C+%22email%22%3A+%22jack%40twitter.com%22%7D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users response: body: string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ @@ -30,7 +31,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 14 Jul 2019 20:25:20 GMT + - Sun, 14 Jul 2019 21:57:11 GMT status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/user/users_get.yaml b/tests/integrational/fixtures/native_sync/user/users_get.yaml index 16fe1db4..636813a4 100644 --- a/tests/integrational/fixtures/native_sync/user/users_get.yaml +++ b/tests/integrational/fixtures/native_sync/user/users_get.yaml @@ -11,7 +11,7 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%27externalId%27%2C+%27profileUrl%27%2C+%27email%27%2C+%27custom%27%2C+%27created%27%2C+%27updated%27%2C+%27eTag%27%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D response: body: string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ @@ -33,7 +33,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 14 Jul 2019 17:09:32 GMT + - Sun, 14 Jul 2019 21:31:42 GMT status: code: 200 message: OK diff --git a/tests/integrational/fixtures/tornado/user/create_user.yaml b/tests/integrational/fixtures/tornado/user/create_user.yaml index 373363db..dbe56ff9 100644 --- a/tests/integrational/fixtures/tornado/user/create_user.yaml +++ b/tests/integrational/fixtures/tornado/user/create_user.yaml @@ -1,19 +1,40 @@ interactions: - request: - body: null + body: '{"id": "user-1", "name": "John Doe", "externalId": null, "profileUrl": + null, "email": "jack@twitter.com"}' headers: Accept-Encoding: - utf-8 User-Agent: - PubNub-Python-Tornado/4.1.0 method: POST - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%7B%22id%22%3A+%22user-1%22%2C+%22name%22%3A+%22John+Doe%22%2C+%22externalId%22%3A+null%2C+%22profileUrl%22%3A+null%2C+%22email%22%3A+%22jack%40twitter.com%22%7D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users response: body: - string: null - headers: [] + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ + \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ + : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ + \n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Sun, 14 Jul 2019 21:53:18 GMT + - !!python/tuple + - Content-Length + - - '319' + - !!python/tuple + - Connection + - - close status: - code: 599 - message: Unknown - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%7B%22id%22%3A%20%22user-1%22%2C%20%22name%22%3A%20%22John%20Doe%22%2C%20%22externalId%22%3A%20null%2C%20%22profileUrl%22%3A%20null%2C%20%22email%22%3A%20%22jack%40twitter.com%22%7D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=be69abb5-71e0-4427-a101-00fb84130dd2 + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=180dbd47-34a5-4a71-afc8-a8a3097e0eba version: 1 diff --git a/tests/integrational/fixtures/tornado/user/users_get.yaml b/tests/integrational/fixtures/tornado/user/users_get.yaml index 25a29c9c..eceb4c67 100644 --- a/tests/integrational/fixtures/tornado/user/users_get.yaml +++ b/tests/integrational/fixtures/tornado/user/users_get.yaml @@ -30,7 +30,7 @@ interactions: - - application/json - !!python/tuple - Date - - - Sun, 14 Jul 2019 17:22:20 GMT + - - Sun, 14 Jul 2019 21:36:27 GMT - !!python/tuple - Content-Length - - '738' @@ -40,5 +40,5 @@ interactions: status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=ea9a47a0-e983-43a9-88d5-ce85f275361f + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=861dcf10-ec38-4a3f-826a-7c2114fd4d6a version: 1 From 860468e3d044c232a4a5412c2316696bbf5617f9 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Mon, 15 Jul 2019 22:45:33 +0200 Subject: [PATCH 06/26] Implement and test FetchUser API. --- pubnub/endpoints/users/fetch_user.py | 60 +++++++++++++++++++ pubnub/enums.py | 1 + pubnub/managers.py | 1 + pubnub/models/consumer/user.py | 14 +++++ pubnub/pubnub_core.py | 4 ++ tests/functional/users/test_fetch_user.py | 27 +++++++++ tests/integrational/asyncio/test_user.py | 23 ++++++- .../fixtures/asyncio/user/fetch_user.yaml | 33 ++++++++++ .../fixtures/native_sync/user/fetch_user.yaml | 35 +++++++++++ .../fixtures/tornado/user/fetch_user.yaml | 39 ++++++++++++ tests/integrational/native_sync/test_user.py | 20 ++++++- tests/integrational/tornado/test_user.py | 19 +++++- 12 files changed, 272 insertions(+), 4 deletions(-) create mode 100644 pubnub/endpoints/users/fetch_user.py create mode 100644 tests/functional/users/test_fetch_user.py create mode 100644 tests/integrational/fixtures/asyncio/user/fetch_user.yaml create mode 100644 tests/integrational/fixtures/native_sync/user/fetch_user.yaml create mode 100644 tests/integrational/fixtures/tornado/user/fetch_user.yaml diff --git a/pubnub/endpoints/users/fetch_user.py b/pubnub/endpoints/users/fetch_user.py new file mode 100644 index 00000000..a38000d4 --- /dev/null +++ b/pubnub/endpoints/users/fetch_user.py @@ -0,0 +1,60 @@ +import six + +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.user import PNFetchUserResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class FetchUser(Endpoint): + FETCH_USER_PATH = '/v1/objects/%s/users/%s' + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._user_id = None + self._include = None + + def user_id(self, user_id): + assert isinstance(user_id, six.string_types) + self._user_id = user_id + return self + + def include(self, data): + self._include = data + return self + + def custom_params(self): + params = {} + if self._include: + params['include'] = utils.url_write(self._include) + return params + + def build_path(self): + if self._user_id is None: + raise PubNubException('Provide user_id.') + return FetchUser.FETCH_USER_PATH % (self.pubnub.config.subscribe_key, self._user_id) + + def http_method(self): + return HttpMethod.GET + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + + def create_response(self, envelope): # pylint: disable=W0221 + return PNFetchUserResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNFetchUserOperation + + def name(self): + return 'Fetch user' diff --git a/pubnub/enums.py b/pubnub/enums.py index c1883c5e..cade070b 100644 --- a/pubnub/enums.py +++ b/pubnub/enums.py @@ -64,6 +64,7 @@ class PNOperationType(object): PNSignalOperation = 26 PNGetUsersOperation = 27 PNCreateUserOperation = 28 + PNFetchUserOperation = 29 class PNHeartbeatNotificationOptions(object): diff --git a/pubnub/managers.py b/pubnub/managers.py index 5165dab3..4879fb94 100644 --- a/pubnub/managers.py +++ b/pubnub/managers.py @@ -453,6 +453,7 @@ def endpoint_name_for_operation(operation_type): PNOperationType.PNSignalOperation: 'sig', PNOperationType.PNGetUsersOperation: 'user', PNOperationType.PNCreateUserOperation: 'user', + PNOperationType.PNFetchUserOperation: 'user', }[operation_type] return endpoint diff --git a/pubnub/models/consumer/user.py b/pubnub/models/consumer/user.py index 565a10fb..a2b440d6 100644 --- a/pubnub/models/consumer/user.py +++ b/pubnub/models/consumer/user.py @@ -24,3 +24,17 @@ def __init__(self, result): def __str__(self): return "User created with data: %s" % self.data + + +class PNFetchUserResult(object): + def __init__(self, result): + """ + Representation of fetch user server response + + :param result: result of fetch user operation + """ + self.data = result['data'] + self.status = result['status'] + + def __str__(self): + return "Fetch user success with data: %s" % self.data diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index f9ed91aa..c0802510 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -27,6 +27,7 @@ from .endpoints.signal import Signal from .endpoints.users.get_users import GetUsers from .endpoints.users.create_user import CreateUser +from .endpoints.users.fetch_user import FetchUser from .endpoints.push.add_channels_to_push import AddChannelsToPush from .endpoints.push.remove_channels_from_push import RemoveChannelsFromPush @@ -177,6 +178,9 @@ def get_users(self): def create_user(self): return CreateUser(self) + def fetch_user(self): + return FetchUser(self) + def time(self): return Time(self) diff --git a/tests/functional/users/test_fetch_user.py b/tests/functional/users/test_fetch_user.py new file mode 100644 index 00000000..3e01f0e6 --- /dev/null +++ b/tests/functional/users/test_fetch_user.py @@ -0,0 +1,27 @@ +import pytest + +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.users.fetch_user import FetchUser +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_fetch_user(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + user = PubNub(config).fetch_user() + user.include(['a', 'b']) + with pytest.raises(PubNubException): + user.build_path() + + user.user_id('foo') + assert user.build_path() == FetchUser.FETCH_USER_PATH % (SUB_KEY, 'foo') + + params = user.custom_params() + assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' + assert AUTH == user.build_params_callback()({})['auth'] diff --git a/tests/integrational/asyncio/test_user.py b/tests/integrational/asyncio/test_user.py index 235eb572..dc66b1e7 100644 --- a/tests/integrational/asyncio/test_user.py +++ b/tests/integrational/asyncio/test_user.py @@ -3,7 +3,7 @@ from tests.helper import pnconf_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope -from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult +from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult, PNFetchUserResult from pubnub.models.consumer.common import PNStatus @@ -32,7 +32,7 @@ def test_get_users(event_loop): @pytest.mark.asyncio def test_create_user(event_loop): config = pnconf_copy() - pn = PubNubAsyncio(config) + pn = PubNubAsyncio(config, custom_event_loop=event_loop) data = {'id': 'user-1', 'name': 'John Doe', 'externalId': None, 'profileUrl': None, 'email': 'jack@twitter.com'} envelope = yield from pn.create_user().include(data).future() @@ -49,3 +49,22 @@ def test_create_user(event_loop): assert data['email'] == 'jack@twitter.com' assert data['created'] == '2019-02-20T23:11:20.893755' assert data['updated'] == '2019-02-20T23:11:20.893755' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/user/fetch_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_fetch_user(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + envelope = yield from pn.fetch_user().user_id('user-1').include(['externalId', 'profileUrl', 'email', + 'created', 'updated', 'eTag']).future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNFetchUserResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'user-1' diff --git a/tests/integrational/fixtures/asyncio/user/fetch_user.yaml b/tests/integrational/fixtures/asyncio/user/fetch_user.yaml new file mode 100644 index 00000000..9b7952c0 --- /dev/null +++ b/tests/integrational/fixtures/asyncio/user/fetch_user.yaml @@ -0,0 +1,33 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ + \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ + : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ + \n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '319' + Content-Type: application/json + Date: Mon, 15 Jul 2019 20:37:59 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + - include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=a9542de8-67ab-4ac6-8747-a05acbf247dd + - '' +version: 1 diff --git a/tests/integrational/fixtures/native_sync/user/fetch_user.yaml b/tests/integrational/fixtures/native_sync/user/fetch_user.yaml new file mode 100644 index 00000000..a8ecc156 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/user/fetch_user.yaml @@ -0,0 +1,35 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - PubNub-Python/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ + \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ + : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ + \n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '319' + Content-Type: + - application/json + Date: + - Mon, 15 Jul 2019 20:35:53 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/tornado/user/fetch_user.yaml b/tests/integrational/fixtures/tornado/user/fetch_user.yaml new file mode 100644 index 00000000..bc051c4e --- /dev/null +++ b/tests/integrational/fixtures/tornado/user/fetch_user.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: null + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ + \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ + : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ + \n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Mon, 15 Jul 2019 20:41:54 GMT + - !!python/tuple + - Content-Length + - - '319' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=f0717bf9-f478-4a9f-be66-068aa23084ce +version: 1 diff --git a/tests/integrational/native_sync/test_user.py b/tests/integrational/native_sync/test_user.py index bd9fdf89..8d574f4a 100644 --- a/tests/integrational/native_sync/test_user.py +++ b/tests/integrational/native_sync/test_user.py @@ -2,7 +2,7 @@ from tests.integrational.vcr_helper import pn_vcr from pubnub.structures import Envelope from pubnub.pubnub import PubNub -from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult +from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult, PNFetchUserResult from pubnub.models.consumer.common import PNStatus @@ -46,3 +46,21 @@ def test_create_user(): assert data['email'] == 'jack@twitter.com' assert data['created'] == '2019-02-20T23:11:20.893755' assert data['updated'] == '2019-02-20T23:11:20.893755' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/user/fetch_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_fetch_user(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.fetch_user().user_id('user-1').include(['externalId', 'profileUrl', 'email', + 'created', 'updated', 'eTag']).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNFetchUserResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'user-1' diff --git a/tests/integrational/tornado/test_user.py b/tests/integrational/tornado/test_user.py index b60edce6..dbf175fe 100644 --- a/tests/integrational/tornado/test_user.py +++ b/tests/integrational/tornado/test_user.py @@ -2,7 +2,7 @@ from tornado.testing import AsyncTestCase from pubnub.pubnub_tornado import PubNubTornado, TornadoEnvelope -from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult +from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult, PNFetchUserResult from pubnub.models.consumer.common import PNStatus from tests.helper import pnconf_copy from tests.integrational.vcr_helper import pn_vcr @@ -54,3 +54,20 @@ def test_create_user(self): assert data['created'] == '2019-02-20T23:11:20.893755' assert data['updated'] == '2019-02-20T23:11:20.893755' self.pn.stop() + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/user/fetch_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_fetch_user(self): + envelope = yield self.pn.fetch_user().user_id('user-1').include(['externalId', 'profileUrl', 'email', + 'created', 'updated', 'eTag']).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNFetchUserResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'user-1' + self.pn.stop() From 8e617df039c7226ce4e4a109f24b912d4eaf3db0 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Tue, 16 Jul 2019 19:29:37 +0200 Subject: [PATCH 07/26] Implement and test UpdateUser endpoint. --- pubnub/endpoints/users/update_user.py | 63 +++++++++++++++++++ pubnub/enums.py | 4 ++ pubnub/managers.py | 1 + pubnub/models/consumer/user.py | 14 +++++ pubnub/pubnub_core.py | 4 ++ pubnub/structures.py | 3 +- tests/functional/users/test_update_user.py | 25 ++++++++ tests/integrational/asyncio/test_user.py | 24 ++++++- .../fixtures/asyncio/user/update_user.yaml | 34 ++++++++++ .../native_sync/user/update_user.yaml | 37 +++++++++++ .../fixtures/tornado/user/update_user.yaml | 40 ++++++++++++ tests/integrational/native_sync/test_user.py | 23 ++++++- tests/integrational/tornado/test_user.py | 22 ++++++- 13 files changed, 290 insertions(+), 4 deletions(-) create mode 100644 pubnub/endpoints/users/update_user.py create mode 100644 tests/functional/users/test_update_user.py create mode 100644 tests/integrational/fixtures/asyncio/user/update_user.yaml create mode 100644 tests/integrational/fixtures/native_sync/user/update_user.yaml create mode 100644 tests/integrational/fixtures/tornado/user/update_user.yaml diff --git a/pubnub/endpoints/users/update_user.py b/pubnub/endpoints/users/update_user.py new file mode 100644 index 00000000..68a88bcc --- /dev/null +++ b/pubnub/endpoints/users/update_user.py @@ -0,0 +1,63 @@ +import six + +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.user import PNUpdateUserResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class UpdateUser(Endpoint): + UPDATE_USER_PATH = '/v1/objects/%s/users/%s' + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._user_id = None + self._include = None + + def user_id(self, user_id): + assert isinstance(user_id, six.string_types) + self._user_id = user_id + return self + + def include(self, data): + assert isinstance(data, dict) + self._include = data + return self + + def custom_params(self): + return {} + + def build_data(self): + if self._include: + return utils.write_value_as_string(self._include) + return '' + + def build_path(self): + if self._user_id is None: + raise PubNubException('Provide user_id.') + return UpdateUser.UPDATE_USER_PATH % (self.pubnub.config.subscribe_key, self._user_id) + + def http_method(self): + return HttpMethod.PATCH + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + + def create_response(self, envelope): # pylint: disable=W0221 + return PNUpdateUserResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNUpdateUserOperation + + def name(self): + return 'Update user' diff --git a/pubnub/enums.py b/pubnub/enums.py index cade070b..cd8fd32e 100644 --- a/pubnub/enums.py +++ b/pubnub/enums.py @@ -2,6 +2,7 @@ class HttpMethod(object): GET = 1 POST = 2 DELETE = 3 + PATCH = 4 @classmethod def string(cls, method): @@ -11,6 +12,8 @@ def string(cls, method): return "POST" elif method == cls.DELETE: return "DELETE" + elif method == cls.PATCH: + return "PATCH" class PNStatusCategory(object): @@ -65,6 +68,7 @@ class PNOperationType(object): PNGetUsersOperation = 27 PNCreateUserOperation = 28 PNFetchUserOperation = 29 + PNUpdateUserOperation = 30 class PNHeartbeatNotificationOptions(object): diff --git a/pubnub/managers.py b/pubnub/managers.py index 4879fb94..2818405e 100644 --- a/pubnub/managers.py +++ b/pubnub/managers.py @@ -454,6 +454,7 @@ def endpoint_name_for_operation(operation_type): PNOperationType.PNGetUsersOperation: 'user', PNOperationType.PNCreateUserOperation: 'user', PNOperationType.PNFetchUserOperation: 'user', + PNOperationType.PNUpdateUserOperation: 'user', }[operation_type] return endpoint diff --git a/pubnub/models/consumer/user.py b/pubnub/models/consumer/user.py index a2b440d6..d73a36e6 100644 --- a/pubnub/models/consumer/user.py +++ b/pubnub/models/consumer/user.py @@ -38,3 +38,17 @@ def __init__(self, result): def __str__(self): return "Fetch user success with data: %s" % self.data + + +class PNUpdateUserResult(object): + def __init__(self, result): + """ + Representation of update user server response + + :param result: result of update user operation + """ + self.data = result['data'] + self.status = result['status'] + + def __str__(self): + return "Update user success with data: %s" % self.data diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index c0802510..7cfc50fa 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -28,6 +28,7 @@ from .endpoints.users.get_users import GetUsers from .endpoints.users.create_user import CreateUser from .endpoints.users.fetch_user import FetchUser +from .endpoints.users.update_user import UpdateUser from .endpoints.push.add_channels_to_push import AddChannelsToPush from .endpoints.push.remove_channels_from_push import RemoveChannelsFromPush @@ -181,6 +182,9 @@ def create_user(self): def fetch_user(self): return FetchUser(self) + def update_user(self): + return UpdateUser(self) + def time(self): return Time(self) diff --git a/pubnub/structures.py b/pubnub/structures.py index 245f38c3..be2f6fe1 100644 --- a/pubnub/structures.py +++ b/pubnub/structures.py @@ -11,7 +11,8 @@ def __init__(self, path, params_callback, method, request_timeout, connect_timeo assert isinstance(method, six.integer_types) assert isinstance(request_timeout, six.integer_types) assert isinstance(connect_timeout, six.integer_types) - if not (method is HttpMethod.GET or method is HttpMethod.POST or method is HttpMethod.DELETE): + if not (method is HttpMethod.GET or method is HttpMethod.POST or method is HttpMethod.DELETE + or method is HttpMethod.PATCH): # noqa raise AssertionError() self.params = None diff --git a/tests/functional/users/test_update_user.py b/tests/functional/users/test_update_user.py new file mode 100644 index 00000000..cc60d847 --- /dev/null +++ b/tests/functional/users/test_update_user.py @@ -0,0 +1,25 @@ +import pytest + +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.users.update_user import UpdateUser +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_fetch_user(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + user = PubNub(config).update_user() + user.include({'a': 3, 'b': 1}) + with pytest.raises(PubNubException): + user.build_path() + + user.user_id('foo') + assert user.build_path() == UpdateUser.UPDATE_USER_PATH % (SUB_KEY, 'foo') + assert user.build_data() == '{"a": 3, "b": 1}' + assert AUTH == user.build_params_callback()({})['auth'] diff --git a/tests/integrational/asyncio/test_user.py b/tests/integrational/asyncio/test_user.py index dc66b1e7..e0064f71 100644 --- a/tests/integrational/asyncio/test_user.py +++ b/tests/integrational/asyncio/test_user.py @@ -3,7 +3,8 @@ from tests.helper import pnconf_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope -from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult, PNFetchUserResult +from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNFetchUserResult, + PNUpdateUserResult) from pubnub.models.consumer.common import PNStatus @@ -68,3 +69,24 @@ def test_fetch_user(event_loop): assert set(['name', 'id', 'externalId', 'profileUrl', 'email', 'created', 'updated', 'eTag']) == set(data) assert data['id'] == 'user-1' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/user/update_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_update_user(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + envelope = yield from pn.update_user().user_id('user-1').include({'id': 'user-1', 'name': 'John Doe', + 'externalId': None, 'profileUrl': None, + 'email': 'jack@twitter.com'}).future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateUserResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'user-1' + assert data['name'] == 'John Doe' diff --git a/tests/integrational/fixtures/asyncio/user/update_user.yaml b/tests/integrational/fixtures/asyncio/user/update_user.yaml new file mode 100644 index 00000000..5f5d4535 --- /dev/null +++ b/tests/integrational/fixtures/asyncio/user/update_user.yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: '{"id": "user-1", "name": "John Doe", "externalId": null, "profileUrl": + null, "email": "jack@twitter.com"}' + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ + \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ + : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ + \n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '319' + Content-Type: application/json + Date: Tue, 16 Jul 2019 17:28:55 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=4c5beff4-a917-4e22-b539-d00806703889 + - '' +version: 1 diff --git a/tests/integrational/fixtures/native_sync/user/update_user.yaml b/tests/integrational/fixtures/native_sync/user/update_user.yaml new file mode 100644 index 00000000..50c9f17d --- /dev/null +++ b/tests/integrational/fixtures/native_sync/user/update_user.yaml @@ -0,0 +1,37 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - PubNub-Python/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ + \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ + : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ + \n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '319' + Content-Type: + - application/json + Date: + - Mon, 15 Jul 2019 21:33:34 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/tornado/user/update_user.yaml b/tests/integrational/fixtures/tornado/user/update_user.yaml new file mode 100644 index 00000000..c7957155 --- /dev/null +++ b/tests/integrational/fixtures/tornado/user/update_user.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: '{"id": "user-1", "name": "John Doe", "externalId": null, "profileUrl": + null, "email": "jack@twitter.com"}' + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ + \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ + : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ + \n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Mon, 15 Jul 2019 21:31:40 GMT + - !!python/tuple + - Content-Length + - - '319' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=97beb33e-2c8a-4875-b551-56a4bad33c50 +version: 1 diff --git a/tests/integrational/native_sync/test_user.py b/tests/integrational/native_sync/test_user.py index 8d574f4a..a8bded64 100644 --- a/tests/integrational/native_sync/test_user.py +++ b/tests/integrational/native_sync/test_user.py @@ -2,7 +2,8 @@ from tests.integrational.vcr_helper import pn_vcr from pubnub.structures import Envelope from pubnub.pubnub import PubNub -from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult, PNFetchUserResult +from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNFetchUserResult, + PNUpdateUserResult) from pubnub.models.consumer.common import PNStatus @@ -64,3 +65,23 @@ def test_fetch_user(): assert set(['name', 'id', 'externalId', 'profileUrl', 'email', 'created', 'updated', 'eTag']) == set(data) assert data['id'] == 'user-1' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/user/update_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_update_user(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.update_user().user_id('user-1').include({'id': 'user-1', 'name': 'John Doe', + 'externalId': None, 'profileUrl': None, + 'email': 'jack@twitter.com'}).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateUserResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'user-1' + assert data['name'] == 'John Doe' diff --git a/tests/integrational/tornado/test_user.py b/tests/integrational/tornado/test_user.py index dbf175fe..73fdbf86 100644 --- a/tests/integrational/tornado/test_user.py +++ b/tests/integrational/tornado/test_user.py @@ -2,7 +2,8 @@ from tornado.testing import AsyncTestCase from pubnub.pubnub_tornado import PubNubTornado, TornadoEnvelope -from pubnub.models.consumer.user import PNGetUsersResult, PNCreateUserResult, PNFetchUserResult +from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNFetchUserResult, + PNUpdateUserResult) from pubnub.models.consumer.common import PNStatus from tests.helper import pnconf_copy from tests.integrational.vcr_helper import pn_vcr @@ -71,3 +72,22 @@ def test_fetch_user(self): 'created', 'updated', 'eTag']) == set(data) assert data['id'] == 'user-1' self.pn.stop() + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/user/update_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_update_user(self): + envelope = yield self.pn.update_user().user_id('user-1').include({'id': 'user-1', 'name': 'John Doe', + 'externalId': None, 'profileUrl': None, + 'email': 'jack@twitter.com'}).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateUserResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'externalId', 'profileUrl', 'email', + 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'user-1' + assert data['name'] == 'John Doe' + self.pn.stop() From d1b2c8e3598450283aafac511c2b8e185e95da21 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Wed, 17 Jul 2019 20:02:45 +0200 Subject: [PATCH 08/26] Implement and test UserDelete endpoint. --- pubnub/endpoints/users/delete_user.py | 54 +++++++++++++++++++ pubnub/enums.py | 1 + pubnub/managers.py | 1 + pubnub/models/consumer/user.py | 14 +++++ pubnub/pubnub_core.py | 4 ++ tests/functional/users/test_delete_user.py | 23 ++++++++ tests/integrational/asyncio/test_user.py | 17 +++++- .../fixtures/asyncio/user/delete_user.yaml | 28 ++++++++++ .../native_sync/user/delete_user.yaml | 32 +++++++++++ .../fixtures/tornado/user/delete_user.yaml | 34 ++++++++++++ tests/integrational/native_sync/test_user.py | 16 +++++- tests/integrational/tornado/test_user.py | 15 +++++- 12 files changed, 236 insertions(+), 3 deletions(-) create mode 100644 pubnub/endpoints/users/delete_user.py create mode 100644 tests/functional/users/test_delete_user.py create mode 100644 tests/integrational/fixtures/asyncio/user/delete_user.yaml create mode 100644 tests/integrational/fixtures/native_sync/user/delete_user.yaml create mode 100644 tests/integrational/fixtures/tornado/user/delete_user.yaml diff --git a/pubnub/endpoints/users/delete_user.py b/pubnub/endpoints/users/delete_user.py new file mode 100644 index 00000000..5b6bf12f --- /dev/null +++ b/pubnub/endpoints/users/delete_user.py @@ -0,0 +1,54 @@ +import six + +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.user import PNDeleteUserResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class DeleteUser(Endpoint): + DELETE_USER_PATH = '/v1/objects/%s/users/%s' + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._user_id = None + + def user_id(self, user_id): + assert isinstance(user_id, six.string_types) + self._user_id = user_id + return self + + def custom_params(self): + return {} + + def build_data(self): + return + + def build_path(self): + if self._user_id is None: + raise PubNubException('Provide user_id.') + return DeleteUser.DELETE_USER_PATH % (self.pubnub.config.subscribe_key, self._user_id) + + def http_method(self): + return HttpMethod.DELETE + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + + def create_response(self, envelope): # pylint: disable=W0221 + return PNDeleteUserResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNDeleteUserOperation + + def name(self): + return 'Delete user' diff --git a/pubnub/enums.py b/pubnub/enums.py index cd8fd32e..988b5431 100644 --- a/pubnub/enums.py +++ b/pubnub/enums.py @@ -69,6 +69,7 @@ class PNOperationType(object): PNCreateUserOperation = 28 PNFetchUserOperation = 29 PNUpdateUserOperation = 30 + PNDeleteUserOperation = 31 class PNHeartbeatNotificationOptions(object): diff --git a/pubnub/managers.py b/pubnub/managers.py index 2818405e..fc5abb63 100644 --- a/pubnub/managers.py +++ b/pubnub/managers.py @@ -455,6 +455,7 @@ def endpoint_name_for_operation(operation_type): PNOperationType.PNCreateUserOperation: 'user', PNOperationType.PNFetchUserOperation: 'user', PNOperationType.PNUpdateUserOperation: 'user', + PNOperationType.PNDeleteUserOperation: 'user' }[operation_type] return endpoint diff --git a/pubnub/models/consumer/user.py b/pubnub/models/consumer/user.py index d73a36e6..18f6ada0 100644 --- a/pubnub/models/consumer/user.py +++ b/pubnub/models/consumer/user.py @@ -52,3 +52,17 @@ def __init__(self, result): def __str__(self): return "Update user success with data: %s" % self.data + + +class PNDeleteUserResult(object): + def __init__(self, result): + """ + Representation of delete user server response + + :param result: result of delete user operation + """ + self.data = result['data'] + self.status = result['status'] + + def __str__(self): + return "Delete user success with data: %s" % self.data diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index 7cfc50fa..86d02d7a 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -29,6 +29,7 @@ from .endpoints.users.create_user import CreateUser from .endpoints.users.fetch_user import FetchUser from .endpoints.users.update_user import UpdateUser +from .endpoints.users.delete_user import DeleteUser from .endpoints.push.add_channels_to_push import AddChannelsToPush from .endpoints.push.remove_channels_from_push import RemoveChannelsFromPush @@ -185,6 +186,9 @@ def fetch_user(self): def update_user(self): return UpdateUser(self) + def delete_user(self): + return DeleteUser(self) + def time(self): return Time(self) diff --git a/tests/functional/users/test_delete_user.py b/tests/functional/users/test_delete_user.py new file mode 100644 index 00000000..b6867600 --- /dev/null +++ b/tests/functional/users/test_delete_user.py @@ -0,0 +1,23 @@ +import pytest + +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.users.delete_user import DeleteUser +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_fetch_user(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + user = PubNub(config).delete_user() + with pytest.raises(PubNubException): + user.build_path() + + user.user_id('foo') + assert user.build_path() == DeleteUser.DELETE_USER_PATH % (SUB_KEY, 'foo') + assert AUTH == user.build_params_callback()({})['auth'] diff --git a/tests/integrational/asyncio/test_user.py b/tests/integrational/asyncio/test_user.py index e0064f71..b48eaff2 100644 --- a/tests/integrational/asyncio/test_user.py +++ b/tests/integrational/asyncio/test_user.py @@ -4,7 +4,7 @@ from tests.integrational.vcr_helper import pn_vcr from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNFetchUserResult, - PNUpdateUserResult) + PNUpdateUserResult, PNDeleteUserResult) from pubnub.models.consumer.common import PNStatus @@ -90,3 +90,18 @@ def test_update_user(event_loop): 'created', 'updated', 'eTag']) == set(data) assert data['id'] == 'user-1' assert data['name'] == 'John Doe' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/user/delete_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_delete_user(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + envelope = yield from pn.delete_user().user_id('user-1').future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNDeleteUserResult) + assert isinstance(envelope.status, PNStatus) + assert envelope.result.data == {} diff --git a/tests/integrational/fixtures/asyncio/user/delete_user.yaml b/tests/integrational/fixtures/asyncio/user/delete_user.yaml new file mode 100644 index 00000000..08b59ee5 --- /dev/null +++ b/tests/integrational/fixtures/asyncio/user/delete_user.yaml @@ -0,0 +1,28 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: DELETE + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + response: + body: + string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '34' + Content-Type: application/json + Date: Wed, 17 Jul 2019 18:02:00 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=b3eb632c-e5da-4649-bd60-bc0a9ecd95ed + - '' +version: 1 diff --git a/tests/integrational/fixtures/native_sync/user/delete_user.yaml b/tests/integrational/fixtures/native_sync/user/delete_user.yaml new file mode 100644 index 00000000..43a0494a --- /dev/null +++ b/tests/integrational/fixtures/native_sync/user/delete_user.yaml @@ -0,0 +1,32 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - PubNub-Python/4.1.0 + method: DELETE + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + response: + body: + string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '34' + Content-Type: + - application/json + Date: + - Wed, 17 Jul 2019 18:02:08 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/tornado/user/delete_user.yaml b/tests/integrational/fixtures/tornado/user/delete_user.yaml new file mode 100644 index 00000000..872c8dab --- /dev/null +++ b/tests/integrational/fixtures/tornado/user/delete_user.yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: null + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: DELETE + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + response: + body: + string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Wed, 17 Jul 2019 18:01:23 GMT + - !!python/tuple + - Content-Length + - - '34' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=66f1becc-0f17-4651-aa06-32eb16a07dde +version: 1 diff --git a/tests/integrational/native_sync/test_user.py b/tests/integrational/native_sync/test_user.py index a8bded64..9428da4e 100644 --- a/tests/integrational/native_sync/test_user.py +++ b/tests/integrational/native_sync/test_user.py @@ -3,7 +3,7 @@ from pubnub.structures import Envelope from pubnub.pubnub import PubNub from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNFetchUserResult, - PNUpdateUserResult) + PNUpdateUserResult, PNDeleteUserResult) from pubnub.models.consumer.common import PNStatus @@ -85,3 +85,17 @@ def test_update_user(): 'created', 'updated', 'eTag']) == set(data) assert data['id'] == 'user-1' assert data['name'] == 'John Doe' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/user/delete_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_delete_user(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.delete_user().user_id('user-1').sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNDeleteUserResult) + assert isinstance(envelope.status, PNStatus) + assert envelope.result.data == {} diff --git a/tests/integrational/tornado/test_user.py b/tests/integrational/tornado/test_user.py index 73fdbf86..bcb0300f 100644 --- a/tests/integrational/tornado/test_user.py +++ b/tests/integrational/tornado/test_user.py @@ -3,7 +3,7 @@ from pubnub.pubnub_tornado import PubNubTornado, TornadoEnvelope from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNFetchUserResult, - PNUpdateUserResult) + PNUpdateUserResult, PNDeleteUserResult) from pubnub.models.consumer.common import PNStatus from tests.helper import pnconf_copy from tests.integrational.vcr_helper import pn_vcr @@ -91,3 +91,16 @@ def test_update_user(self): assert data['id'] == 'user-1' assert data['name'] == 'John Doe' self.pn.stop() + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/user/delete_user.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_delete_user(self): + envelope = yield self.pn.delete_user().user_id('user-1').future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNDeleteUserResult) + assert isinstance(envelope.status, PNStatus) + assert envelope.result.data == {} + self.pn.stop() From 030d19113b722602545ca6839980b93d56ce0e16 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Wed, 17 Jul 2019 20:49:58 +0200 Subject: [PATCH 09/26] Fix test assertion. --- tests/functional/users/test_update_user.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/functional/users/test_update_user.py b/tests/functional/users/test_update_user.py index cc60d847..19a06ad2 100644 --- a/tests/functional/users/test_update_user.py +++ b/tests/functional/users/test_update_user.py @@ -1,4 +1,5 @@ import pytest +import json from pubnub.pubnub import PubNub from pubnub.pnconfiguration import PNConfiguration @@ -21,5 +22,5 @@ def test_fetch_user(): user.user_id('foo') assert user.build_path() == UpdateUser.UPDATE_USER_PATH % (SUB_KEY, 'foo') - assert user.build_data() == '{"a": 3, "b": 1}' + assert json.loads(user.build_data()) == {'a': 3, 'b': 1} assert AUTH == user.build_params_callback()({})['auth'] From d974885fc77406cc8c2e9e3c3c0061d73493965b Mon Sep 17 00:00:00 2001 From: QSD_z Date: Wed, 17 Jul 2019 21:12:16 +0200 Subject: [PATCH 10/26] Expose next, prev and total_count data. --- pubnub/models/consumer/user.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pubnub/models/consumer/user.py b/pubnub/models/consumer/user.py index 18f6ada0..6df6b5db 100644 --- a/pubnub/models/consumer/user.py +++ b/pubnub/models/consumer/user.py @@ -7,6 +7,9 @@ def __init__(self, result): """ self.data = result['data'] self.status = result['status'] + self.total_count = result.get('totalCount', None) + self.next = result.get('next', None) + self.prev = result.get('prev', None) def __str__(self): return "Get users success with data: %s" % self.data From b63f5f43ecb1e6b4d11a7624752f6965bb507d50 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Wed, 17 Jul 2019 21:13:19 +0200 Subject: [PATCH 11/26] Implement consumers and enums for Space API. --- pubnub/enums.py | 5 +++ pubnub/managers.py | 8 +++- pubnub/models/consumer/space.py | 71 +++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 pubnub/models/consumer/space.py diff --git a/pubnub/enums.py b/pubnub/enums.py index 988b5431..3c5692ee 100644 --- a/pubnub/enums.py +++ b/pubnub/enums.py @@ -70,6 +70,11 @@ class PNOperationType(object): PNFetchUserOperation = 29 PNUpdateUserOperation = 30 PNDeleteUserOperation = 31 + PNGetSpacesOperation = 32 + PNCreateSpaceOperation = 33 + PNGetSpaceOperation = 34 + PNUpdateSpaceOperation = 35 + PNDeleteSpaceOperation = 36 class PNHeartbeatNotificationOptions(object): diff --git a/pubnub/managers.py b/pubnub/managers.py index fc5abb63..efe911f9 100644 --- a/pubnub/managers.py +++ b/pubnub/managers.py @@ -455,7 +455,13 @@ def endpoint_name_for_operation(operation_type): PNOperationType.PNCreateUserOperation: 'user', PNOperationType.PNFetchUserOperation: 'user', PNOperationType.PNUpdateUserOperation: 'user', - PNOperationType.PNDeleteUserOperation: 'user' + PNOperationType.PNDeleteUserOperation: 'user', + + PNOperationType.PNGetSpacesOperation: 'spc', + PNOperationType.PNCreateSpaceOperation: 'spc', + PNOperationType.PNGetSpaceOperation: 'spc', + PNOperationType.PNUpdateSpaceOperation: 'spc', + PNOperationType.PNDeleteSpaceOperation: 'spc', }[operation_type] return endpoint diff --git a/pubnub/models/consumer/space.py b/pubnub/models/consumer/space.py new file mode 100644 index 00000000..4effc375 --- /dev/null +++ b/pubnub/models/consumer/space.py @@ -0,0 +1,71 @@ +class PNGetSpacesResult(object): + def __init__(self, result): + """ + Representation of get spaces server response + + :param result: result of get spaces operation + """ + self.data = result['data'] + self.status = result['status'] + self.total_count = result.get('totalCount', None) + self.next = result.get('next', None) + self.prev = result.get('prev', None) + + def __str__(self): + return "Get spaces success with data: %s" % self.data + + +class PNCreateSpaceResult(object): + def __init__(self, result): + """ + Representation of create space server response + + :param result: result of create space operation + """ + self.data = result['data'] + self.status = result['status'] + + def __str__(self): + return "Space created with data: %s" % self.data + + +class PNGetSpaceResult(object): + def __init__(self, result): + """ + Representation of get space server response + + :param result: result of get space operation + """ + self.data = result['data'] + self.status = result['status'] + + def __str__(self): + return "Get space success with data: %s" % self.data + + +class PNUpdateSpaceResult(object): + def __init__(self, result): + """ + Representation of update space server response + + :param result: result of update space operation + """ + self.data = result['data'] + self.status = result['status'] + + def __str__(self): + return "Update space success with data: %s" % self.data + + +class PNDeleteSpaceResult(object): + def __init__(self, result): + """ + Representation of delete space server response + + :param result: result of delete space operation + """ + self.data = result['data'] + self.status = result['status'] + + def __str__(self): + return "Delete space success with data: %s" % self.data From a84b8d376c902062b436a7a28b2536e4bad14a49 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sun, 21 Jul 2019 13:38:10 +0200 Subject: [PATCH 12/26] Implement and test Space API. --- pubnub/endpoints/space/__init__.py | 0 pubnub/endpoints/space/create_space.py | 53 +++++++++ pubnub/endpoints/space/delete_space.py | 54 +++++++++ pubnub/endpoints/space/get_space.py | 60 ++++++++++ pubnub/endpoints/space/get_spaces.py | 88 ++++++++++++++ pubnub/endpoints/space/update_space.py | 63 +++++++++++ pubnub/pubnub_core.py | 20 ++++ tests/functional/spaces/__init__.py | 0 tests/functional/spaces/test_create_space.py | 29 +++++ tests/functional/spaces/test_delete_space.py | 23 ++++ tests/functional/spaces/test_get_space.py | 27 +++++ tests/functional/spaces/test_get_spaces.py | 31 +++++ tests/functional/spaces/test_update_space.py | 26 +++++ tests/functional/users/test_create_user.py | 2 +- tests/functional/users/test_delete_user.py | 2 +- tests/functional/users/test_update_user.py | 2 +- tests/integrational/asyncio/test_space.py | 107 ++++++++++++++++++ .../fixtures/asyncio/space/create_space.yaml | 32 ++++++ .../fixtures/asyncio/space/delete_space.yaml | 28 +++++ .../fixtures/asyncio/space/get_space.yaml | 31 +++++ .../fixtures/asyncio/space/get_spaces.yaml | 39 +++++++ .../fixtures/asyncio/space/update_space.yaml | 32 ++++++ .../native_sync/space/create_space.yaml | 36 ++++++ .../native_sync/space/delete_space.yaml | 32 ++++++ .../fixtures/native_sync/space/get_space.yaml | 33 ++++++ .../native_sync/space/get_spaces.yaml | 41 +++++++ .../native_sync/space/update_space.yaml | 35 ++++++ .../fixtures/tornado/space/create_space.yaml | 38 +++++++ .../fixtures/tornado/space/delete_space.yaml | 34 ++++++ .../fixtures/tornado/space/get_space.yaml | 37 ++++++ .../fixtures/tornado/space/get_spaces.yaml | 45 ++++++++ .../fixtures/tornado/space/update_space.yaml | 38 +++++++ tests/integrational/native_sync/test_space.py | 100 ++++++++++++++++ tests/integrational/tornado/test_space.py | 105 +++++++++++++++++ tests/integrational/tornado/test_user.py | 2 +- 35 files changed, 1321 insertions(+), 4 deletions(-) create mode 100644 pubnub/endpoints/space/__init__.py create mode 100644 pubnub/endpoints/space/create_space.py create mode 100644 pubnub/endpoints/space/delete_space.py create mode 100644 pubnub/endpoints/space/get_space.py create mode 100644 pubnub/endpoints/space/get_spaces.py create mode 100644 pubnub/endpoints/space/update_space.py create mode 100644 tests/functional/spaces/__init__.py create mode 100644 tests/functional/spaces/test_create_space.py create mode 100644 tests/functional/spaces/test_delete_space.py create mode 100644 tests/functional/spaces/test_get_space.py create mode 100644 tests/functional/spaces/test_get_spaces.py create mode 100644 tests/functional/spaces/test_update_space.py create mode 100644 tests/integrational/asyncio/test_space.py create mode 100644 tests/integrational/fixtures/asyncio/space/create_space.yaml create mode 100644 tests/integrational/fixtures/asyncio/space/delete_space.yaml create mode 100644 tests/integrational/fixtures/asyncio/space/get_space.yaml create mode 100644 tests/integrational/fixtures/asyncio/space/get_spaces.yaml create mode 100644 tests/integrational/fixtures/asyncio/space/update_space.yaml create mode 100644 tests/integrational/fixtures/native_sync/space/create_space.yaml create mode 100644 tests/integrational/fixtures/native_sync/space/delete_space.yaml create mode 100644 tests/integrational/fixtures/native_sync/space/get_space.yaml create mode 100644 tests/integrational/fixtures/native_sync/space/get_spaces.yaml create mode 100644 tests/integrational/fixtures/native_sync/space/update_space.yaml create mode 100644 tests/integrational/fixtures/tornado/space/create_space.yaml create mode 100644 tests/integrational/fixtures/tornado/space/delete_space.yaml create mode 100644 tests/integrational/fixtures/tornado/space/get_space.yaml create mode 100644 tests/integrational/fixtures/tornado/space/get_spaces.yaml create mode 100644 tests/integrational/fixtures/tornado/space/update_space.yaml create mode 100644 tests/integrational/native_sync/test_space.py create mode 100644 tests/integrational/tornado/test_space.py diff --git a/pubnub/endpoints/space/__init__.py b/pubnub/endpoints/space/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pubnub/endpoints/space/create_space.py b/pubnub/endpoints/space/create_space.py new file mode 100644 index 00000000..f8bbfa37 --- /dev/null +++ b/pubnub/endpoints/space/create_space.py @@ -0,0 +1,53 @@ +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.space import PNCreateSpaceResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class CreateSpace(Endpoint): + CREATE_SPACE_PATH = '/v1/objects/%s/spaces' + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._include = {} + + def include(self, data): + assert isinstance(data, dict) + self._include = data + return self + + def custom_params(self): + return {} + + def build_data(self): + return utils.write_value_as_string(self._include) + + def validate_params(self): + self.validate_subscribe_key() + if 'id' not in self._include or 'name' not in self._include: + raise PubNubException('"id" or "name" not found in include data.') + + def build_path(self): + return CreateSpace.CREATE_SPACE_PATH % (self.pubnub.config.subscribe_key) + + def http_method(self): + return HttpMethod.POST + + def is_auth_required(self): + return True + + def create_response(self, envelope): # pylint: disable=W0221 + return PNCreateSpaceResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNCreateSpaceOperation + + def name(self): + return 'Create space' diff --git a/pubnub/endpoints/space/delete_space.py b/pubnub/endpoints/space/delete_space.py new file mode 100644 index 00000000..e1f04a1e --- /dev/null +++ b/pubnub/endpoints/space/delete_space.py @@ -0,0 +1,54 @@ +import six + +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.space import PNDeleteSpaceResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class DeleteSpace(Endpoint): + DELETE_DELETE_PATH = '/v1/objects/%s/spaces/%s' + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._space_id = None + + def space_id(self, space_id): + assert isinstance(space_id, six.string_types) + self._space_id = space_id + return self + + def custom_params(self): + return {} + + def build_data(self): + return + + def build_path(self): + if self._space_id is None: + raise PubNubException('Provide space id.') + return DeleteSpace.DELETE_DELETE_PATH % (self.pubnub.config.subscribe_key, self._space_id) + + def http_method(self): + return HttpMethod.DELETE + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + + def create_response(self, envelope): # pylint: disable=W0221 + return PNDeleteSpaceResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNDeleteSpaceOperation + + def name(self): + return 'Delete space' diff --git a/pubnub/endpoints/space/get_space.py b/pubnub/endpoints/space/get_space.py new file mode 100644 index 00000000..0da54399 --- /dev/null +++ b/pubnub/endpoints/space/get_space.py @@ -0,0 +1,60 @@ +import six + +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.space import PNGetSpaceResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class GetSpace(Endpoint): + GET_SPACE_PATH = '/v1/objects/%s/spaces/%s' + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._space_id = None + self._include = None + + def space_id(self, space_id): + assert isinstance(space_id, six.string_types) + self._space_id = space_id + return self + + def include(self, data): + self._include = data + return self + + def custom_params(self): + params = {} + if self._include: + params['include'] = utils.url_write(self._include) + return params + + def build_path(self): + if self._space_id is None: + raise PubNubException('Provide space id.') + return GetSpace.GET_SPACE_PATH % (self.pubnub.config.subscribe_key, self._space_id) + + def http_method(self): + return HttpMethod.GET + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + + def create_response(self, envelope): # pylint: disable=W0221 + return PNGetSpaceResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNGetSpaceOperation + + def name(self): + return 'Get space' diff --git a/pubnub/endpoints/space/get_spaces.py b/pubnub/endpoints/space/get_spaces.py new file mode 100644 index 00000000..dab60565 --- /dev/null +++ b/pubnub/endpoints/space/get_spaces.py @@ -0,0 +1,88 @@ +import six +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.space import PNGetSpacesResult +from pubnub.enums import HttpMethod, PNOperationType + + +class GetSpaces(Endpoint): + GET_SPACES_PATH = '/v1/objects/%s/spaces' + MAX_LIMIT = 100 + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._start = None + self._end = None + self._limit = GetSpaces.MAX_LIMIT + self._count = False + self._include = None + + def start(self, start): + assert isinstance(start, six.string_types) + self._start = start + return self + + def end(self, end): + assert isinstance(end, six.string_types) + self._end = end + return self + + def limit(self, limit): + assert isinstance(limit, six.integer_types) + self._limit = limit + return self + + def count(self, count): + self._count = bool(count) + return self + + def include(self, data): + self._include = data + return self + + def custom_params(self): + params = {} + + if self._start is not None: + params['start'] = self._start + + if self._end is not None and self._start is None: + params['end'] = self._end + + if self._count is True: + params['count'] = True + + if self._limit != GetSpaces.MAX_LIMIT: + params['limit'] = self._limit + + if self._include: + params['include'] = utils.url_write(self._include) + + return params + + def build_path(self): + return GetSpaces.GET_SPACES_PATH % (self.pubnub.config.subscribe_key) + + def http_method(self): + return HttpMethod.GET + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + + def create_response(self, envelope): # pylint: disable=W0221 + return PNGetSpacesResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNGetSpacesOperation + + def name(self): + return 'Get spaces' diff --git a/pubnub/endpoints/space/update_space.py b/pubnub/endpoints/space/update_space.py new file mode 100644 index 00000000..14145e61 --- /dev/null +++ b/pubnub/endpoints/space/update_space.py @@ -0,0 +1,63 @@ +import six + +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.space import PNUpdateSpaceResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class UpdateSpace(Endpoint): + UPDATE_SPACE_PATH = '/v1/objects/%s/spaces/%s' + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._space_id = None + self._include = None + + def space_id(self, space_id): + assert isinstance(space_id, six.string_types) + self._space_id = space_id + return self + + def include(self, data): + assert isinstance(data, dict) + self._include = data + return self + + def custom_params(self): + return {} + + def build_data(self): + if self._include: + return utils.write_value_as_string(self._include) + return '' + + def build_path(self): + if self._space_id is None: + raise PubNubException('Provide space id.') + return UpdateSpace.UPDATE_SPACE_PATH % (self.pubnub.config.subscribe_key, self._space_id) + + def http_method(self): + return HttpMethod.PATCH + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + + def create_response(self, envelope): # pylint: disable=W0221 + return PNUpdateSpaceResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNUpdateSpaceOperation + + def name(self): + return 'Update space' diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index 86d02d7a..331a7a1e 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -30,6 +30,11 @@ from .endpoints.users.fetch_user import FetchUser from .endpoints.users.update_user import UpdateUser from .endpoints.users.delete_user import DeleteUser +from .endpoints.space.get_spaces import GetSpaces +from .endpoints.space.get_space import GetSpace +from .endpoints.space.update_space import UpdateSpace +from .endpoints.space.delete_space import DeleteSpace +from .endpoints.space.create_space import CreateSpace from .endpoints.push.add_channels_to_push import AddChannelsToPush from .endpoints.push.remove_channels_from_push import RemoveChannelsFromPush @@ -189,6 +194,21 @@ def update_user(self): def delete_user(self): return DeleteUser(self) + def get_spaces(self): + return GetSpaces(self) + + def get_space(self): + return GetSpace(self) + + def update_space(self): + return UpdateSpace(self) + + def delete_space(self): + return DeleteSpace(self) + + def create_space(self): + return CreateSpace(self) + def time(self): return Time(self) diff --git a/tests/functional/spaces/__init__.py b/tests/functional/spaces/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/functional/spaces/test_create_space.py b/tests/functional/spaces/test_create_space.py new file mode 100644 index 00000000..ba94b13d --- /dev/null +++ b/tests/functional/spaces/test_create_space.py @@ -0,0 +1,29 @@ +import pytest +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.space.create_space import CreateSpace +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_create_space(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + space = PubNub(config).create_space() + with pytest.raises(PubNubException): + space.validate_params() + space.include({'name': 'a'}) + with pytest.raises(PubNubException): + space.validate_params() + space.include({'id': 'x'}) + with pytest.raises(PubNubException): + space.validate_params() + space.include({'id': 'x', 'name': 'a'}) + space.validate_params() + + assert space.build_path() == CreateSpace.CREATE_SPACE_PATH % SUB_KEY + assert AUTH == space.build_params_callback()({})['auth'] diff --git a/tests/functional/spaces/test_delete_space.py b/tests/functional/spaces/test_delete_space.py new file mode 100644 index 00000000..f69c8b86 --- /dev/null +++ b/tests/functional/spaces/test_delete_space.py @@ -0,0 +1,23 @@ +import pytest + +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.space.delete_space import DeleteSpace +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_delete_space(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + space = PubNub(config).delete_space() + with pytest.raises(PubNubException): + space.build_path() + + space.space_id('foo') + assert space.build_path() == DeleteSpace.DELETE_DELETE_PATH % (SUB_KEY, 'foo') + assert AUTH == space.build_params_callback()({})['auth'] diff --git a/tests/functional/spaces/test_get_space.py b/tests/functional/spaces/test_get_space.py new file mode 100644 index 00000000..4e90778f --- /dev/null +++ b/tests/functional/spaces/test_get_space.py @@ -0,0 +1,27 @@ +import pytest + +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.space.get_space import GetSpace +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_fetch_space(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + space = PubNub(config).get_space() + space.include(['a', 'b']) + with pytest.raises(PubNubException): + space.build_path() + + space.space_id('foo') + assert space.build_path() == GetSpace.GET_SPACE_PATH % (SUB_KEY, 'foo') + + params = space.custom_params() + assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' + assert AUTH == space.build_params_callback()({})['auth'] diff --git a/tests/functional/spaces/test_get_spaces.py b/tests/functional/spaces/test_get_spaces.py new file mode 100644 index 00000000..a0a9e543 --- /dev/null +++ b/tests/functional/spaces/test_get_spaces.py @@ -0,0 +1,31 @@ +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.space.get_spaces import GetSpaces + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_get_spaces(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + spaces = PubNub(config).get_spaces() + spaces.include(['a', 'b']).limit(30).end('XXX') + + assert spaces.build_path() == GetSpaces.GET_SPACES_PATH % SUB_KEY + + params = spaces.custom_params() + assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' + assert params['limit'] == 30 + assert params['end'] == 'XXX' + assert 'count' not in params + + spaces.start('YYY').count(True) + params = spaces.custom_params() + assert 'end' not in params + assert params['start'] == 'YYY' + assert params['count'] is True + + assert AUTH == spaces.build_params_callback()({})['auth'] diff --git a/tests/functional/spaces/test_update_space.py b/tests/functional/spaces/test_update_space.py new file mode 100644 index 00000000..9813b6e1 --- /dev/null +++ b/tests/functional/spaces/test_update_space.py @@ -0,0 +1,26 @@ +import pytest +import json + +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.space.update_space import UpdateSpace +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_update_space(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + space = PubNub(config).update_space() + space.include({'a': 3, 'b': 1}) + with pytest.raises(PubNubException): + space.build_path() + + space.space_id('foo') + assert space.build_path() == UpdateSpace.UPDATE_SPACE_PATH % (SUB_KEY, 'foo') + assert json.loads(space.build_data()) == {'a': 3, 'b': 1} + assert AUTH == space.build_params_callback()({})['auth'] diff --git a/tests/functional/users/test_create_user.py b/tests/functional/users/test_create_user.py index f0de4f0a..64af71e1 100644 --- a/tests/functional/users/test_create_user.py +++ b/tests/functional/users/test_create_user.py @@ -9,7 +9,7 @@ AUTH = 'auth' -def test_get_users(): +def test_create_user(): config = PNConfiguration() config.subscribe_key = SUB_KEY config.auth_key = AUTH diff --git a/tests/functional/users/test_delete_user.py b/tests/functional/users/test_delete_user.py index b6867600..2809fcbf 100644 --- a/tests/functional/users/test_delete_user.py +++ b/tests/functional/users/test_delete_user.py @@ -10,7 +10,7 @@ AUTH = 'auth' -def test_fetch_user(): +def test_delete_user(): config = PNConfiguration() config.subscribe_key = SUB_KEY config.auth_key = AUTH diff --git a/tests/functional/users/test_update_user.py b/tests/functional/users/test_update_user.py index 19a06ad2..fedcd350 100644 --- a/tests/functional/users/test_update_user.py +++ b/tests/functional/users/test_update_user.py @@ -11,7 +11,7 @@ AUTH = 'auth' -def test_fetch_user(): +def test_update_user(): config = PNConfiguration() config.subscribe_key = SUB_KEY config.auth_key = AUTH diff --git a/tests/integrational/asyncio/test_space.py b/tests/integrational/asyncio/test_space.py new file mode 100644 index 00000000..81859c8a --- /dev/null +++ b/tests/integrational/asyncio/test_space.py @@ -0,0 +1,107 @@ +import pytest + +from tests.helper import pnconf_copy +from tests.integrational.vcr_helper import pn_vcr +from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope +from pubnub.models.consumer.space import (PNGetSpacesResult, PNCreateSpaceResult, PNGetSpaceResult, + PNUpdateSpaceResult, PNDeleteSpaceResult) +from pubnub.models.consumer.common import PNStatus + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/space/get_spaces.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_get_spaces(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + envelope = yield from pn.get_spaces().include(['description', 'custom', 'created', 'updated', 'eTag']).future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetSpacesResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[1]) + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/space/create_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_create_space(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + envelope = yield from pn.create_space().include({'id': 'my-channel', 'name': 'My space', + 'description': 'A space that is mine'}).future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNCreateSpaceResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert data['id'] == 'my-channel' + assert data['name'] == 'My space' + assert data['description'] == 'A space that is mine' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/space/get_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_get_space(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + envelope = yield from pn.get_space().space_id( + 'my-chanel').include(['description', 'name', 'created', 'updated', 'eTag']).future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetSpaceResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'my-channel' + assert data['name'] == 'My space' + assert data['description'] == 'A space that is mine' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/space/update_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_update_space(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + include = {'id': 'my-channel', 'name': 'My space', + 'description': 'A space that is mine'} + envelope = yield from pn.update_space().space_id('my-channel').include(include).future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateSpaceResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'my-channel' + assert data['name'] == 'My space' + assert data['description'] == 'A space that is mine' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/space/delete_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_delete_space(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + envelope = yield from pn.delete_space().space_id('main').future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNDeleteSpaceResult) + assert isinstance(envelope.status, PNStatus) + assert envelope.result.data == {} diff --git a/tests/integrational/fixtures/asyncio/space/create_space.yaml b/tests/integrational/fixtures/asyncio/space/create_space.yaml new file mode 100644 index 00000000..8778bf7d --- /dev/null +++ b/tests/integrational/fixtures/asyncio/space/create_space.yaml @@ -0,0 +1,32 @@ +interactions: +- request: + body: '{"id": "my-channel", "name": "My space", "description": "A space that is + mine"}' + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: POST + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '285' + Content-Type: application/json + Date: Sun, 21 Jul 2019 11:50:35 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=d4cb114b-f8b6-4eb7-b37d-886a613629c4 + - '' +version: 1 diff --git a/tests/integrational/fixtures/asyncio/space/delete_space.yaml b/tests/integrational/fixtures/asyncio/space/delete_space.yaml new file mode 100644 index 00000000..ad25f1f1 --- /dev/null +++ b/tests/integrational/fixtures/asyncio/space/delete_space.yaml @@ -0,0 +1,28 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: DELETE + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main + response: + body: + string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '34' + Content-Type: application/json + Date: Sun, 21 Jul 2019 11:50:36 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=a08a0bdc-6626-4926-ac86-ff77e8af18be + - '' +version: 1 diff --git a/tests/integrational/fixtures/asyncio/space/get_space.yaml b/tests/integrational/fixtures/asyncio/space/get_space.yaml new file mode 100644 index 00000000..ac435975 --- /dev/null +++ b/tests/integrational/fixtures/asyncio/space/get_space.yaml @@ -0,0 +1,31 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel?include=%5B%22description%22%2C+%22name%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '285' + Content-Type: application/json + Date: Sun, 21 Jul 2019 11:50:36 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel + - include=%5B%22description%22%2C%20%22name%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=a92093b7-9c6c-4f98-a252-ba3cb25ec65f + - '' +version: 1 diff --git a/tests/integrational/fixtures/asyncio/space/get_spaces.yaml b/tests/integrational/fixtures/asyncio/space/get_spaces.yaml new file mode 100644 index 00000000..b2be51ac --- /dev/null +++ b/tests/integrational/fixtures/asyncio/space/get_spaces.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?include=%5B%22description%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": null,\n \"description\": \"A space that is mine\"\ + ,\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"\ + updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n \"created\"\ + : \"2019-02-20T23:11:20.893755\",\n \"custom\": {\n \"motd\":\ + \ \"Always check your spelling!\",\n \"public\": true\n },\n \ + \ \"description\": \"The main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"MUIwQTAwMUItQkRBRC00NDkyLTgyMEMtODg2OUU1N0REMTNBCg==\"\ + ,\n \"prev\": \"M0FFODRENzMtNjY2Qy00RUExLTk4QzktNkY1Q0I2MUJFNDRCCg==\",\n\ + \ \"status\": \"ok\",\n \"totalCount\": 9\n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '842' + Content-Type: application/json + Date: Sun, 21 Jul 2019 11:50:35 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces + - include=%5B%22description%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=726f3828-77b8-4af6-b633-8b81313543d5 + - '' +version: 1 diff --git a/tests/integrational/fixtures/asyncio/space/update_space.yaml b/tests/integrational/fixtures/asyncio/space/update_space.yaml new file mode 100644 index 00000000..7d4894b8 --- /dev/null +++ b/tests/integrational/fixtures/asyncio/space/update_space.yaml @@ -0,0 +1,32 @@ +interactions: +- request: + body: '{"id": "my-channel", "name": "My space", "description": "A space that is + mine"}' + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-channel + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '285' + Content-Type: application/json + Date: Sun, 21 Jul 2019 11:50:36 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-channel + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=5944dcec-c3e7-4837-a830-f66132e36fad + - '' +version: 1 diff --git a/tests/integrational/fixtures/native_sync/space/create_space.yaml b/tests/integrational/fixtures/native_sync/space/create_space.yaml new file mode 100644 index 00000000..5ed92bf0 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/space/create_space.yaml @@ -0,0 +1,36 @@ +interactions: +- request: + body: '{"id": "my-channel", "name": "My space", "description": "A space that is + mine"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '79' + User-Agent: + - PubNub-Python/4.1.0 + method: POST + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '285' + Content-Type: + - application/json + Date: + - Sun, 21 Jul 2019 11:36:49 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/native_sync/space/delete_space.yaml b/tests/integrational/fixtures/native_sync/space/delete_space.yaml new file mode 100644 index 00000000..e5509d58 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/space/delete_space.yaml @@ -0,0 +1,32 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - PubNub-Python/4.1.0 + method: DELETE + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main + response: + body: + string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '34' + Content-Type: + - application/json + Date: + - Sun, 21 Jul 2019 11:37:02 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/native_sync/space/get_space.yaml b/tests/integrational/fixtures/native_sync/space/get_space.yaml new file mode 100644 index 00000000..6e91adeb --- /dev/null +++ b/tests/integrational/fixtures/native_sync/space/get_space.yaml @@ -0,0 +1,33 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - PubNub-Python/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel?include=%5B%22description%22%2C+%22name%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '285' + Content-Type: + - application/json + Date: + - Sun, 21 Jul 2019 11:36:49 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/native_sync/space/get_spaces.yaml b/tests/integrational/fixtures/native_sync/space/get_spaces.yaml new file mode 100644 index 00000000..8a1dbccc --- /dev/null +++ b/tests/integrational/fixtures/native_sync/space/get_spaces.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - PubNub-Python/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?include=%5B%22description%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": null,\n \"description\": \"A space that is mine\"\ + ,\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"\ + updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n \"created\"\ + : \"2019-02-20T23:11:20.893755\",\n \"custom\": {\n \"motd\":\ + \ \"Always check your spelling!\",\n \"public\": true\n },\n \ + \ \"description\": \"The main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"MUIwQTAwMUItQkRBRC00NDkyLTgyMEMtODg2OUU1N0REMTNBCg==\"\ + ,\n \"prev\": \"M0FFODRENzMtNjY2Qy00RUExLTk4QzktNkY1Q0I2MUJFNDRCCg==\",\n\ + \ \"status\": \"ok\",\n \"totalCount\": 9\n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '842' + Content-Type: + - application/json + Date: + - Sun, 21 Jul 2019 11:36:49 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/native_sync/space/update_space.yaml b/tests/integrational/fixtures/native_sync/space/update_space.yaml new file mode 100644 index 00000000..d56a39d8 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/space/update_space.yaml @@ -0,0 +1,35 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - PubNub-Python/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-channel + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '285' + Content-Type: + - application/json + Date: + - Sun, 21 Jul 2019 11:36:49 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/tornado/space/create_space.yaml b/tests/integrational/fixtures/tornado/space/create_space.yaml new file mode 100644 index 00000000..299044eb --- /dev/null +++ b/tests/integrational/fixtures/tornado/space/create_space.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: '{"id": "my-channel", "name": "My space", "description": "A space that is + mine"}' + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: POST + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Sun, 21 Jul 2019 11:57:06 GMT + - !!python/tuple + - Content-Length + - - '285' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=40461998-ccdc-4768-83f7-f0005f11b10c +version: 1 diff --git a/tests/integrational/fixtures/tornado/space/delete_space.yaml b/tests/integrational/fixtures/tornado/space/delete_space.yaml new file mode 100644 index 00000000..d36fce01 --- /dev/null +++ b/tests/integrational/fixtures/tornado/space/delete_space.yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: null + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: DELETE + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main + response: + body: + string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Sun, 21 Jul 2019 11:57:06 GMT + - !!python/tuple + - Content-Length + - - '34' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=93064877-8c6b-4882-8152-83eed20d09e4 +version: 1 diff --git a/tests/integrational/fixtures/tornado/space/get_space.yaml b/tests/integrational/fixtures/tornado/space/get_space.yaml new file mode 100644 index 00000000..866bc855 --- /dev/null +++ b/tests/integrational/fixtures/tornado/space/get_space.yaml @@ -0,0 +1,37 @@ +interactions: +- request: + body: null + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel?include=%5B%22description%22%2C+%22name%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Sun, 21 Jul 2019 11:57:06 GMT + - !!python/tuple + - Content-Length + - - '285' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel?include=%5B%22description%22%2C%20%22name%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=0da25714-4f0c-4b3b-adcd-33bfc44d1431 +version: 1 diff --git a/tests/integrational/fixtures/tornado/space/get_spaces.yaml b/tests/integrational/fixtures/tornado/space/get_spaces.yaml new file mode 100644 index 00000000..f8ee86de --- /dev/null +++ b/tests/integrational/fixtures/tornado/space/get_spaces.yaml @@ -0,0 +1,45 @@ +interactions: +- request: + body: null + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?include=%5B%22description%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": null,\n \"description\": \"A space that is mine\"\ + ,\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"\ + updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n \"created\"\ + : \"2019-02-20T23:11:20.893755\",\n \"custom\": {\n \"motd\":\ + \ \"Always check your spelling!\",\n \"public\": true\n },\n \ + \ \"description\": \"The main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"MUIwQTAwMUItQkRBRC00NDkyLTgyMEMtODg2OUU1N0REMTNBCg==\"\ + ,\n \"prev\": \"M0FFODRENzMtNjY2Qy00RUExLTk4QzktNkY1Q0I2MUJFNDRCCg==\",\n\ + \ \"status\": \"ok\",\n \"totalCount\": 9\n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Sun, 21 Jul 2019 11:57:06 GMT + - !!python/tuple + - Content-Length + - - '842' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?include=%5B%22description%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=363b0152-af3e-4635-9046-b5a761ca182b +version: 1 diff --git a/tests/integrational/fixtures/tornado/space/update_space.yaml b/tests/integrational/fixtures/tornado/space/update_space.yaml new file mode 100644 index 00000000..396e5aca --- /dev/null +++ b/tests/integrational/fixtures/tornado/space/update_space.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: '{"id": "my-channel", "name": "My space", "description": "A space that is + mine"}' + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-channel + response: + body: + string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ + \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Sun, 21 Jul 2019 11:57:06 GMT + - !!python/tuple + - Content-Length + - - '285' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-channel?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=4301d4ab-e67c-4fa4-b8c8-477114fc3666 +version: 1 diff --git a/tests/integrational/native_sync/test_space.py b/tests/integrational/native_sync/test_space.py new file mode 100644 index 00000000..271d2d1b --- /dev/null +++ b/tests/integrational/native_sync/test_space.py @@ -0,0 +1,100 @@ +from tests.helper import pnconf_copy +from tests.integrational.vcr_helper import pn_vcr +from pubnub.structures import Envelope +from pubnub.pubnub import PubNub +from pubnub.models.consumer.space import (PNGetSpacesResult, PNCreateSpaceResult, PNGetSpaceResult, + PNUpdateSpaceResult, PNDeleteSpaceResult) +from pubnub.models.consumer.common import PNStatus + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/space/get_spaces.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_get_spaces(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.get_spaces().include(['description', 'custom', 'created', 'updated', 'eTag']).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetSpacesResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[1]) + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/space/create_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_create_space(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.create_space().include({'id': 'my-channel', 'name': 'My space', + 'description': 'A space that is mine'}).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNCreateSpaceResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert data['id'] == 'my-channel' + assert data['name'] == 'My space' + assert data['description'] == 'A space that is mine' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/space/get_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_get_space(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.get_space().space_id( + 'my-chanel').include(['description', 'name', 'created', 'updated', 'eTag']).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetSpaceResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'my-channel' + assert data['name'] == 'My space' + assert data['description'] == 'A space that is mine' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/space/update_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_update_space(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.update_space().space_id('my-channel').include({'id': 'my-channel', 'name': 'My space', + 'description': 'A space that is mine'}).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateSpaceResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'my-channel' + assert data['name'] == 'My space' + assert data['description'] == 'A space that is mine' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/space/delete_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_delete_space(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.delete_space().space_id('main').sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNDeleteSpaceResult) + assert isinstance(envelope.status, PNStatus) + assert envelope.result.data == {} diff --git a/tests/integrational/tornado/test_space.py b/tests/integrational/tornado/test_space.py new file mode 100644 index 00000000..5e7c59c7 --- /dev/null +++ b/tests/integrational/tornado/test_space.py @@ -0,0 +1,105 @@ +import tornado +from tornado.testing import AsyncTestCase + +from tests.helper import pnconf_copy +from tests.integrational.vcr_helper import pn_vcr +from pubnub.pubnub_tornado import PubNubTornado, TornadoEnvelope +from pubnub.models.consumer.space import (PNGetSpacesResult, PNCreateSpaceResult, PNGetSpaceResult, + PNUpdateSpaceResult, PNDeleteSpaceResult) +from pubnub.models.consumer.common import PNStatus + + +class TestSpace(AsyncTestCase): + def setUp(self): + AsyncTestCase.setUp(self) + config = pnconf_copy() + self.pn = PubNubTornado(config, custom_ioloop=self.io_loop) + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/space/get_spaces.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_get_spaces(self): + envelope = yield self.pn.get_spaces().include(['description', 'custom', 'created', 'updated', 'eTag']).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetSpacesResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[1]) + self.pn.stop() + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/space/create_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_create_space(self): + envelope = yield self.pn.create_space().include({'id': 'my-channel', 'name': 'My space', + 'description': 'A space that is mine'}).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNCreateSpaceResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert data['id'] == 'my-channel' + assert data['name'] == 'My space' + assert data['description'] == 'A space that is mine' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' + self.pn.stop() + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/space/get_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_get_space(self): + envelope = yield self.pn.get_space().space_id( + 'my-chanel').include(['description', 'name', 'created', 'updated', 'eTag']).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetSpaceResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'my-channel' + assert data['name'] == 'My space' + assert data['description'] == 'A space that is mine' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' + self.pn.stop() + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/space/update_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_update_space(self): + include = {'id': 'my-channel', 'name': 'My space', + 'description': 'A space that is mine'} + envelope = yield self.pn.update_space().space_id('my-channel').include(include).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateSpaceResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) + assert data['id'] == 'my-channel' + assert data['name'] == 'My space' + assert data['description'] == 'A space that is mine' + assert data['created'] == '2019-02-20T23:11:20.893755' + assert data['updated'] == '2019-02-20T23:11:20.893755' + self.pn.stop() + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/space/delete_space.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_delete_space(self): + envelope = yield self.pn.delete_space().space_id('main').future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNDeleteSpaceResult) + assert isinstance(envelope.status, PNStatus) + assert envelope.result.data == {} + self.pn.stop() diff --git a/tests/integrational/tornado/test_user.py b/tests/integrational/tornado/test_user.py index bcb0300f..f8be4051 100644 --- a/tests/integrational/tornado/test_user.py +++ b/tests/integrational/tornado/test_user.py @@ -9,7 +9,7 @@ from tests.integrational.vcr_helper import pn_vcr -class TestGetUsers(AsyncTestCase): +class TestUser(AsyncTestCase): def setUp(self): AsyncTestCase.setUp(self) config = pnconf_copy() From 2bc4630047071999ffb3a431cf547f41992e3c32 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sun, 28 Jul 2019 14:30:13 +0200 Subject: [PATCH 13/26] Implement consumers and enums for Membership API. --- pubnub/enums.py | 4 ++ pubnub/managers.py | 28 +++++++----- pubnub/models/consumer/membership.py | 66 ++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 pubnub/models/consumer/membership.py diff --git a/pubnub/enums.py b/pubnub/enums.py index 3c5692ee..d288ae23 100644 --- a/pubnub/enums.py +++ b/pubnub/enums.py @@ -75,6 +75,10 @@ class PNOperationType(object): PNGetSpaceOperation = 34 PNUpdateSpaceOperation = 35 PNDeleteSpaceOperation = 36 + PNGetMembersOperation = 37 + PNGetSpaceMembershipsOperation = 38 + PNUpdateMembersOperation = 39 + PNUpdateSpaceMembershipsOperation = 40 class PNHeartbeatNotificationOptions(object): diff --git a/pubnub/managers.py b/pubnub/managers.py index efe911f9..62e21c17 100644 --- a/pubnub/managers.py +++ b/pubnub/managers.py @@ -448,20 +448,24 @@ def endpoint_name_for_operation(operation_type): PNOperationType.PNAccessManagerAudit: 'pam', PNOperationType.PNAccessManagerGrant: 'pam', PNOperationType.PNAccessManagerRevoke: 'pam', - PNOperationType.PNTimeOperation: 'pam', + PNOperationType.PNSignalOperation: 'sig', - PNOperationType.PNGetUsersOperation: 'user', - PNOperationType.PNCreateUserOperation: 'user', - PNOperationType.PNFetchUserOperation: 'user', - PNOperationType.PNUpdateUserOperation: 'user', - PNOperationType.PNDeleteUserOperation: 'user', - - PNOperationType.PNGetSpacesOperation: 'spc', - PNOperationType.PNCreateSpaceOperation: 'spc', - PNOperationType.PNGetSpaceOperation: 'spc', - PNOperationType.PNUpdateSpaceOperation: 'spc', - PNOperationType.PNDeleteSpaceOperation: 'spc', + + PNOperationType.PNGetUsersOperation: 'obj', + PNOperationType.PNCreateUserOperation: 'obj', + PNOperationType.PNFetchUserOperation: 'obj', + PNOperationType.PNUpdateUserOperation: 'obj', + PNOperationType.PNDeleteUserOperation: 'obj', + PNOperationType.PNGetSpacesOperation: 'obj', + PNOperationType.PNCreateSpaceOperation: 'obj', + PNOperationType.PNGetSpaceOperation: 'obj', + PNOperationType.PNUpdateSpaceOperation: 'obj', + PNOperationType.PNDeleteSpaceOperation: 'obj', + PNOperationType.PNGetMembersOperation: 'obj', + PNOperationType.PNGetSpaceMembershipsOperation: 'obj', + PNOperationType.PNUpdateMembersOperation: 'obj', + PNOperationType.PNUpdateSpaceMembershipsOperation: 'obj', }[operation_type] return endpoint diff --git a/pubnub/models/consumer/membership.py b/pubnub/models/consumer/membership.py new file mode 100644 index 00000000..5d5de3a4 --- /dev/null +++ b/pubnub/models/consumer/membership.py @@ -0,0 +1,66 @@ +class PNGetSpaceMembershipsResult(object): + def __init__(self, result): + """ + Representation of get space memberships server response + + :param result: result of get space memberships operation + """ + self.data = result['data'] + self.status = result['status'] + self.total_count = result.get('totalCount', None) + self.next = result.get('next', None) + self.prev = result.get('prev', None) + + def __str__(self): + return "Get space memberships success with data: %s" % self.space + + +class PNUpdateSpaceMembershipsResult(object): + def __init__(self, result): + """ + Representation of update space memeberships response + + :param result: result of update space memeberships operation + """ + self.data = result['data'] + self.status = result['status'] + self.total_count = result.get('totalCount', None) + self.next = result.get('next', None) + self.prev = result.get('prev', None) + + def __str__(self): + return "Update space memebership success with data: %s" % self.data + + +class PNGetMembersResult(object): + def __init__(self, result): + """ + Representation of fetch user server response + + :param result: result of fetch user operation + """ + self.data = result['data'] + self.status = result['status'] + self.total_count = result.get('totalCount', None) + self.next = result.get('next', None) + self.prev = result.get('prev', None) + + def __str__(self): + return "Get members success with data: %s" % self.data + + +class PNUpdateMembersResult(object): + def __init__(self, result): + """ + Representation of update members server response + + :param result: result of update members operation + """ + self.data = result['data'] + self.status = result['status'] + self.total_count = result.get('totalCount', None) + self.next = result.get('next', None) + self.prev = result.get('prev', None) + + def __str__(self): + return "Update update members success with data: %s" % self.data From 403d5165576d4cd4f8fa2039c73c5bef59474fea Mon Sep 17 00:00:00 2001 From: QSD_z Date: Tue, 30 Jul 2019 20:12:19 +0200 Subject: [PATCH 14/26] Write tests for get_members and get_space_memberships endpoints. --- pubnub/endpoints/membership/__init__.py | 0 pubnub/endpoints/membership/get_members.py | 100 ++++++++++++++++++ .../membership/get_space_memberships.py | 100 ++++++++++++++++++ pubnub/pubnub_core.py | 8 ++ tests/functional/membership/__init__.py | 0 .../functional/membership/test_get_members.py | 37 +++++++ .../membership/test_get_space_memberships.py | 37 +++++++ .../integrational/asyncio/test_membership.py | 48 +++++++++ .../fixtures/asyncio/members/get_members.yaml | 49 +++++++++ .../members/get_space_memberships.yaml | 46 ++++++++ .../native_sync/members/get_members.yaml | 51 +++++++++ .../members/get_space_memberships.yaml | 48 +++++++++ .../fixtures/tornado/members/get_members.yaml | 55 ++++++++++ .../members/get_space_memberships.yaml | 52 +++++++++ .../native_sync/test_membership.py | 44 ++++++++ .../integrational/tornado/test_membership.py | 53 ++++++++++ 16 files changed, 728 insertions(+) create mode 100644 pubnub/endpoints/membership/__init__.py create mode 100644 pubnub/endpoints/membership/get_members.py create mode 100644 pubnub/endpoints/membership/get_space_memberships.py create mode 100644 tests/functional/membership/__init__.py create mode 100644 tests/functional/membership/test_get_members.py create mode 100644 tests/functional/membership/test_get_space_memberships.py create mode 100644 tests/integrational/asyncio/test_membership.py create mode 100644 tests/integrational/fixtures/asyncio/members/get_members.yaml create mode 100644 tests/integrational/fixtures/asyncio/members/get_space_memberships.yaml create mode 100644 tests/integrational/fixtures/native_sync/members/get_members.yaml create mode 100644 tests/integrational/fixtures/native_sync/members/get_space_memberships.yaml create mode 100644 tests/integrational/fixtures/tornado/members/get_members.yaml create mode 100644 tests/integrational/fixtures/tornado/members/get_space_memberships.yaml create mode 100644 tests/integrational/native_sync/test_membership.py create mode 100644 tests/integrational/tornado/test_membership.py diff --git a/pubnub/endpoints/membership/__init__.py b/pubnub/endpoints/membership/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pubnub/endpoints/membership/get_members.py b/pubnub/endpoints/membership/get_members.py new file mode 100644 index 00000000..8cec54e2 --- /dev/null +++ b/pubnub/endpoints/membership/get_members.py @@ -0,0 +1,100 @@ +import six + +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.membership import PNGetMembersResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class GetMembers(Endpoint): + GET_MEMBERS_PATH = '/v1/objects/%s/spaces/%s/users' + MAX_LIMIT = 100 + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._start = None + self._end = None + self._limit = GetMembers.MAX_LIMIT + self._count = False + self._include = None + self._space_id = None + + def space_id(self, space_id): + assert isinstance(space_id, six.string_types) + self._space_id = space_id + return self + + def start(self, start): + assert isinstance(start, six.string_types) + self._start = start + return self + + def end(self, end): + assert isinstance(end, six.string_types) + self._end = end + return self + + def limit(self, limit): + assert isinstance(limit, six.integer_types) + self._limit = limit + return self + + def count(self, count): + self._count = bool(count) + return self + + def include(self, data): + self._include = data + return self + + def custom_params(self): + params = {} + + if self._start is not None: + params['start'] = self._start + + if self._end is not None and self._start is None: + params['end'] = self._end + + if self._count is True: + params['count'] = True + + if self._limit != GetMembers.MAX_LIMIT: + params['limit'] = self._limit + + if self._include: + params['include'] = utils.url_write(self._include) + + return params + + def build_path(self): + if self._space_id is None: + raise PubNubException('Provide space_id.') + return GetMembers.GET_MEMBERS_PATH % (self.pubnub.config.subscribe_key, self._space_id) + + def http_method(self): + return HttpMethod.GET + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + if self._space_id is None: + raise PubNubException('Provide space_id.') + + def create_response(self, envelope): # pylint: disable=W0221 + return PNGetMembersResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNGetMembersOperation + + def name(self): + return 'Get members' diff --git a/pubnub/endpoints/membership/get_space_memberships.py b/pubnub/endpoints/membership/get_space_memberships.py new file mode 100644 index 00000000..1c94432a --- /dev/null +++ b/pubnub/endpoints/membership/get_space_memberships.py @@ -0,0 +1,100 @@ +import six + +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.membership import PNGetSpaceMembershipsResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class GetSpaceMemberships(Endpoint): + GET_SPACE_MEMBERSHIPS_PATH = '/v1/objects/%s/users/%s/spaces' + MAX_LIMIT = 100 + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._start = None + self._end = None + self._limit = GetSpaceMemberships.MAX_LIMIT + self._count = False + self._include = None + self._user_id = None + + def user_id(self, user_id): + assert isinstance(user_id, six.string_types) + self._user_id = user_id + return self + + def start(self, start): + assert isinstance(start, six.string_types) + self._start = start + return self + + def end(self, end): + assert isinstance(end, six.string_types) + self._end = end + return self + + def limit(self, limit): + assert isinstance(limit, six.integer_types) + self._limit = limit + return self + + def count(self, count): + self._count = bool(count) + return self + + def include(self, data): + self._include = data + return self + + def custom_params(self): + params = {} + + if self._start is not None: + params['start'] = self._start + + if self._end is not None and self._start is None: + params['end'] = self._end + + if self._count is True: + params['count'] = True + + if self._limit != GetSpaceMemberships.MAX_LIMIT: + params['limit'] = self._limit + + if self._include: + params['include'] = utils.url_write(self._include) + + return params + + def build_path(self): + if self._user_id is None: + raise PubNubException('Provide user_id.') + return GetSpaceMemberships.GET_SPACE_MEMBERSHIPS_PATH % (self.pubnub.config.subscribe_key, self._user_id) + + def http_method(self): + return HttpMethod.GET + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + if self._user_id is None: + raise PubNubException('Provide user_id.') + + def create_response(self, envelope): # pylint: disable=W0221 + return PNGetSpaceMembershipsResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNGetSpaceMembershipsOperation + + def name(self): + return 'Get space membership' diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index 331a7a1e..b331d74a 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -35,6 +35,8 @@ from .endpoints.space.update_space import UpdateSpace from .endpoints.space.delete_space import DeleteSpace from .endpoints.space.create_space import CreateSpace +from .endpoints.membership.get_space_memberships import GetSpaceMemberships +from .endpoints.membership.get_members import GetMembers from .endpoints.push.add_channels_to_push import AddChannelsToPush from .endpoints.push.remove_channels_from_push import RemoveChannelsFromPush @@ -209,6 +211,12 @@ def delete_space(self): def create_space(self): return CreateSpace(self) + def get_space_memberships(self): + return GetSpaceMemberships(self) + + def get_members(self): + return GetMembers(self) + def time(self): return Time(self) diff --git a/tests/functional/membership/__init__.py b/tests/functional/membership/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/functional/membership/test_get_members.py b/tests/functional/membership/test_get_members.py new file mode 100644 index 00000000..5bfaeba6 --- /dev/null +++ b/tests/functional/membership/test_get_members.py @@ -0,0 +1,37 @@ +import pytest +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.membership.get_members import GetMembers +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_get_members(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + membership = PubNub(config).get_members() + membership.include(['a', 'b']).limit(30).end('XXX') + + with pytest.raises(PubNubException): + membership.validate_params() + + membership.space_id('foo') + assert membership.build_path() == GetMembers.GET_MEMBERS_PATH % (SUB_KEY, 'foo') + + params = membership.custom_params() + assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' + assert params['limit'] == 30 + assert params['end'] == 'XXX' + assert 'count' not in params + + membership.start('YYY').count(True) + params = membership.custom_params() + assert 'end' not in params + assert params['start'] == 'YYY' + assert params['count'] is True + + assert AUTH == membership.build_params_callback()({})['auth'] diff --git a/tests/functional/membership/test_get_space_memberships.py b/tests/functional/membership/test_get_space_memberships.py new file mode 100644 index 00000000..5e99d8ea --- /dev/null +++ b/tests/functional/membership/test_get_space_memberships.py @@ -0,0 +1,37 @@ +import pytest +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.membership.get_space_memberships import GetSpaceMemberships +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_get_space_memberships(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + membership = PubNub(config).get_space_memberships() + membership.include(['a', 'b']).limit(30).end('XXX') + + with pytest.raises(PubNubException): + membership.validate_params() + + membership.user_id('foo') + assert membership.build_path() == GetSpaceMemberships.GET_SPACE_MEMBERSHIPS_PATH % (SUB_KEY, 'foo') + + params = membership.custom_params() + assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' + assert params['limit'] == 30 + assert params['end'] == 'XXX' + assert 'count' not in params + + membership.start('YYY').count(True) + params = membership.custom_params() + assert 'end' not in params + assert params['start'] == 'YYY' + assert params['count'] is True + + assert AUTH == membership.build_params_callback()({})['auth'] diff --git a/tests/integrational/asyncio/test_membership.py b/tests/integrational/asyncio/test_membership.py new file mode 100644 index 00000000..80cfdcb6 --- /dev/null +++ b/tests/integrational/asyncio/test_membership.py @@ -0,0 +1,48 @@ +import pytest + +from tests.helper import pnconf_copy +from tests.integrational.vcr_helper import pn_vcr +from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope +from pubnub.models.consumer.membership import PNGetMembersResult, PNGetSpaceMembershipsResult +from pubnub.models.consumer.common import PNStatus + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/members/get_members.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_get_members(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + envelope = yield from pn.get_members().space_id('main').limit(10).count(True).include(['custom', 'user']).future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetMembersResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) + assert data[0]['user']['id'] == 'user-1' + assert data[0]['user']['name'] == 'John Doe' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/members/get_space_memberships.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_get_space_memberships(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + envelope = yield from pn.get_space_memberships().user_id('charlie').limit(10).count(True)\ + .include(['custom', 'space']).future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetSpaceMembershipsResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) + assert data[0]['space']['id'] == 'my-channel' + assert data[0]['space']['name'] == 'My space' diff --git a/tests/integrational/fixtures/asyncio/members/get_members.yaml b/tests/integrational/fixtures/asyncio/members/get_members.yaml new file mode 100644 index 00000000..74df0e11 --- /dev/null +++ b/tests/integrational/fixtures/asyncio/members/get_members.yaml @@ -0,0 +1,49 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%5B%22custom%22%2C+%22user%22%5D&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ + : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ + : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ + user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ + custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ + ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ + profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ + \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ + eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ + id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ + \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ + \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ + \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ + ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ + \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 37\n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '1455' + Content-Type: application/json + Date: Tue, 30 Jul 2019 17:50:13 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users + - count=True&limit=10&include=%5B%22custom%22%2C%20%22user%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=713958cb-3b66-4a19-a481-7917e100224e + - '' +version: 1 diff --git a/tests/integrational/fixtures/asyncio/members/get_space_memberships.yaml b/tests/integrational/fixtures/asyncio/members/get_space_memberships.yaml new file mode 100644 index 00000000..ac61166a --- /dev/null +++ b/tests/integrational/fixtures/asyncio/members/get_space_memberships.yaml @@ -0,0 +1,46 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%5B%22custom%22%2C+%22space%22%5D&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ + : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ + : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ + RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ + my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ + \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ + \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ + : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ + ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ + ,\n \"public\": true\n },\n \"description\": \"The\ + \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ + updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ + 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 7\n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '1378' + Content-Type: application/json + Date: Tue, 30 Jul 2019 17:50:13 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces + - count=True&limit=10&include=%5B%22custom%22%2C%20%22space%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=2b8c9d19-2de7-468d-bdac-ce4ed6048f0e + - '' +version: 1 diff --git a/tests/integrational/fixtures/native_sync/members/get_members.yaml b/tests/integrational/fixtures/native_sync/members/get_members.yaml new file mode 100644 index 00000000..08e13819 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/members/get_members.yaml @@ -0,0 +1,51 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - PubNub-Python/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%5B%22custom%22%2C+%22user%22%5D&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ + : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ + : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ + user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ + custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ + ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ + profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ + \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ + eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ + id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ + \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ + \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ + \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ + ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ + \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 37\n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '1455' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2019 17:47:01 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/native_sync/members/get_space_memberships.yaml b/tests/integrational/fixtures/native_sync/members/get_space_memberships.yaml new file mode 100644 index 00000000..9e9e812a --- /dev/null +++ b/tests/integrational/fixtures/native_sync/members/get_space_memberships.yaml @@ -0,0 +1,48 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - PubNub-Python/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%5B%22custom%22%2C+%22space%22%5D&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ + : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ + : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ + RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ + my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ + \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ + \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ + : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ + ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ + ,\n \"public\": true\n },\n \"description\": \"The\ + \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ + updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ + 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 7\n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '1378' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2019 17:47:01 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/tornado/members/get_members.yaml b/tests/integrational/fixtures/tornado/members/get_members.yaml new file mode 100644 index 00000000..deb1f180 --- /dev/null +++ b/tests/integrational/fixtures/tornado/members/get_members.yaml @@ -0,0 +1,55 @@ +interactions: +- request: + body: null + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%5B%22custom%22%2C+%22user%22%5D&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ + : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ + : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ + user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ + custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ + ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ + profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ + \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ + eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ + id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ + \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ + \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ + \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ + ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ + \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 37\n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Tue, 30 Jul 2019 17:57:24 GMT + - !!python/tuple + - Content-Length + - - '1455' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&limit=10&include=%5B%22custom%22%2C%20%22user%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=fad8dc01-8290-4739-888d-97526afbefb2 +version: 1 diff --git a/tests/integrational/fixtures/tornado/members/get_space_memberships.yaml b/tests/integrational/fixtures/tornado/members/get_space_memberships.yaml new file mode 100644 index 00000000..9377b788 --- /dev/null +++ b/tests/integrational/fixtures/tornado/members/get_space_memberships.yaml @@ -0,0 +1,52 @@ +interactions: +- request: + body: null + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: GET + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%5B%22custom%22%2C+%22space%22%5D&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ + : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ + : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ + RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ + my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ + \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ + \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ + : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ + ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ + ,\n \"public\": true\n },\n \"description\": \"The\ + \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ + updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ + 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 7\n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Tue, 30 Jul 2019 17:57:24 GMT + - !!python/tuple + - Content-Length + - - '1378' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&limit=10&include=%5B%22custom%22%2C%20%22space%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=d7e7d41e-ba3d-4e4d-895b-8de8e4dbeb1a +version: 1 diff --git a/tests/integrational/native_sync/test_membership.py b/tests/integrational/native_sync/test_membership.py new file mode 100644 index 00000000..4e5d4267 --- /dev/null +++ b/tests/integrational/native_sync/test_membership.py @@ -0,0 +1,44 @@ +from tests.helper import pnconf_copy +from tests.integrational.vcr_helper import pn_vcr +from pubnub.structures import Envelope +from pubnub.pubnub import PubNub +from pubnub.models.consumer.membership import PNGetMembersResult, PNGetSpaceMembershipsResult +from pubnub.models.consumer.common import PNStatus + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/members/get_members.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_get_members(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.get_members().space_id('main').limit(10).count(True).include(['custom', 'user']).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetMembersResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) + assert data[0]['user']['id'] == 'user-1' + assert data[0]['user']['name'] == 'John Doe' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/members/get_space_memberships.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_get_space_memberships(): + config = pnconf_copy() + pn = PubNub(config) + envelope = pn.get_space_memberships().user_id('charlie').limit(10).count(True).include(['custom', 'space']).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetSpaceMembershipsResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) + assert data[0]['space']['id'] == 'my-channel' + assert data[0]['space']['name'] == 'My space' diff --git a/tests/integrational/tornado/test_membership.py b/tests/integrational/tornado/test_membership.py new file mode 100644 index 00000000..1b30fd82 --- /dev/null +++ b/tests/integrational/tornado/test_membership.py @@ -0,0 +1,53 @@ +import tornado +from tornado.testing import AsyncTestCase + +from pubnub.pubnub_tornado import PubNubTornado, TornadoEnvelope +from pubnub.models.consumer.membership import PNGetMembersResult, PNGetSpaceMembershipsResult +from pubnub.models.consumer.common import PNStatus +from tests.helper import pnconf_copy +from tests.integrational.vcr_helper import pn_vcr + + +class TestUser(AsyncTestCase): + def setUp(self): + AsyncTestCase.setUp(self) + config = pnconf_copy() + self.pn = PubNubTornado(config, custom_ioloop=self.io_loop) + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/members/get_members.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_get_members(self): + envelope = yield self.pn.get_members().space_id('main').limit(10).count(True)\ + .include(['custom', 'user']).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetMembersResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) + assert data[0]['user']['id'] == 'user-1' + assert data[0]['user']['name'] == 'John Doe' + self.pn.stop() + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/members/get_space_memberships.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_get_space_memberships(self): + envelope = yield self.pn.get_space_memberships().user_id('charlie').limit(10).count(True)\ + .include(['custom', 'space']).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNGetSpaceMembershipsResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) + assert data[0]['space']['id'] == 'my-channel' + assert data[0]['space']['name'] == 'My space' + self.pn.stop() From 9fd713a2209bf3465f3822b9ae875180daf1fae7 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sun, 4 Aug 2019 00:42:44 +0200 Subject: [PATCH 15/26] Implement and test UpdateMembers and UpdateSpaceMemberships endpoints. --- pubnub/endpoints/membership/update_members.py | 110 ++++++++++++++++++ .../membership/update_space_memberships.py | 110 ++++++++++++++++++ pubnub/pubnub_core.py | 8 ++ .../membership/test_update_members.py | 39 +++++++ .../test_update_space_memberships.py | 39 +++++++ .../integrational/asyncio/test_membership.py | 85 +++++++++++++- .../asyncio/members/update_members.yaml | 50 ++++++++ .../members/update_space_memberships.yaml | 47 ++++++++ .../native_sync/members/update_members.yaml | 53 +++++++++ .../members/update_space_memberships.yaml | 50 ++++++++ .../tornado/members/update_members.yaml | 56 +++++++++ .../members/update_space_memberships.yaml | 53 +++++++++ .../native_sync/test_membership.py | 82 ++++++++++++- .../integrational/tornado/test_membership.py | 81 ++++++++++++- 14 files changed, 860 insertions(+), 3 deletions(-) create mode 100644 pubnub/endpoints/membership/update_members.py create mode 100644 pubnub/endpoints/membership/update_space_memberships.py create mode 100644 tests/functional/membership/test_update_members.py create mode 100644 tests/functional/membership/test_update_space_memberships.py create mode 100644 tests/integrational/fixtures/asyncio/members/update_members.yaml create mode 100644 tests/integrational/fixtures/asyncio/members/update_space_memberships.yaml create mode 100644 tests/integrational/fixtures/native_sync/members/update_members.yaml create mode 100644 tests/integrational/fixtures/native_sync/members/update_space_memberships.yaml create mode 100644 tests/integrational/fixtures/tornado/members/update_members.yaml create mode 100644 tests/integrational/fixtures/tornado/members/update_space_memberships.yaml diff --git a/pubnub/endpoints/membership/update_members.py b/pubnub/endpoints/membership/update_members.py new file mode 100644 index 00000000..ab76be0f --- /dev/null +++ b/pubnub/endpoints/membership/update_members.py @@ -0,0 +1,110 @@ +import six + +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.membership import PNUpdateMembersResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class UpdateMembers(Endpoint): + UPDATE_MEMBERS_PATH = '/v1/objects/%s/spaces/%s/users' + MAX_LIMIT = 100 + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._start = None + self._end = None + self._limit = UpdateMembers.MAX_LIMIT + self._count = False + self._include = None + self._space_id = None + self._data = None + + def space_id(self, space_id): + assert isinstance(space_id, six.string_types) + self._space_id = space_id + return self + + def start(self, start): + assert isinstance(start, six.string_types) + self._start = start + return self + + def end(self, end): + assert isinstance(end, six.string_types) + self._end = end + return self + + def limit(self, limit): + assert isinstance(limit, six.integer_types) + self._limit = limit + return self + + def count(self, count): + self._count = bool(count) + return self + + def include(self, data): + self._include = data + return self + + def data(self, data): + assert isinstance(data, dict) + self._data = data + return self + + def build_data(self): + if self._data is not None: + return utils.write_value_as_string(self._data) + + def custom_params(self): + params = {} + + if self._start is not None: + params['start'] = self._start + + if self._end is not None and self._start is None: + params['end'] = self._end + + if self._count is True: + params['count'] = True + + if self._limit != UpdateMembers.MAX_LIMIT: + params['limit'] = self._limit + + if self._include: + params['include'] = utils.url_write(self._include) + + return params + + def build_path(self): + if self._space_id is None: + raise PubNubException('Provide space_id.') + return UpdateMembers.UPDATE_MEMBERS_PATH % (self.pubnub.config.subscribe_key, self._space_id) + + def http_method(self): + return HttpMethod.PATCH + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + if self._space_id is None: + raise PubNubException('Provide space_id.') + + def create_response(self, envelope): # pylint: disable=W0221 + return PNUpdateMembersResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNUpdateMembersOperation + + def name(self): + return 'Update members' diff --git a/pubnub/endpoints/membership/update_space_memberships.py b/pubnub/endpoints/membership/update_space_memberships.py new file mode 100644 index 00000000..b91badf0 --- /dev/null +++ b/pubnub/endpoints/membership/update_space_memberships.py @@ -0,0 +1,110 @@ +import six + +from pubnub import utils +from pubnub.endpoints.endpoint import Endpoint +from pubnub.models.consumer.membership import PNUpdateSpaceMembershipsResult +from pubnub.enums import HttpMethod, PNOperationType +from pubnub.exceptions import PubNubException + + +class UpdateSpaceMemberships(Endpoint): + UPDATE_SPACE_MEMBERSHIPS_PATH = '/v1/objects/%s/users/%s/spaces' + MAX_LIMIT = 100 + + def __init__(self, pubnub): + Endpoint.__init__(self, pubnub) + self._start = None + self._end = None + self._limit = UpdateSpaceMemberships.MAX_LIMIT + self._count = False + self._include = None + self._user_id = None + self._data = None + + def user_id(self, user_id): + assert isinstance(user_id, six.string_types) + self._user_id = user_id + return self + + def start(self, start): + assert isinstance(start, six.string_types) + self._start = start + return self + + def end(self, end): + assert isinstance(end, six.string_types) + self._end = end + return self + + def limit(self, limit): + assert isinstance(limit, six.integer_types) + self._limit = limit + return self + + def count(self, count): + self._count = bool(count) + return self + + def include(self, data): + self._include = data + return self + + def data(self, data): + assert isinstance(data, dict) + self._data = data + return self + + def build_data(self): + if self._data is not None: + return utils.write_value_as_string(self._data) + + def custom_params(self): + params = {} + + if self._start is not None: + params['start'] = self._start + + if self._end is not None and self._start is None: + params['end'] = self._end + + if self._count is True: + params['count'] = True + + if self._limit != UpdateSpaceMemberships.MAX_LIMIT: + params['limit'] = self._limit + + if self._include: + params['include'] = utils.url_write(self._include) + + return params + + def build_path(self): + if self._user_id is None: + raise PubNubException('Provide user_id.') + return UpdateSpaceMemberships.UPDATE_SPACE_MEMBERSHIPS_PATH % (self.pubnub.config.subscribe_key, self._user_id) + + def http_method(self): + return HttpMethod.PATCH + + def is_auth_required(self): + return True + + def validate_params(self): + self.validate_subscribe_key() + if self._user_id is None: + raise PubNubException('Provide user_id.') + + def create_response(self, envelope): # pylint: disable=W0221 + return PNUpdateSpaceMembershipsResult(envelope) + + def request_timeout(self): + return self.pubnub.config.non_subscribe_request_timeout + + def connect_timeout(self): + return self.pubnub.config.connect_timeout + + def operation_type(self): + return PNOperationType.PNUpdateSpaceMembershipsOperation + + def name(self): + return 'Update space memberships' diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index b331d74a..5d9088ee 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -37,6 +37,8 @@ from .endpoints.space.create_space import CreateSpace from .endpoints.membership.get_space_memberships import GetSpaceMemberships from .endpoints.membership.get_members import GetMembers +from .endpoints.membership.update_members import UpdateMembers +from .endpoints.membership.update_space_memberships import UpdateSpaceMemberships from .endpoints.push.add_channels_to_push import AddChannelsToPush from .endpoints.push.remove_channels_from_push import RemoveChannelsFromPush @@ -217,6 +219,12 @@ def get_space_memberships(self): def get_members(self): return GetMembers(self) + def update_members(self): + return UpdateMembers(self) + + def update_space_memberships(self): + return UpdateSpaceMemberships(self) + def time(self): return Time(self) diff --git a/tests/functional/membership/test_update_members.py b/tests/functional/membership/test_update_members.py new file mode 100644 index 00000000..8a3b868a --- /dev/null +++ b/tests/functional/membership/test_update_members.py @@ -0,0 +1,39 @@ +import pytest +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.membership.update_members import UpdateMembers +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_get_members(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + membership = PubNub(config).update_members() + membership.include('custom').limit(30).end('XXX') + + with pytest.raises(PubNubException): + membership.validate_params() + + membership.space_id('foo') + assert membership.build_path() == UpdateMembers.UPDATE_MEMBERS_PATH % (SUB_KEY, 'foo') + + params = membership.custom_params() + assert params['include'] == '%22custom%22' + assert params['limit'] == 30 + assert params['end'] == 'XXX' + assert 'count' not in params + + membership.start('YYY').count(True) + params = membership.custom_params() + assert 'end' not in params + assert params['start'] == 'YYY' + assert params['count'] is True + + assert AUTH == membership.build_params_callback()({})['auth'] + membership.data({'add': [{'id': 'user'}]}) + assert membership.build_data() == '{"add": [{"id": "user"}]}' diff --git a/tests/functional/membership/test_update_space_memberships.py b/tests/functional/membership/test_update_space_memberships.py new file mode 100644 index 00000000..3dbc25b5 --- /dev/null +++ b/tests/functional/membership/test_update_space_memberships.py @@ -0,0 +1,39 @@ +import pytest +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration +from pubnub.endpoints.membership.update_space_memberships import UpdateSpaceMemberships +from pubnub.exceptions import PubNubException + + +SUB_KEY = 'sub' +AUTH = 'auth' + + +def test_get_space_memberships(): + config = PNConfiguration() + config.subscribe_key = SUB_KEY + config.auth_key = AUTH + membership = PubNub(config).update_space_memberships() + membership.include('custom').limit(30).end('XXX') + + with pytest.raises(PubNubException): + membership.validate_params() + + membership.user_id('foo') + assert membership.build_path() == UpdateSpaceMemberships.UPDATE_SPACE_MEMBERSHIPS_PATH % (SUB_KEY, 'foo') + + params = membership.custom_params() + assert params['include'] == '%22custom%22' + assert params['limit'] == 30 + assert params['end'] == 'XXX' + assert 'count' not in params + + membership.start('YYY').count(True) + params = membership.custom_params() + assert 'end' not in params + assert params['start'] == 'YYY' + assert params['count'] is True + + assert AUTH == membership.build_params_callback()({})['auth'] + membership.data({"add": [{"id": "my-channel"}]}) + assert membership.build_data() == '{"add": [{"id": "my-channel"}]}' diff --git a/tests/integrational/asyncio/test_membership.py b/tests/integrational/asyncio/test_membership.py index 80cfdcb6..e4c3fa58 100644 --- a/tests/integrational/asyncio/test_membership.py +++ b/tests/integrational/asyncio/test_membership.py @@ -3,7 +3,8 @@ from tests.helper import pnconf_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope -from pubnub.models.consumer.membership import PNGetMembersResult, PNGetSpaceMembershipsResult +from pubnub.models.consumer.membership import (PNGetMembersResult, PNGetSpaceMembershipsResult, + PNUpdateMembersResult, PNUpdateSpaceMembershipsResult) from pubnub.models.consumer.common import PNStatus @@ -46,3 +47,85 @@ def test_get_space_memberships(event_loop): assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) assert data[0]['space']['id'] == 'my-channel' assert data[0]['space']['name'] == 'My space' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/members/update_space_memberships.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_update_space_memberships(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + data = { + "add": [ + { + "id": "my-channel" + } + ], + "update": [ + { + "id": "main", + "custom": { + "starred": True + } + } + ], + "remove": [ + { + "id": "space-0" + } + ] + } + envelope = yield from pn.update_space_memberships().user_id('charlie').limit(10).count(True)\ + .include('custom').data(data).future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateSpaceMembershipsResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) + assert data[0]['space']['id'] == 'my-channel' + assert data[0]['space']['name'] == 'My space' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/members/update_members.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +@pytest.mark.asyncio +def test_update_members(event_loop): + config = pnconf_copy() + pn = PubNubAsyncio(config, custom_event_loop=event_loop) + data = { + "add": [ + { + "id": "user-1" + } + ], + "update": [ + { + "id": "user-2", + "custom": { + "role": "moderator" + } + } + ], + "remove": [ + { + "id": "user-0" + } + ] + } + envelope = yield from pn.update_members().space_id('main').limit(10).count(True).include('custom')\ + .data(data).future() + + assert(isinstance(envelope, AsyncioEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateMembersResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) + assert data[0]['user']['id'] == 'user-1' + assert data[0]['user']['name'] == 'John Doe' diff --git a/tests/integrational/fixtures/asyncio/members/update_members.yaml b/tests/integrational/fixtures/asyncio/members/update_members.yaml new file mode 100644 index 00000000..d4721306 --- /dev/null +++ b/tests/integrational/fixtures/asyncio/members/update_members.yaml @@ -0,0 +1,50 @@ +interactions: +- request: + body: '{"add": [{"id": "user-1"}], "update": [{"id": "user-2", "custom": {"role": + "moderator"}}], "remove": [{"id": "user-0"}]}' + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%22custom%22&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ + : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ + : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ + user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ + custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ + ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ + profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ + \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ + eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ + id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ + \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ + \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ + \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ + ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ + \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 37\n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '1455' + Content-Type: application/json + Date: Sat, 03 Aug 2019 22:37:18 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users + - count=True&limit=10&include=%22custom%22&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=56f4731a-403f-4610-8224-ed8a69b3d512 + - '' +version: 1 diff --git a/tests/integrational/fixtures/asyncio/members/update_space_memberships.yaml b/tests/integrational/fixtures/asyncio/members/update_space_memberships.yaml new file mode 100644 index 00000000..e3d4fdf9 --- /dev/null +++ b/tests/integrational/fixtures/asyncio/members/update_space_memberships.yaml @@ -0,0 +1,47 @@ +interactions: +- request: + body: '{"add": [{"id": "my-channel"}], "update": [{"id": "main", "custom": {"starred": + true}}], "remove": [{"id": "space-0"}]}' + headers: + User-Agent: + - PubNub-Python-Asyncio/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%22custom%22&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ + : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ + : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ + RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ + my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ + \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ + \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ + : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ + ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ + ,\n \"public\": true\n },\n \"description\": \"The\ + \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ + updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ + 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 7\n}" + headers: + Access-Control-Allow-Origin: '*' + Content-Length: '1378' + Content-Type: application/json + Date: Sat, 03 Aug 2019 22:37:18 GMT + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - http + - ps.pndsn.com + - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces + - count=True&limit=10&include=%22custom%22&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=3ca7ed05-0507-4c58-8e1b-92d811ab9cb7 + - '' +version: 1 diff --git a/tests/integrational/fixtures/native_sync/members/update_members.yaml b/tests/integrational/fixtures/native_sync/members/update_members.yaml new file mode 100644 index 00000000..ee17a06b --- /dev/null +++ b/tests/integrational/fixtures/native_sync/members/update_members.yaml @@ -0,0 +1,53 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - PubNub-Python/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%22custom%22&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ + : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ + : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ + user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ + custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ + ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ + profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ + \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ + eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ + id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ + \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ + \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ + \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ + ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ + \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 37\n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '1455' + Content-Type: + - application/json + Date: + - Sat, 03 Aug 2019 22:33:56 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/native_sync/members/update_space_memberships.yaml b/tests/integrational/fixtures/native_sync/members/update_space_memberships.yaml new file mode 100644 index 00000000..2dc8f81d --- /dev/null +++ b/tests/integrational/fixtures/native_sync/members/update_space_memberships.yaml @@ -0,0 +1,50 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - PubNub-Python/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%22custom%22&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ + : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ + : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ + RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ + my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ + \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ + \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ + : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ + ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ + ,\n \"public\": true\n },\n \"description\": \"The\ + \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ + updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ + 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 7\n}" + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '1378' + Content-Type: + - application/json + Date: + - Sat, 03 Aug 2019 22:33:56 GMT + status: + code: 200 + message: OK +version: 1 diff --git a/tests/integrational/fixtures/tornado/members/update_members.yaml b/tests/integrational/fixtures/tornado/members/update_members.yaml new file mode 100644 index 00000000..5345c3bb --- /dev/null +++ b/tests/integrational/fixtures/tornado/members/update_members.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: '{"add": [{"id": "user-1"}], "update": [{"id": "user-2", "custom": {"role": + "moderator"}}], "remove": [{"id": "user-0"}]}' + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%22custom%22&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ + : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ + : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ + user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ + custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ + ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ + profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ + \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ + eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ + id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ + \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ + \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ + \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ + ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ + \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ + : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ + \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 37\n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Sat, 03 Aug 2019 22:40:12 GMT + - !!python/tuple + - Content-Length + - - '1455' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&limit=10&include=%22custom%22&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=0dc26bd2-433d-466c-a839-32f0e7330420 +version: 1 diff --git a/tests/integrational/fixtures/tornado/members/update_space_memberships.yaml b/tests/integrational/fixtures/tornado/members/update_space_memberships.yaml new file mode 100644 index 00000000..4c66ffc9 --- /dev/null +++ b/tests/integrational/fixtures/tornado/members/update_space_memberships.yaml @@ -0,0 +1,53 @@ +interactions: +- request: + body: '{"add": [{"id": "my-channel"}], "update": [{"id": "main", "custom": {"starred": + true}}], "remove": [{"id": "space-0"}]}' + headers: + Accept-Encoding: + - utf-8 + User-Agent: + - PubNub-Python-Tornado/4.1.0 + method: PATCH + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%22custom%22&limit=10 + response: + body: + string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ + : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ + : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ + RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ + my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ + \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ + \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ + : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ + ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ + ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ + ,\n \"public\": true\n },\n \"description\": \"The\ + \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ + ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ + updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ + 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ + ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ + \ \"status\": 200,\n \"totalCount\": 7\n}" + headers: + - !!python/tuple + - Access-Control-Allow-Origin + - - '*' + - !!python/tuple + - Content-Type + - - application/json + - !!python/tuple + - Date + - - Sat, 03 Aug 2019 22:40:12 GMT + - !!python/tuple + - Content-Length + - - '1378' + - !!python/tuple + - Connection + - - close + status: + code: 200 + message: OK + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&limit=10&include=%22custom%22&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=07c69db6-bf20-4017-aa6e-bd51f96bfb22 +version: 1 diff --git a/tests/integrational/native_sync/test_membership.py b/tests/integrational/native_sync/test_membership.py index 4e5d4267..e56af284 100644 --- a/tests/integrational/native_sync/test_membership.py +++ b/tests/integrational/native_sync/test_membership.py @@ -2,7 +2,8 @@ from tests.integrational.vcr_helper import pn_vcr from pubnub.structures import Envelope from pubnub.pubnub import PubNub -from pubnub.models.consumer.membership import PNGetMembersResult, PNGetSpaceMembershipsResult +from pubnub.models.consumer.membership import (PNGetMembersResult, PNGetSpaceMembershipsResult, + PNUpdateSpaceMembershipsResult, PNUpdateMembersResult) from pubnub.models.consumer.common import PNStatus @@ -42,3 +43,82 @@ def test_get_space_memberships(): assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) assert data[0]['space']['id'] == 'my-channel' assert data[0]['space']['name'] == 'My space' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/members/update_space_memberships.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_update_space_memberships(): + config = pnconf_copy() + pn = PubNub(config) + data = { + "add": [ + { + "id": "my-channel" + } + ], + "update": [ + { + "id": "main", + "custom": { + "starred": True + } + } + ], + "remove": [ + { + "id": "space-0" + } + ] + } + envelope = pn.update_space_memberships().user_id('charlie').limit(10).count(True)\ + .include('custom').data(data).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateSpaceMembershipsResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) + assert data[0]['space']['id'] == 'my-channel' + assert data[0]['space']['name'] == 'My space' + + +@pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/members/update_members.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) +def test_update_members(): + config = pnconf_copy() + pn = PubNub(config) + data = { + "add": [ + { + "id": "user-1" + } + ], + "update": [ + { + "id": "user-2", + "custom": { + "role": "moderator" + } + } + ], + "remove": [ + { + "id": "user-0" + } + ] + } + envelope = pn.update_members().space_id('main').limit(10).count(True).include('custom').data(data).sync() + + assert(isinstance(envelope, Envelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateMembersResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) + assert data[0]['user']['id'] == 'user-1' + assert data[0]['user']['name'] == 'John Doe' diff --git a/tests/integrational/tornado/test_membership.py b/tests/integrational/tornado/test_membership.py index 1b30fd82..c63b3a4e 100644 --- a/tests/integrational/tornado/test_membership.py +++ b/tests/integrational/tornado/test_membership.py @@ -2,7 +2,8 @@ from tornado.testing import AsyncTestCase from pubnub.pubnub_tornado import PubNubTornado, TornadoEnvelope -from pubnub.models.consumer.membership import PNGetMembersResult, PNGetSpaceMembershipsResult +from pubnub.models.consumer.membership import (PNGetMembersResult, PNGetSpaceMembershipsResult, + PNUpdateSpaceMembershipsResult, PNUpdateMembersResult) from pubnub.models.consumer.common import PNStatus from tests.helper import pnconf_copy from tests.integrational.vcr_helper import pn_vcr @@ -51,3 +52,81 @@ def test_get_space_memberships(self): assert data[0]['space']['id'] == 'my-channel' assert data[0]['space']['name'] == 'My space' self.pn.stop() + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/members/update_space_memberships.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_update_space_memberships(self): + data = { + "add": [ + { + "id": "my-channel" + } + ], + "update": [ + { + "id": "main", + "custom": { + "starred": True + } + } + ], + "remove": [ + { + "id": "space-0" + } + ] + } + envelope = yield self.pn.update_space_memberships().user_id('charlie').limit(10).count(True)\ + .include('custom').data(data).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateSpaceMembershipsResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) + assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) + assert data[0]['space']['id'] == 'my-channel' + assert data[0]['space']['name'] == 'My space' + self.pn.stop() + + @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/members/update_members.yaml', + filter_query_parameters=['uuid', 'seqn', 'pnsdk']) + @tornado.testing.gen_test + def test_update_members(self): + data = { + "add": [ + { + "id": "user-1" + } + ], + "update": [ + { + "id": "user-2", + "custom": { + "role": "moderator" + } + } + ], + "remove": [ + { + "id": "user-0" + } + ] + } + envelope = yield self.pn.update_members().space_id('main').limit(10).count(True).include('custom')\ + .data(data).future() + + assert(isinstance(envelope, TornadoEnvelope)) + assert not envelope.status.is_error() + assert isinstance(envelope.result, PNUpdateMembersResult) + assert isinstance(envelope.status, PNStatus) + data = envelope.result.data + assert len(data) == 2 + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) + assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) + assert data[0]['user']['id'] == 'user-1' + assert data[0]['user']['name'] == 'John Doe' + self.pn.stop() From 6bc50b8c4a68a00cb38a262d2258ba6d92b381c0 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sun, 4 Aug 2019 19:48:32 +0200 Subject: [PATCH 16/26] Correctly use include URL parameter. --- pubnub/endpoints/space/create_space.py | 20 ++++++++++++----- pubnub/endpoints/space/update_space.py | 18 ++++++++++----- pubnub/endpoints/users/create_user.py | 22 ++++++++++++++----- pubnub/endpoints/users/update_user.py | 18 ++++++++++----- tests/functional/spaces/test_create_space.py | 7 +++++- tests/functional/spaces/test_update_space.py | 7 ++++-- tests/functional/users/test_create_user.py | 7 +++++- tests/functional/users/test_update_user.py | 7 ++++-- tests/integrational/asyncio/test_space.py | 14 +++++------- tests/integrational/asyncio/test_user.py | 14 +++++------- .../fixtures/asyncio/space/get_space.yaml | 10 ++++----- .../fixtures/asyncio/space/get_spaces.yaml | 10 ++++----- .../fixtures/asyncio/user/fetch_user.yaml | 11 +++++----- .../fixtures/asyncio/user/users_get.yaml | 10 ++++----- .../fixtures/native_sync/space/get_space.yaml | 8 +++---- .../native_sync/space/get_spaces.yaml | 8 +++---- .../fixtures/native_sync/user/fetch_user.yaml | 9 ++++---- .../fixtures/native_sync/user/users_get.yaml | 8 +++---- .../fixtures/tornado/space/get_space.yaml | 10 ++++----- .../fixtures/tornado/space/get_spaces.yaml | 10 ++++----- .../fixtures/tornado/user/fetch_user.yaml | 11 +++++----- .../fixtures/tornado/user/users_get.yaml | 10 ++++----- tests/integrational/native_sync/test_space.py | 13 +++++------ tests/integrational/native_sync/test_user.py | 16 ++++++-------- tests/integrational/tornado/test_space.py | 13 +++++------ tests/integrational/tornado/test_user.py | 14 +++++------- 26 files changed, 172 insertions(+), 133 deletions(-) diff --git a/pubnub/endpoints/space/create_space.py b/pubnub/endpoints/space/create_space.py index f8bbfa37..049fbc94 100644 --- a/pubnub/endpoints/space/create_space.py +++ b/pubnub/endpoints/space/create_space.py @@ -11,22 +11,32 @@ class CreateSpace(Endpoint): def __init__(self, pubnub): Endpoint.__init__(self, pubnub) self._include = {} + self._data = None def include(self, data): - assert isinstance(data, dict) self._include = data return self + def data(self, data): + assert isinstance(data, dict) + if 'id' not in data or 'name' not in data: + raise PubNubException("Space's id or name missing.") + self._data = data + return self + def custom_params(self): - return {} + params = {} + if self._include: + params['include'] = utils.url_write(self._include) + return params def build_data(self): - return utils.write_value_as_string(self._include) + return utils.write_value_as_string(self._data) def validate_params(self): self.validate_subscribe_key() - if 'id' not in self._include or 'name' not in self._include: - raise PubNubException('"id" or "name" not found in include data.') + if self._data is None: + raise PubNubException('No data supplied.') def build_path(self): return CreateSpace.CREATE_SPACE_PATH % (self.pubnub.config.subscribe_key) diff --git a/pubnub/endpoints/space/update_space.py b/pubnub/endpoints/space/update_space.py index 14145e61..4d72db1d 100644 --- a/pubnub/endpoints/space/update_space.py +++ b/pubnub/endpoints/space/update_space.py @@ -14,24 +14,30 @@ def __init__(self, pubnub): Endpoint.__init__(self, pubnub) self._space_id = None self._include = None + self._data = None def space_id(self, space_id): assert isinstance(space_id, six.string_types) self._space_id = space_id return self - def include(self, data): + def data(self, data): assert isinstance(data, dict) + self._data = data + return self + + def include(self, data): self._include = data return self def custom_params(self): - return {} + params = {} + if self._include: + params['include'] = utils.url_write(self._include) + return params def build_data(self): - if self._include: - return utils.write_value_as_string(self._include) - return '' + return utils.write_value_as_string(self._data) def build_path(self): if self._space_id is None: @@ -46,6 +52,8 @@ def is_auth_required(self): def validate_params(self): self.validate_subscribe_key() + if self._data is None: + raise PubNubException('No data supplied.') def create_response(self, envelope): # pylint: disable=W0221 return PNUpdateSpaceResult(envelope) diff --git a/pubnub/endpoints/users/create_user.py b/pubnub/endpoints/users/create_user.py index 6abe16c0..8a321773 100644 --- a/pubnub/endpoints/users/create_user.py +++ b/pubnub/endpoints/users/create_user.py @@ -10,23 +10,33 @@ class CreateUser(Endpoint): def __init__(self, pubnub): Endpoint.__init__(self, pubnub) - self._include = {} + self._include = None + self._data = None def include(self, data): - assert isinstance(data, dict) self._include = data return self def custom_params(self): - return {} + params = {} + if self._include: + params['include'] = utils.url_write(self._include) + return params + + def data(self, data): + assert isinstance(data, dict) + if 'id' not in data or 'name' not in data: + raise PubNubException("User's id or name missing.") + self._data = data + return self def build_data(self): - return utils.write_value_as_string(self._include) + return utils.write_value_as_string(self._data) def validate_params(self): self.validate_subscribe_key() - if 'id' not in self._include or 'name' not in self._include: - raise PubNubException('"id" or "name" not found in include data.') + if self._data is None: + raise PubNubException('No data supplied.') def build_path(self): return CreateUser.CREATE_USER_PATH % (self.pubnub.config.subscribe_key) diff --git a/pubnub/endpoints/users/update_user.py b/pubnub/endpoints/users/update_user.py index 68a88bcc..6b858d5e 100644 --- a/pubnub/endpoints/users/update_user.py +++ b/pubnub/endpoints/users/update_user.py @@ -14,6 +14,7 @@ def __init__(self, pubnub): Endpoint.__init__(self, pubnub) self._user_id = None self._include = None + self._data = None def user_id(self, user_id): assert isinstance(user_id, six.string_types) @@ -21,17 +22,22 @@ def user_id(self, user_id): return self def include(self, data): - assert isinstance(data, dict) self._include = data return self + def data(self, data): + assert isinstance(data, dict) + self._data = data + return self + def custom_params(self): - return {} + params = {} + if self._include: + params['include'] = utils.url_write(self._include) + return params def build_data(self): - if self._include: - return utils.write_value_as_string(self._include) - return '' + return utils.write_value_as_string(self._data) def build_path(self): if self._user_id is None: @@ -46,6 +52,8 @@ def is_auth_required(self): def validate_params(self): self.validate_subscribe_key() + if self._data is None: + raise PubNubException('No data supplied.') def create_response(self, envelope): # pylint: disable=W0221 return PNUpdateUserResult(envelope) diff --git a/tests/functional/spaces/test_create_space.py b/tests/functional/spaces/test_create_space.py index ba94b13d..39b7a710 100644 --- a/tests/functional/spaces/test_create_space.py +++ b/tests/functional/spaces/test_create_space.py @@ -1,4 +1,5 @@ import pytest +import json from pubnub.pubnub import PubNub from pubnub.pnconfiguration import PNConfiguration from pubnub.endpoints.space.create_space import CreateSpace @@ -22,8 +23,12 @@ def test_create_space(): space.include({'id': 'x'}) with pytest.raises(PubNubException): space.validate_params() - space.include({'id': 'x', 'name': 'a'}) + space.include('custom') + with pytest.raises(PubNubException): + space.validate_params() + space.data({'id': 'x', 'name': 'a'}) space.validate_params() assert space.build_path() == CreateSpace.CREATE_SPACE_PATH % SUB_KEY assert AUTH == space.build_params_callback()({})['auth'] + assert json.loads(space.build_data()) == {'id': 'x', 'name': 'a'} diff --git a/tests/functional/spaces/test_update_space.py b/tests/functional/spaces/test_update_space.py index 9813b6e1..94c4c109 100644 --- a/tests/functional/spaces/test_update_space.py +++ b/tests/functional/spaces/test_update_space.py @@ -16,11 +16,14 @@ def test_update_space(): config.subscribe_key = SUB_KEY config.auth_key = AUTH space = PubNub(config).update_space() - space.include({'a': 3, 'b': 1}) + space.include('custom') with pytest.raises(PubNubException): space.build_path() space.space_id('foo') assert space.build_path() == UpdateSpace.UPDATE_SPACE_PATH % (SUB_KEY, 'foo') - assert json.loads(space.build_data()) == {'a': 3, 'b': 1} + with pytest.raises(PubNubException): + space.validate_params() + space.data({'name': 'bar'}) + assert json.loads(space.build_data()) == {'name': 'bar'} assert AUTH == space.build_params_callback()({})['auth'] diff --git a/tests/functional/users/test_create_user.py b/tests/functional/users/test_create_user.py index 64af71e1..cc4f82f1 100644 --- a/tests/functional/users/test_create_user.py +++ b/tests/functional/users/test_create_user.py @@ -1,4 +1,5 @@ import pytest +import json from pubnub.pubnub import PubNub from pubnub.pnconfiguration import PNConfiguration from pubnub.endpoints.users.create_user import CreateUser @@ -22,8 +23,12 @@ def test_create_user(): user.include({'id': 'x'}) with pytest.raises(PubNubException): user.validate_params() - user.include({'id': 'x', 'name': 'a'}) + user.include('id') + with pytest.raises(PubNubException): + user.validate_params() + user.data({'id': 'user', 'name': 'username'}) user.validate_params() assert user.build_path() == CreateUser.CREATE_USER_PATH % SUB_KEY assert AUTH == user.build_params_callback()({})['auth'] + assert json.loads(user.build_data()) == {'id': 'user', 'name': 'username'} diff --git a/tests/functional/users/test_update_user.py b/tests/functional/users/test_update_user.py index fedcd350..f943e7ec 100644 --- a/tests/functional/users/test_update_user.py +++ b/tests/functional/users/test_update_user.py @@ -16,11 +16,14 @@ def test_update_user(): config.subscribe_key = SUB_KEY config.auth_key = AUTH user = PubNub(config).update_user() - user.include({'a': 3, 'b': 1}) with pytest.raises(PubNubException): user.build_path() user.user_id('foo') assert user.build_path() == UpdateUser.UPDATE_USER_PATH % (SUB_KEY, 'foo') - assert json.loads(user.build_data()) == {'a': 3, 'b': 1} + with pytest.raises(PubNubException): + user.validate_params() + user.data({'name': 'username'}) + user.validate_params() + assert json.loads(user.build_data()) == {'name': 'username'} assert AUTH == user.build_params_callback()({})['auth'] diff --git a/tests/integrational/asyncio/test_space.py b/tests/integrational/asyncio/test_space.py index 81859c8a..eabf0f35 100644 --- a/tests/integrational/asyncio/test_space.py +++ b/tests/integrational/asyncio/test_space.py @@ -14,7 +14,7 @@ def test_get_spaces(event_loop): config = pnconf_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.get_spaces().include(['description', 'custom', 'created', 'updated', 'eTag']).future() + envelope = yield from pn.get_spaces().future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() @@ -32,8 +32,8 @@ def test_get_spaces(event_loop): def test_create_space(event_loop): config = pnconf_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.create_space().include({'id': 'my-channel', 'name': 'My space', - 'description': 'A space that is mine'}).future() + envelope = yield from pn.create_space().data({'id': 'my-channel', 'name': 'My space', + 'description': 'A space that is mine'}).future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() @@ -53,8 +53,7 @@ def test_create_space(event_loop): def test_get_space(event_loop): config = pnconf_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.get_space().space_id( - 'my-chanel').include(['description', 'name', 'created', 'updated', 'eTag']).future() + envelope = yield from pn.get_space().space_id('my-chanel').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() @@ -75,9 +74,8 @@ def test_get_space(event_loop): def test_update_space(event_loop): config = pnconf_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - include = {'id': 'my-channel', 'name': 'My space', - 'description': 'A space that is mine'} - envelope = yield from pn.update_space().space_id('my-channel').include(include).future() + data = {'name': 'My space', 'description': 'A space that is mine'} + envelope = yield from pn.update_space().space_id('my-channel').data(data).future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() diff --git a/tests/integrational/asyncio/test_user.py b/tests/integrational/asyncio/test_user.py index b48eaff2..d0103d1e 100644 --- a/tests/integrational/asyncio/test_user.py +++ b/tests/integrational/asyncio/test_user.py @@ -14,8 +14,7 @@ def test_get_users(event_loop): config = pnconf_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.get_users().include(['externalId', 'profileUrl', 'email', - 'custom', 'created', 'updated', 'eTag']).future() + envelope = yield from pn.get_users().future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetUsersResult) @@ -36,7 +35,7 @@ def test_create_user(event_loop): pn = PubNubAsyncio(config, custom_event_loop=event_loop) data = {'id': 'user-1', 'name': 'John Doe', 'externalId': None, 'profileUrl': None, 'email': 'jack@twitter.com'} - envelope = yield from pn.create_user().include(data).future() + envelope = yield from pn.create_user().data(data).future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() @@ -58,8 +57,7 @@ def test_create_user(event_loop): def test_fetch_user(event_loop): config = pnconf_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.fetch_user().user_id('user-1').include(['externalId', 'profileUrl', 'email', - 'created', 'updated', 'eTag']).future() + envelope = yield from pn.fetch_user().user_id('user-1').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() @@ -77,9 +75,9 @@ def test_fetch_user(event_loop): def test_update_user(event_loop): config = pnconf_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.update_user().user_id('user-1').include({'id': 'user-1', 'name': 'John Doe', - 'externalId': None, 'profileUrl': None, - 'email': 'jack@twitter.com'}).future() + envelope = yield from pn.update_user().user_id('user-1').data({'name': 'John Doe', + 'externalId': None, 'profileUrl': None, + 'email': 'jack@twitter.com'}).future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() diff --git a/tests/integrational/fixtures/asyncio/space/get_space.yaml b/tests/integrational/fixtures/asyncio/space/get_space.yaml index ac435975..0e8f79f2 100644 --- a/tests/integrational/fixtures/asyncio/space/get_space.yaml +++ b/tests/integrational/fixtures/asyncio/space/get_space.yaml @@ -5,18 +5,18 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel?include=%5B%22description%22%2C+%22name%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel response: body: string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" headers: Access-Control-Allow-Origin: '*' - Content-Length: '285' + Content-Length: '284' Content-Type: application/json - Date: Sun, 21 Jul 2019 11:50:36 GMT + Date: Sun, 04 Aug 2019 17:47:30 GMT status: code: 200 message: OK @@ -26,6 +26,6 @@ interactions: - http - ps.pndsn.com - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel - - include=%5B%22description%22%2C%20%22name%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=a92093b7-9c6c-4f98-a252-ba3cb25ec65f + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=87ecbfb8-86c2-4967-82bd-e39c65334189 - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/space/get_spaces.yaml b/tests/integrational/fixtures/asyncio/space/get_spaces.yaml index b2be51ac..8e6d2d6b 100644 --- a/tests/integrational/fixtures/asyncio/space/get_spaces.yaml +++ b/tests/integrational/fixtures/asyncio/space/get_spaces.yaml @@ -5,7 +5,7 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?include=%5B%22description%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces response: body: string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ @@ -19,12 +19,12 @@ interactions: ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"updated\"\ : \"2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"MUIwQTAwMUItQkRBRC00NDkyLTgyMEMtODg2OUU1N0REMTNBCg==\"\ ,\n \"prev\": \"M0FFODRENzMtNjY2Qy00RUExLTk4QzktNkY1Q0I2MUJFNDRCCg==\",\n\ - \ \"status\": \"ok\",\n \"totalCount\": 9\n}" + \ \"status\": 200,\n \"totalCount\": 9\n}" headers: Access-Control-Allow-Origin: '*' - Content-Length: '842' + Content-Length: '841' Content-Type: application/json - Date: Sun, 21 Jul 2019 11:50:35 GMT + Date: Sun, 04 Aug 2019 17:47:30 GMT status: code: 200 message: OK @@ -34,6 +34,6 @@ interactions: - http - ps.pndsn.com - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces - - include=%5B%22description%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=726f3828-77b8-4af6-b633-8b81313543d5 + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=b1d0b6fd-2356-4969-9a82-89acdc9c4121 - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/user/fetch_user.yaml b/tests/integrational/fixtures/asyncio/user/fetch_user.yaml index 9b7952c0..8bf0df7a 100644 --- a/tests/integrational/fixtures/asyncio/user/fetch_user.yaml +++ b/tests/integrational/fixtures/asyncio/user/fetch_user.yaml @@ -5,20 +5,19 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 response: body: string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ - \n}" + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" headers: Access-Control-Allow-Origin: '*' - Content-Length: '319' + Content-Length: '318' Content-Type: application/json - Date: Mon, 15 Jul 2019 20:37:59 GMT + Date: Sun, 04 Aug 2019 17:36:22 GMT status: code: 200 message: OK @@ -28,6 +27,6 @@ interactions: - http - ps.pndsn.com - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 - - include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=a9542de8-67ab-4ac6-8747-a05acbf247dd + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=fa2600b7-d476-4080-8e43-1666b030b661 - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/user/users_get.yaml b/tests/integrational/fixtures/asyncio/user/users_get.yaml index 2ee58c38..914e2f81 100644 --- a/tests/integrational/fixtures/asyncio/user/users_get.yaml +++ b/tests/integrational/fixtures/asyncio/user/users_get.yaml @@ -5,7 +5,7 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users response: body: string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ @@ -18,12 +18,12 @@ interactions: ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n \ \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n ],\n\ - \ \"status\": \"ok\"\n}" + \ \"status\": 200\n}" headers: Access-Control-Allow-Origin: '*' - Content-Length: '738' + Content-Length: '737' Content-Type: application/json - Date: Sun, 14 Jul 2019 21:31:55 GMT + Date: Sun, 04 Aug 2019 18:44:33 GMT status: code: 200 message: OK @@ -33,6 +33,6 @@ interactions: - http - ps.pndsn.com - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users - - include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=ce392d26-151b-4eac-8143-c7e8b9c5cdf9 + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=2f59bc97-a946-4abe-b1f8-0efebbacde4d - '' version: 1 diff --git a/tests/integrational/fixtures/native_sync/space/get_space.yaml b/tests/integrational/fixtures/native_sync/space/get_space.yaml index 6e91adeb..d859d9e7 100644 --- a/tests/integrational/fixtures/native_sync/space/get_space.yaml +++ b/tests/integrational/fixtures/native_sync/space/get_space.yaml @@ -11,22 +11,22 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel?include=%5B%22description%22%2C+%22name%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel response: body: string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" headers: Access-Control-Allow-Origin: - '*' Content-Length: - - '285' + - '284' Content-Type: - application/json Date: - - Sun, 21 Jul 2019 11:36:49 GMT + - Sun, 04 Aug 2019 17:45:09 GMT status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/space/get_spaces.yaml b/tests/integrational/fixtures/native_sync/space/get_spaces.yaml index 8a1dbccc..0a09b0d2 100644 --- a/tests/integrational/fixtures/native_sync/space/get_spaces.yaml +++ b/tests/integrational/fixtures/native_sync/space/get_spaces.yaml @@ -11,7 +11,7 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?include=%5B%22description%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces response: body: string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ @@ -25,16 +25,16 @@ interactions: ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"updated\"\ : \"2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"MUIwQTAwMUItQkRBRC00NDkyLTgyMEMtODg2OUU1N0REMTNBCg==\"\ ,\n \"prev\": \"M0FFODRENzMtNjY2Qy00RUExLTk4QzktNkY1Q0I2MUJFNDRCCg==\",\n\ - \ \"status\": \"ok\",\n \"totalCount\": 9\n}" + \ \"status\": 200,\n \"totalCount\": 9\n}" headers: Access-Control-Allow-Origin: - '*' Content-Length: - - '842' + - '841' Content-Type: - application/json Date: - - Sun, 21 Jul 2019 11:36:49 GMT + - Sun, 04 Aug 2019 17:45:14 GMT status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/user/fetch_user.yaml b/tests/integrational/fixtures/native_sync/user/fetch_user.yaml index a8ecc156..aa7f39a3 100644 --- a/tests/integrational/fixtures/native_sync/user/fetch_user.yaml +++ b/tests/integrational/fixtures/native_sync/user/fetch_user.yaml @@ -11,24 +11,23 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 response: body: string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ - \n}" + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" headers: Access-Control-Allow-Origin: - '*' Content-Length: - - '319' + - '318' Content-Type: - application/json Date: - - Mon, 15 Jul 2019 20:35:53 GMT + - Sun, 04 Aug 2019 17:38:55 GMT status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/user/users_get.yaml b/tests/integrational/fixtures/native_sync/user/users_get.yaml index 636813a4..49eb1e21 100644 --- a/tests/integrational/fixtures/native_sync/user/users_get.yaml +++ b/tests/integrational/fixtures/native_sync/user/users_get.yaml @@ -11,7 +11,7 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users response: body: string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ @@ -24,16 +24,16 @@ interactions: ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n \ \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n ],\n\ - \ \"status\": \"ok\"\n}" + \ \"status\": 200\n}" headers: Access-Control-Allow-Origin: - '*' Content-Length: - - '738' + - '737' Content-Type: - application/json Date: - - Sun, 14 Jul 2019 21:31:42 GMT + - Sun, 04 Aug 2019 17:39:02 GMT status: code: 200 message: OK diff --git a/tests/integrational/fixtures/tornado/space/get_space.yaml b/tests/integrational/fixtures/tornado/space/get_space.yaml index 866bc855..76b8fc08 100644 --- a/tests/integrational/fixtures/tornado/space/get_space.yaml +++ b/tests/integrational/fixtures/tornado/space/get_space.yaml @@ -7,13 +7,13 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel?include=%5B%22description%22%2C+%22name%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel response: body: string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" headers: - !!python/tuple - Access-Control-Allow-Origin @@ -23,15 +23,15 @@ interactions: - - application/json - !!python/tuple - Date - - - Sun, 21 Jul 2019 11:57:06 GMT + - - Sun, 04 Aug 2019 17:43:40 GMT - !!python/tuple - Content-Length - - - '285' + - - '284' - !!python/tuple - Connection - - close status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel?include=%5B%22description%22%2C%20%22name%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=0da25714-4f0c-4b3b-adcd-33bfc44d1431 + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=54fdaf57-ca7b-4fcd-a4b8-b8a0c1b87998 version: 1 diff --git a/tests/integrational/fixtures/tornado/space/get_spaces.yaml b/tests/integrational/fixtures/tornado/space/get_spaces.yaml index f8ee86de..a22ac62c 100644 --- a/tests/integrational/fixtures/tornado/space/get_spaces.yaml +++ b/tests/integrational/fixtures/tornado/space/get_spaces.yaml @@ -7,7 +7,7 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?include=%5B%22description%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces response: body: string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ @@ -21,7 +21,7 @@ interactions: ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"updated\"\ : \"2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"MUIwQTAwMUItQkRBRC00NDkyLTgyMEMtODg2OUU1N0REMTNBCg==\"\ ,\n \"prev\": \"M0FFODRENzMtNjY2Qy00RUExLTk4QzktNkY1Q0I2MUJFNDRCCg==\",\n\ - \ \"status\": \"ok\",\n \"totalCount\": 9\n}" + \ \"status\": 200,\n \"totalCount\": 9\n}" headers: - !!python/tuple - Access-Control-Allow-Origin @@ -31,15 +31,15 @@ interactions: - - application/json - !!python/tuple - Date - - - Sun, 21 Jul 2019 11:57:06 GMT + - - Sun, 04 Aug 2019 17:43:40 GMT - !!python/tuple - Content-Length - - - '842' + - - '841' - !!python/tuple - Connection - - close status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?include=%5B%22description%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=363b0152-af3e-4635-9046-b5a761ca182b + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=0851146a-88f5-48f3-8762-7e4ce787897f version: 1 diff --git a/tests/integrational/fixtures/tornado/user/fetch_user.yaml b/tests/integrational/fixtures/tornado/user/fetch_user.yaml index bc051c4e..23931493 100644 --- a/tests/integrational/fixtures/tornado/user/fetch_user.yaml +++ b/tests/integrational/fixtures/tornado/user/fetch_user.yaml @@ -7,15 +7,14 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 response: body: string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ - \n}" + \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" headers: - !!python/tuple - Access-Control-Allow-Origin @@ -25,15 +24,15 @@ interactions: - - application/json - !!python/tuple - Date - - - Mon, 15 Jul 2019 20:41:54 GMT + - - Sun, 04 Aug 2019 17:41:24 GMT - !!python/tuple - Content-Length - - - '319' + - - '318' - !!python/tuple - Connection - - close status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=f0717bf9-f478-4a9f-be66-068aa23084ce + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=e998d43a-3fc8-45c0-bb35-11c1ec6d8de6 version: 1 diff --git a/tests/integrational/fixtures/tornado/user/users_get.yaml b/tests/integrational/fixtures/tornado/user/users_get.yaml index eceb4c67..42451e96 100644 --- a/tests/integrational/fixtures/tornado/user/users_get.yaml +++ b/tests/integrational/fixtures/tornado/user/users_get.yaml @@ -7,7 +7,7 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%22externalId%22%2C+%22profileUrl%22%2C+%22email%22%2C+%22custom%22%2C+%22created%22%2C+%22updated%22%2C+%22eTag%22%5D + uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users response: body: string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ @@ -20,7 +20,7 @@ interactions: ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n \ \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n ],\n\ - \ \"status\": \"ok\"\n}" + \ \"status\": 200\n}" headers: - !!python/tuple - Access-Control-Allow-Origin @@ -30,15 +30,15 @@ interactions: - - application/json - !!python/tuple - Date - - - Sun, 14 Jul 2019 21:36:27 GMT + - - Sun, 04 Aug 2019 17:41:52 GMT - !!python/tuple - Content-Length - - - '738' + - - '737' - !!python/tuple - Connection - - close status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?include=%5B%22externalId%22%2C%20%22profileUrl%22%2C%20%22email%22%2C%20%22custom%22%2C%20%22created%22%2C%20%22updated%22%2C%20%22eTag%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=861dcf10-ec38-4a3f-826a-7c2114fd4d6a + url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=e9e04c00-2d03-4409-b1fd-a41f379cdad0 version: 1 diff --git a/tests/integrational/native_sync/test_space.py b/tests/integrational/native_sync/test_space.py index 271d2d1b..04c9819e 100644 --- a/tests/integrational/native_sync/test_space.py +++ b/tests/integrational/native_sync/test_space.py @@ -12,7 +12,7 @@ def test_get_spaces(): config = pnconf_copy() pn = PubNub(config) - envelope = pn.get_spaces().include(['description', 'custom', 'created', 'updated', 'eTag']).sync() + envelope = pn.get_spaces().sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() @@ -29,8 +29,8 @@ def test_get_spaces(): def test_create_space(): config = pnconf_copy() pn = PubNub(config) - envelope = pn.create_space().include({'id': 'my-channel', 'name': 'My space', - 'description': 'A space that is mine'}).sync() + envelope = pn.create_space().data({'id': 'my-channel', 'name': 'My space', + 'description': 'A space that is mine'}).sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() @@ -49,8 +49,7 @@ def test_create_space(): def test_get_space(): config = pnconf_copy() pn = PubNub(config) - envelope = pn.get_space().space_id( - 'my-chanel').include(['description', 'name', 'created', 'updated', 'eTag']).sync() + envelope = pn.get_space().space_id('my-chanel').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() @@ -70,8 +69,8 @@ def test_get_space(): def test_update_space(): config = pnconf_copy() pn = PubNub(config) - envelope = pn.update_space().space_id('my-channel').include({'id': 'my-channel', 'name': 'My space', - 'description': 'A space that is mine'}).sync() + envelope = pn.update_space().space_id('my-channel').data({'name': 'My space', + 'description': 'A space that is mine'}).sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() diff --git a/tests/integrational/native_sync/test_user.py b/tests/integrational/native_sync/test_user.py index 9428da4e..f7f1e2fd 100644 --- a/tests/integrational/native_sync/test_user.py +++ b/tests/integrational/native_sync/test_user.py @@ -12,8 +12,7 @@ def test_get_users(): config = pnconf_copy() pn = PubNub(config) - envelope = pn.get_users().include(['externalId', 'profileUrl', 'email', - 'custom', 'created', 'updated', 'eTag']).sync() + envelope = pn.get_users().sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() @@ -32,8 +31,8 @@ def test_get_users(): def test_create_user(): config = pnconf_copy() pn = PubNub(config) - envelope = pn.create_user().include({'id': 'user-1', 'name': 'John Doe', - 'externalId': None, 'profileUrl': None, 'email': 'jack@twitter.com'}).sync() + envelope = pn.create_user().data({'id': 'user-1', 'name': 'John Doe', + 'externalId': None, 'profileUrl': None, 'email': 'jack@twitter.com'}).sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() @@ -54,8 +53,7 @@ def test_create_user(): def test_fetch_user(): config = pnconf_copy() pn = PubNub(config) - envelope = pn.fetch_user().user_id('user-1').include(['externalId', 'profileUrl', 'email', - 'created', 'updated', 'eTag']).sync() + envelope = pn.fetch_user().user_id('user-1').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() @@ -72,9 +70,9 @@ def test_fetch_user(): def test_update_user(): config = pnconf_copy() pn = PubNub(config) - envelope = pn.update_user().user_id('user-1').include({'id': 'user-1', 'name': 'John Doe', - 'externalId': None, 'profileUrl': None, - 'email': 'jack@twitter.com'}).sync() + envelope = pn.update_user().user_id('user-1').data({'name': 'John Doe', + 'externalId': None, 'profileUrl': None, + 'email': 'jack@twitter.com'}).sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() diff --git a/tests/integrational/tornado/test_space.py b/tests/integrational/tornado/test_space.py index 5e7c59c7..73eb265d 100644 --- a/tests/integrational/tornado/test_space.py +++ b/tests/integrational/tornado/test_space.py @@ -19,7 +19,7 @@ def setUp(self): filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_get_spaces(self): - envelope = yield self.pn.get_spaces().include(['description', 'custom', 'created', 'updated', 'eTag']).future() + envelope = yield self.pn.get_spaces().future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() @@ -35,8 +35,8 @@ def test_get_spaces(self): filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_create_space(self): - envelope = yield self.pn.create_space().include({'id': 'my-channel', 'name': 'My space', - 'description': 'A space that is mine'}).future() + envelope = yield self.pn.create_space().data({'id': 'my-channel', 'name': 'My space', + 'description': 'A space that is mine'}).future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() @@ -55,7 +55,7 @@ def test_create_space(self): @tornado.testing.gen_test def test_get_space(self): envelope = yield self.pn.get_space().space_id( - 'my-chanel').include(['description', 'name', 'created', 'updated', 'eTag']).future() + 'my-chanel').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() @@ -74,9 +74,8 @@ def test_get_space(self): filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_update_space(self): - include = {'id': 'my-channel', 'name': 'My space', - 'description': 'A space that is mine'} - envelope = yield self.pn.update_space().space_id('my-channel').include(include).future() + data = {'name': 'My space', 'description': 'A space that is mine'} + envelope = yield self.pn.update_space().space_id('my-channel').data(data).future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() diff --git a/tests/integrational/tornado/test_user.py b/tests/integrational/tornado/test_user.py index f8be4051..b51d01f9 100644 --- a/tests/integrational/tornado/test_user.py +++ b/tests/integrational/tornado/test_user.py @@ -19,8 +19,7 @@ def setUp(self): filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_single_channel(self): - envelope = yield self.pn.get_users().include(['externalId', 'profileUrl', 'email', - 'custom', 'created', 'updated', 'eTag']).future() + envelope = yield self.pn.get_users().future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() @@ -40,7 +39,7 @@ def test_single_channel(self): def test_create_user(self): data = {'id': 'user-1', 'name': 'John Doe', 'externalId': None, 'profileUrl': None, 'email': 'jack@twitter.com'} - envelope = yield self.pn.create_user().include(data).future() + envelope = yield self.pn.create_user().data(data).future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() @@ -60,8 +59,7 @@ def test_create_user(self): filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_fetch_user(self): - envelope = yield self.pn.fetch_user().user_id('user-1').include(['externalId', 'profileUrl', 'email', - 'created', 'updated', 'eTag']).future() + envelope = yield self.pn.fetch_user().user_id('user-1').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() @@ -77,9 +75,9 @@ def test_fetch_user(self): filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_update_user(self): - envelope = yield self.pn.update_user().user_id('user-1').include({'id': 'user-1', 'name': 'John Doe', - 'externalId': None, 'profileUrl': None, - 'email': 'jack@twitter.com'}).future() + envelope = yield self.pn.update_user().user_id('user-1').data({'name': 'John Doe', + 'externalId': None, 'profileUrl': None, + 'email': 'jack@twitter.com'}).future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() From 1fbbdb2d2362e3a97385a58011b61f5b1fcb1b5a Mon Sep 17 00:00:00 2001 From: QSD_z Date: Mon, 5 Aug 2019 14:12:32 +0200 Subject: [PATCH 17/26] Rename FetchUser to GetUser. Update tests. --- .../endpoints/users/{fetch_user.py => get_user.py} | 14 +++++++------- pubnub/enums.py | 2 +- pubnub/managers.py | 2 +- pubnub/models/consumer/user.py | 8 ++++---- pubnub/pubnub_core.py | 6 +++--- tests/functional/spaces/test_get_space.py | 2 +- .../users/{test_fetch_user.py => test_get_user.py} | 8 ++++---- tests/integrational/asyncio/test_user.py | 8 ++++---- tests/integrational/native_sync/test_user.py | 8 ++++---- tests/integrational/tornado/test_user.py | 8 ++++---- 10 files changed, 33 insertions(+), 33 deletions(-) rename pubnub/endpoints/users/{fetch_user.py => get_user.py} (78%) rename tests/functional/users/{test_fetch_user.py => test_get_user.py} (73%) diff --git a/pubnub/endpoints/users/fetch_user.py b/pubnub/endpoints/users/get_user.py similarity index 78% rename from pubnub/endpoints/users/fetch_user.py rename to pubnub/endpoints/users/get_user.py index a38000d4..ba91ad30 100644 --- a/pubnub/endpoints/users/fetch_user.py +++ b/pubnub/endpoints/users/get_user.py @@ -2,13 +2,13 @@ from pubnub import utils from pubnub.endpoints.endpoint import Endpoint -from pubnub.models.consumer.user import PNFetchUserResult +from pubnub.models.consumer.user import PNGetUserResult from pubnub.enums import HttpMethod, PNOperationType from pubnub.exceptions import PubNubException -class FetchUser(Endpoint): - FETCH_USER_PATH = '/v1/objects/%s/users/%s' +class GetUser(Endpoint): + GET_USER_PATH = '/v1/objects/%s/users/%s' def __init__(self, pubnub): Endpoint.__init__(self, pubnub) @@ -33,7 +33,7 @@ def custom_params(self): def build_path(self): if self._user_id is None: raise PubNubException('Provide user_id.') - return FetchUser.FETCH_USER_PATH % (self.pubnub.config.subscribe_key, self._user_id) + return GetUser.GET_USER_PATH % (self.pubnub.config.subscribe_key, self._user_id) def http_method(self): return HttpMethod.GET @@ -45,7 +45,7 @@ def validate_params(self): self.validate_subscribe_key() def create_response(self, envelope): # pylint: disable=W0221 - return PNFetchUserResult(envelope) + return PNGetUserResult(envelope) def request_timeout(self): return self.pubnub.config.non_subscribe_request_timeout @@ -54,7 +54,7 @@ def connect_timeout(self): return self.pubnub.config.connect_timeout def operation_type(self): - return PNOperationType.PNFetchUserOperation + return PNOperationType.PNGetUserOperation def name(self): - return 'Fetch user' + return 'Get user' diff --git a/pubnub/enums.py b/pubnub/enums.py index d288ae23..dd874c3e 100644 --- a/pubnub/enums.py +++ b/pubnub/enums.py @@ -67,7 +67,7 @@ class PNOperationType(object): PNSignalOperation = 26 PNGetUsersOperation = 27 PNCreateUserOperation = 28 - PNFetchUserOperation = 29 + PNGetUserOperation = 29 PNUpdateUserOperation = 30 PNDeleteUserOperation = 31 PNGetSpacesOperation = 32 diff --git a/pubnub/managers.py b/pubnub/managers.py index 62e21c17..41575d63 100644 --- a/pubnub/managers.py +++ b/pubnub/managers.py @@ -454,7 +454,7 @@ def endpoint_name_for_operation(operation_type): PNOperationType.PNGetUsersOperation: 'obj', PNOperationType.PNCreateUserOperation: 'obj', - PNOperationType.PNFetchUserOperation: 'obj', + PNOperationType.PNGetUserOperation: 'obj', PNOperationType.PNUpdateUserOperation: 'obj', PNOperationType.PNDeleteUserOperation: 'obj', PNOperationType.PNGetSpacesOperation: 'obj', diff --git a/pubnub/models/consumer/user.py b/pubnub/models/consumer/user.py index 6df6b5db..128e1d06 100644 --- a/pubnub/models/consumer/user.py +++ b/pubnub/models/consumer/user.py @@ -29,18 +29,18 @@ def __str__(self): return "User created with data: %s" % self.data -class PNFetchUserResult(object): +class PNGetUserResult(object): def __init__(self, result): """ - Representation of fetch user server response + Representation of get user server response - :param result: result of fetch user operation + :param result: result of get user operation """ self.data = result['data'] self.status = result['status'] def __str__(self): - return "Fetch user success with data: %s" % self.data + return "Get user success with data: %s" % self.data class PNUpdateUserResult(object): diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index 5d9088ee..cd0883bb 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -27,7 +27,7 @@ from .endpoints.signal import Signal from .endpoints.users.get_users import GetUsers from .endpoints.users.create_user import CreateUser -from .endpoints.users.fetch_user import FetchUser +from .endpoints.users.get_user import GetUser from .endpoints.users.update_user import UpdateUser from .endpoints.users.delete_user import DeleteUser from .endpoints.space.get_spaces import GetSpaces @@ -189,8 +189,8 @@ def get_users(self): def create_user(self): return CreateUser(self) - def fetch_user(self): - return FetchUser(self) + def get_user(self): + return GetUser(self) def update_user(self): return UpdateUser(self) diff --git a/tests/functional/spaces/test_get_space.py b/tests/functional/spaces/test_get_space.py index 4e90778f..d86a2c95 100644 --- a/tests/functional/spaces/test_get_space.py +++ b/tests/functional/spaces/test_get_space.py @@ -10,7 +10,7 @@ AUTH = 'auth' -def test_fetch_space(): +def test_get_space(): config = PNConfiguration() config.subscribe_key = SUB_KEY config.auth_key = AUTH diff --git a/tests/functional/users/test_fetch_user.py b/tests/functional/users/test_get_user.py similarity index 73% rename from tests/functional/users/test_fetch_user.py rename to tests/functional/users/test_get_user.py index 3e01f0e6..3c3743ba 100644 --- a/tests/functional/users/test_fetch_user.py +++ b/tests/functional/users/test_get_user.py @@ -2,7 +2,7 @@ from pubnub.pubnub import PubNub from pubnub.pnconfiguration import PNConfiguration -from pubnub.endpoints.users.fetch_user import FetchUser +from pubnub.endpoints.users.get_user import GetUser from pubnub.exceptions import PubNubException @@ -10,17 +10,17 @@ AUTH = 'auth' -def test_fetch_user(): +def test_get_user(): config = PNConfiguration() config.subscribe_key = SUB_KEY config.auth_key = AUTH - user = PubNub(config).fetch_user() + user = PubNub(config).get_user() user.include(['a', 'b']) with pytest.raises(PubNubException): user.build_path() user.user_id('foo') - assert user.build_path() == FetchUser.FETCH_USER_PATH % (SUB_KEY, 'foo') + assert user.build_path() == GetUser.GET_USER_PATH % (SUB_KEY, 'foo') params = user.custom_params() assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' diff --git a/tests/integrational/asyncio/test_user.py b/tests/integrational/asyncio/test_user.py index d0103d1e..6181a2b4 100644 --- a/tests/integrational/asyncio/test_user.py +++ b/tests/integrational/asyncio/test_user.py @@ -3,7 +3,7 @@ from tests.helper import pnconf_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope -from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNFetchUserResult, +from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNGetUserResult, PNUpdateUserResult, PNDeleteUserResult) from pubnub.models.consumer.common import PNStatus @@ -54,14 +54,14 @@ def test_create_user(event_loop): @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/user/fetch_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio -def test_fetch_user(event_loop): +def test_get_user(event_loop): config = pnconf_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.fetch_user().user_id('user-1').future() + envelope = yield from pn.get_user().user_id('user-1').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() - assert isinstance(envelope.result, PNFetchUserResult) + assert isinstance(envelope.result, PNGetUserResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert set(['name', 'id', 'externalId', 'profileUrl', 'email', diff --git a/tests/integrational/native_sync/test_user.py b/tests/integrational/native_sync/test_user.py index f7f1e2fd..de7f3e82 100644 --- a/tests/integrational/native_sync/test_user.py +++ b/tests/integrational/native_sync/test_user.py @@ -2,7 +2,7 @@ from tests.integrational.vcr_helper import pn_vcr from pubnub.structures import Envelope from pubnub.pubnub import PubNub -from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNFetchUserResult, +from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNGetUserResult, PNUpdateUserResult, PNDeleteUserResult) from pubnub.models.consumer.common import PNStatus @@ -50,14 +50,14 @@ def test_create_user(): @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/user/fetch_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) -def test_fetch_user(): +def test_get_user(): config = pnconf_copy() pn = PubNub(config) - envelope = pn.fetch_user().user_id('user-1').sync() + envelope = pn.get_user().user_id('user-1').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() - assert isinstance(envelope.result, PNFetchUserResult) + assert isinstance(envelope.result, PNGetUserResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert set(['name', 'id', 'externalId', 'profileUrl', 'email', diff --git a/tests/integrational/tornado/test_user.py b/tests/integrational/tornado/test_user.py index b51d01f9..7622d840 100644 --- a/tests/integrational/tornado/test_user.py +++ b/tests/integrational/tornado/test_user.py @@ -2,7 +2,7 @@ from tornado.testing import AsyncTestCase from pubnub.pubnub_tornado import PubNubTornado, TornadoEnvelope -from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNFetchUserResult, +from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNGetUserResult, PNUpdateUserResult, PNDeleteUserResult) from pubnub.models.consumer.common import PNStatus from tests.helper import pnconf_copy @@ -58,12 +58,12 @@ def test_create_user(self): @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/user/fetch_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test - def test_fetch_user(self): - envelope = yield self.pn.fetch_user().user_id('user-1').future() + def test_get_user(self): + envelope = yield self.pn.get_user().user_id('user-1').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() - assert isinstance(envelope.result, PNFetchUserResult) + assert isinstance(envelope.result, PNGetUserResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert set(['name', 'id', 'externalId', 'profileUrl', 'email', From 6939e4952684406e40e146c389a1a20f1a7265ee Mon Sep 17 00:00:00 2001 From: QSD_z Date: Tue, 13 Aug 2019 22:13:12 +0200 Subject: [PATCH 18/26] Implement listener methods for Objects API. --- pubnub/callbacks.py | 9 +++++++++ pubnub/managers.py | 12 ++++++++++++ pubnub/models/consumer/membership.py | 9 +++++++++ pubnub/models/consumer/space.py | 9 +++++++++ pubnub/models/consumer/user.py | 9 +++++++++ pubnub/models/server/subscribe.py | 3 +++ pubnub/workers.py | 22 ++++++++++++++++++++++ 7 files changed, 73 insertions(+) diff --git a/pubnub/callbacks.py b/pubnub/callbacks.py index 98833e5c..7bf4afb1 100644 --- a/pubnub/callbacks.py +++ b/pubnub/callbacks.py @@ -25,6 +25,15 @@ def presence(self, pubnub, presence): def signal(self, pubnub, signal): pass + def user(self, pubnub, user): + pass + + def space(self, pubnub, space): + pass + + def membership(self, pubnub, membership): + pass + class ReconnectionCallback(object): @abstractmethod diff --git a/pubnub/managers.py b/pubnub/managers.py index 41575d63..59f821be 100644 --- a/pubnub/managers.py +++ b/pubnub/managers.py @@ -207,6 +207,18 @@ def announce_signal(self, signal): for callback in self._listeners: callback.signal(self._pubnub, signal) + def announce_user(self, user): + for callback in self._listeners: + callback.user(self._pubnub, user) + + def announce_space(self, space): + for callback in self._listeners: + callback.space(self._pubnub, space) + + def announce_membership(self, membership): + for callback in self._listeners: + callback.membership(self._pubnub, membership) + def announce_presence(self, presence): for callback in self._listeners: callback.presence(self._pubnub, presence) diff --git a/pubnub/models/consumer/membership.py b/pubnub/models/consumer/membership.py index 5d5de3a4..249025fb 100644 --- a/pubnub/models/consumer/membership.py +++ b/pubnub/models/consumer/membership.py @@ -64,3 +64,12 @@ def __init__(self, result): def __str__(self): return "Update update members success with data: %s" % self.data + + +class PNMembershipResult(object): + def __init__(self, event, data): + self.data = data + self.event = event + + def __str__(self): + return "Membership %s event with data: %s" % (self.event, self.data) diff --git a/pubnub/models/consumer/space.py b/pubnub/models/consumer/space.py index 4effc375..39cd5df1 100644 --- a/pubnub/models/consumer/space.py +++ b/pubnub/models/consumer/space.py @@ -69,3 +69,12 @@ def __init__(self, result): def __str__(self): return "Delete space success with data: %s" % self.data + + +class PNSpaceResult(object): + def __init__(self, event, data): + self.data = data + self.event = event + + def __str__(self): + return "Space %s event with data: %s" % (self.event, self.data) diff --git a/pubnub/models/consumer/user.py b/pubnub/models/consumer/user.py index 128e1d06..a8a1e0e4 100644 --- a/pubnub/models/consumer/user.py +++ b/pubnub/models/consumer/user.py @@ -69,3 +69,12 @@ def __init__(self, result): def __str__(self): return "Delete user success with data: %s" % self.data + + +class PNUserResult(object): + def __init__(self, event, data): + self.data = data + self.event = event + + def __str__(self): + return "User %s event with data: %s" % (self.event, self.data) diff --git a/pubnub/models/server/subscribe.py b/pubnub/models/server/subscribe.py index baca7253..e1ed6b67 100644 --- a/pubnub/models/server/subscribe.py +++ b/pubnub/models/server/subscribe.py @@ -33,6 +33,7 @@ def __init__(self): self.publish_metadata = None self.only_channel_subscription = False self.is_signal = False + self.is_object = False @classmethod def from_json(cls, json_input): @@ -52,6 +53,8 @@ def from_json(cls, json_input): message.publish_metadata = PublishMetadata.from_json(json_input['p']) if 'e' in json_input and json_input['e'] == 1: message.is_signal = True + if 'e' in json_input and json_input['e'] == 2: + message.is_object = True return message diff --git a/pubnub/workers.py b/pubnub/workers.py index 3fd0f02a..3d010e1e 100644 --- a/pubnub/workers.py +++ b/pubnub/workers.py @@ -4,6 +4,9 @@ from .utils import strip_right from .models.consumer.pubsub import PNPresenceEventResult, PNMessageResult, PNSignalMessageResult from .models.server.subscribe import SubscribeMessage, PresenceEnvelope +from .models.consumer.user import PNUserResult +from .models.consumer.space import PNSpaceResult +from .models.consumer.membership import PNMembershipResult logger = logging.getLogger("pubnub") @@ -66,6 +69,25 @@ def _process_incoming_payload(self, message): state=presence_payload.data ) self._listener_manager.announce_presence(pn_presence_event_result) + elif message.is_object: + if message.payload['type'] == 'user': + user_result = PNUserResult( + type=message.payload['event'], + data=message.payload['data'] + ) + self._listener_manager.announce_user(user_result) + elif message.payload['type'] == 'space': + space_result = PNSpaceResult( + type=message.payload['event'], + data=message.payload['data'] + ) + self._listener_manager.announce_space(space_result) + else: + membership_result = PNMembershipResult( + type=message.payload['event'], + data=message.payload['data'] + ) + self._listener_manager.announce_membership(membership_result) else: extracted_message = self._process_message(message.payload) publisher = message.issuing_client_id From 03d162ae0ef5af9bec34250d001a774f87fac3f3 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sun, 18 Aug 2019 18:58:56 +0200 Subject: [PATCH 19/26] Properly set include URL parameters. Send PATCH request body when using native SDK. --- pubnub/endpoints/membership/get_members.py | 2 +- pubnub/endpoints/membership/get_space_memberships.py | 2 +- pubnub/endpoints/membership/update_members.py | 2 +- pubnub/endpoints/membership/update_space_memberships.py | 2 +- pubnub/endpoints/space/create_space.py | 2 +- pubnub/endpoints/space/get_space.py | 2 +- pubnub/endpoints/space/get_spaces.py | 2 +- pubnub/endpoints/space/update_space.py | 2 +- pubnub/endpoints/users/create_user.py | 2 +- pubnub/endpoints/users/get_user.py | 3 +-- pubnub/endpoints/users/get_users.py | 4 ++-- pubnub/endpoints/users/update_user.py | 2 +- pubnub/request_handlers/requests_handler.py | 4 ++-- pubnub/request_handlers/urllib2_handler.py | 2 +- pubnub/structures.py | 3 +++ 15 files changed, 19 insertions(+), 17 deletions(-) diff --git a/pubnub/endpoints/membership/get_members.py b/pubnub/endpoints/membership/get_members.py index 8cec54e2..2a8027cb 100644 --- a/pubnub/endpoints/membership/get_members.py +++ b/pubnub/endpoints/membership/get_members.py @@ -64,7 +64,7 @@ def custom_params(self): params['limit'] = self._limit if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = utils.join_items(self._include) return params diff --git a/pubnub/endpoints/membership/get_space_memberships.py b/pubnub/endpoints/membership/get_space_memberships.py index 1c94432a..a0ffe566 100644 --- a/pubnub/endpoints/membership/get_space_memberships.py +++ b/pubnub/endpoints/membership/get_space_memberships.py @@ -64,7 +64,7 @@ def custom_params(self): params['limit'] = self._limit if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = utils.join_items(self._include) return params diff --git a/pubnub/endpoints/membership/update_members.py b/pubnub/endpoints/membership/update_members.py index ab76be0f..5c8f4d0c 100644 --- a/pubnub/endpoints/membership/update_members.py +++ b/pubnub/endpoints/membership/update_members.py @@ -74,7 +74,7 @@ def custom_params(self): params['limit'] = self._limit if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = utils.join_items(self._include) return params diff --git a/pubnub/endpoints/membership/update_space_memberships.py b/pubnub/endpoints/membership/update_space_memberships.py index b91badf0..6162163f 100644 --- a/pubnub/endpoints/membership/update_space_memberships.py +++ b/pubnub/endpoints/membership/update_space_memberships.py @@ -74,7 +74,7 @@ def custom_params(self): params['limit'] = self._limit if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = utils.join_items(self._include) return params diff --git a/pubnub/endpoints/space/create_space.py b/pubnub/endpoints/space/create_space.py index 049fbc94..f65efc48 100644 --- a/pubnub/endpoints/space/create_space.py +++ b/pubnub/endpoints/space/create_space.py @@ -27,7 +27,7 @@ def data(self, data): def custom_params(self): params = {} if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = self._include return params def build_data(self): diff --git a/pubnub/endpoints/space/get_space.py b/pubnub/endpoints/space/get_space.py index 0da54399..8704016f 100644 --- a/pubnub/endpoints/space/get_space.py +++ b/pubnub/endpoints/space/get_space.py @@ -27,7 +27,7 @@ def include(self, data): def custom_params(self): params = {} if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = self._include return params def build_path(self): diff --git a/pubnub/endpoints/space/get_spaces.py b/pubnub/endpoints/space/get_spaces.py index dab60565..010469e1 100644 --- a/pubnub/endpoints/space/get_spaces.py +++ b/pubnub/endpoints/space/get_spaces.py @@ -56,7 +56,7 @@ def custom_params(self): params['limit'] = self._limit if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = self._include return params diff --git a/pubnub/endpoints/space/update_space.py b/pubnub/endpoints/space/update_space.py index 4d72db1d..c480c587 100644 --- a/pubnub/endpoints/space/update_space.py +++ b/pubnub/endpoints/space/update_space.py @@ -33,7 +33,7 @@ def include(self, data): def custom_params(self): params = {} if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = self._include return params def build_data(self): diff --git a/pubnub/endpoints/users/create_user.py b/pubnub/endpoints/users/create_user.py index 8a321773..c28359ce 100644 --- a/pubnub/endpoints/users/create_user.py +++ b/pubnub/endpoints/users/create_user.py @@ -20,7 +20,7 @@ def include(self, data): def custom_params(self): params = {} if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = self._include return params def data(self, data): diff --git a/pubnub/endpoints/users/get_user.py b/pubnub/endpoints/users/get_user.py index ba91ad30..fbaca447 100644 --- a/pubnub/endpoints/users/get_user.py +++ b/pubnub/endpoints/users/get_user.py @@ -1,6 +1,5 @@ import six -from pubnub import utils from pubnub.endpoints.endpoint import Endpoint from pubnub.models.consumer.user import PNGetUserResult from pubnub.enums import HttpMethod, PNOperationType @@ -27,7 +26,7 @@ def include(self, data): def custom_params(self): params = {} if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = self._include return params def build_path(self): diff --git a/pubnub/endpoints/users/get_users.py b/pubnub/endpoints/users/get_users.py index 08074b24..984f0601 100644 --- a/pubnub/endpoints/users/get_users.py +++ b/pubnub/endpoints/users/get_users.py @@ -1,5 +1,5 @@ import six -from pubnub import utils + from pubnub.endpoints.endpoint import Endpoint from pubnub.models.consumer.user import PNGetUsersResult from pubnub.enums import HttpMethod, PNOperationType @@ -56,7 +56,7 @@ def custom_params(self): params['limit'] = self._limit if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = self._include return params diff --git a/pubnub/endpoints/users/update_user.py b/pubnub/endpoints/users/update_user.py index 6b858d5e..c9756974 100644 --- a/pubnub/endpoints/users/update_user.py +++ b/pubnub/endpoints/users/update_user.py @@ -33,7 +33,7 @@ def data(self, data): def custom_params(self): params = {} if self._include: - params['include'] = utils.url_write(self._include) + params['include'] = self._include return params def build_data(self): diff --git a/pubnub/request_handlers/requests_handler.py b/pubnub/request_handlers/requests_handler.py index 452d2add..20ec642a 100644 --- a/pubnub/request_handlers/requests_handler.py +++ b/pubnub/request_handlers/requests_handler.py @@ -2,7 +2,7 @@ import threading import requests import six -import json # noqa # pylint: disable=W0611 +import json # noqa # pylint: disable=W0611 from requests import Session from requests.adapters import HTTPAdapter @@ -189,7 +189,7 @@ def _invoke_request(self, p_options, e_options, base_origin): 'timeout': (e_options.connect_timeout, e_options.request_timeout) } - if e_options.is_post(): + if e_options.is_post() or e_options.is_patch(): args['data'] = e_options.data logger.debug("%s %s %s" % ( e_options.method_string, diff --git a/pubnub/request_handlers/urllib2_handler.py b/pubnub/request_handlers/urllib2_handler.py index 2a98c61b..34aefb04 100644 --- a/pubnub/request_handlers/urllib2_handler.py +++ b/pubnub/request_handlers/urllib2_handler.py @@ -181,7 +181,7 @@ def _invoke_request(p_options, e_options, base_origin): 'timeout': (e_options.connect_timeout, e_options.request_timeout) } - if e_options.is_post(): + if e_options.is_post() or e_options.is_patch(): args['data'] = e_options.data logger.debug("%s %s %s" % (e_options.method_string, url, e_options.data)) else: diff --git a/pubnub/structures.py b/pubnub/structures.py index be2f6fe1..83845907 100644 --- a/pubnub/structures.py +++ b/pubnub/structures.py @@ -41,6 +41,9 @@ def method_string(self): def is_post(self): return self._method is HttpMethod.POST + def is_patch(self): + return self._method is HttpMethod.PATCH + def query_list(self): """ All query keys and values should be already encoded inside a build_params() method""" s = [] From 95b84e212f344508216c25c446710d85a6ada8f2 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sun, 18 Aug 2019 19:24:29 +0200 Subject: [PATCH 20/26] Remove unneeded imports. --- pubnub/endpoints/space/get_space.py | 1 - pubnub/endpoints/space/get_spaces.py | 2 +- pubnub/workers.py | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pubnub/endpoints/space/get_space.py b/pubnub/endpoints/space/get_space.py index 8704016f..39c5b347 100644 --- a/pubnub/endpoints/space/get_space.py +++ b/pubnub/endpoints/space/get_space.py @@ -1,6 +1,5 @@ import six -from pubnub import utils from pubnub.endpoints.endpoint import Endpoint from pubnub.models.consumer.space import PNGetSpaceResult from pubnub.enums import HttpMethod, PNOperationType diff --git a/pubnub/endpoints/space/get_spaces.py b/pubnub/endpoints/space/get_spaces.py index 010469e1..b02af49f 100644 --- a/pubnub/endpoints/space/get_spaces.py +++ b/pubnub/endpoints/space/get_spaces.py @@ -1,5 +1,5 @@ import six -from pubnub import utils + from pubnub.endpoints.endpoint import Endpoint from pubnub.models.consumer.space import PNGetSpacesResult from pubnub.enums import HttpMethod, PNOperationType diff --git a/pubnub/workers.py b/pubnub/workers.py index 3d010e1e..a046ec30 100644 --- a/pubnub/workers.py +++ b/pubnub/workers.py @@ -71,19 +71,19 @@ def _process_incoming_payload(self, message): self._listener_manager.announce_presence(pn_presence_event_result) elif message.is_object: if message.payload['type'] == 'user': - user_result = PNUserResult( + user_result = PNUserResult( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter type=message.payload['event'], data=message.payload['data'] ) self._listener_manager.announce_user(user_result) elif message.payload['type'] == 'space': - space_result = PNSpaceResult( + space_result = PNSpaceResult( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter type=message.payload['event'], data=message.payload['data'] ) self._listener_manager.announce_space(space_result) else: - membership_result = PNMembershipResult( + membership_result = PNMembershipResult( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter type=message.payload['event'], data=message.payload['data'] ) From da36f78b081dcaec789a6c23edec7a8d21a116bd Mon Sep 17 00:00:00 2001 From: QSD_z Date: Mon, 19 Aug 2019 23:06:14 +0200 Subject: [PATCH 21/26] Update user tests. --- tests/functional/users/test_get_user.py | 2 +- tests/functional/users/test_get_users.py | 2 +- tests/helper.py | 8 + tests/integrational/asyncio/test_user.py | 58 +++---- .../fixtures/asyncio/user/create_user.yaml | 23 ++- .../fixtures/asyncio/user/delete_user.yaml | 15 +- .../fixtures/asyncio/user/fetch_user.yaml | 19 +-- .../fixtures/asyncio/user/update_user.yaml | 23 ++- .../fixtures/asyncio/user/users_get.yaml | 27 ++-- .../native_sync/user/create_user.yaml | 24 ++- .../native_sync/user/delete_user.yaml | 14 +- .../fixtures/native_sync/user/fetch_user.yaml | 18 +-- .../native_sync/user/update_user.yaml | 23 ++- .../fixtures/native_sync/user/users_get.yaml | 141 +++++++++++++++--- .../fixtures/tornado/user/create_user.yaml | 26 ++-- .../fixtures/tornado/user/delete_user.yaml | 18 +-- .../fixtures/tornado/user/fetch_user.yaml | 22 ++- .../fixtures/tornado/user/update_user.yaml | 26 ++-- .../fixtures/tornado/user/users_get.yaml | 36 ++--- tests/integrational/native_sync/test_user.py | 57 +++---- tests/integrational/tornado/test_user.py | 52 ++++--- 21 files changed, 358 insertions(+), 276 deletions(-) diff --git a/tests/functional/users/test_get_user.py b/tests/functional/users/test_get_user.py index 3c3743ba..78cc286c 100644 --- a/tests/functional/users/test_get_user.py +++ b/tests/functional/users/test_get_user.py @@ -23,5 +23,5 @@ def test_get_user(): assert user.build_path() == GetUser.GET_USER_PATH % (SUB_KEY, 'foo') params = user.custom_params() - assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' + assert params['include'] == ['a', 'b'] assert AUTH == user.build_params_callback()({})['auth'] diff --git a/tests/functional/users/test_get_users.py b/tests/functional/users/test_get_users.py index 22bb393c..f7655bfe 100644 --- a/tests/functional/users/test_get_users.py +++ b/tests/functional/users/test_get_users.py @@ -17,7 +17,7 @@ def test_get_users(): assert users.build_path() == GetUsers.GET_USERS_PATH % SUB_KEY params = users.custom_params() - assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' + assert params['include'] == ['a', 'b'] assert params['limit'] == 30 assert params['end'] == 'XXX' assert 'count' not in params diff --git a/tests/helper.py b/tests/helper.py index f43134c2..5a354b38 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -59,6 +59,10 @@ message_count_config.subscribe_key = 'demo-36' message_count_config.origin = 'balancer1g.bronze.aws-pdx-1.ps.pn' +objects_config = PNConfiguration() +objects_config.publish_key = 'demo' +objects_config.subscribe_key = 'demo' + def pnconf_copy(): return copy(pnconf) @@ -88,6 +92,10 @@ def pnconf_mc_copy(): return copy(message_count_config) +def pnconf_obj_copy(): + return copy(objects_config) + + sdk_name = "Python-UnitTest" diff --git a/tests/integrational/asyncio/test_user.py b/tests/integrational/asyncio/test_user.py index 6181a2b4..4c509c4f 100644 --- a/tests/integrational/asyncio/test_user.py +++ b/tests/integrational/asyncio/test_user.py @@ -1,6 +1,6 @@ import pytest -from tests.helper import pnconf_copy +from tests.helper import pnconf_obj_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNGetUserResult, @@ -12,15 +12,15 @@ filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_get_users(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.get_users().future() + envelope = yield from pn.get_users().include('custom').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetUsersResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert len(data) == 2 + assert len(data) == 100 assert set(['name', 'id', 'externalId', 'profileUrl', 'email', 'custom', 'created', 'updated', 'eTag']) == set(data[0]) assert set(['name', 'id', 'externalId', 'profileUrl', 'email', @@ -31,33 +31,31 @@ def test_get_users(event_loop): filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_create_user(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - data = {'id': 'user-1', 'name': 'John Doe', - 'externalId': None, 'profileUrl': None, 'email': 'jack@twitter.com'} - envelope = yield from pn.create_user().data(data).future() + data = {'id': 'mg', 'name': 'MAGNUM', 'custom': {'XXX': 'YYYY'}} + envelope = yield from pn.create_user().data(data).include('custom').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNCreateUserResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert data['id'] == 'user-1' - assert data['name'] == 'John Doe' + assert data['id'] == 'mg' + assert data['name'] == 'MAGNUM' assert data['externalId'] is None assert data['profileUrl'] is None - assert data['email'] == 'jack@twitter.com' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert data['email'] is None + assert data['custom'] == {'XXX': 'YYYY'} @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/user/fetch_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_get_user(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.get_user().user_id('user-1').future() + envelope = yield from pn.get_user().user_id('mg').include('custom').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() @@ -65,19 +63,22 @@ def test_get_user(event_loop): assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert set(['name', 'id', 'externalId', 'profileUrl', 'email', - 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'user-1' + 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'mg' + assert data['name'] == 'MAGNUM' + assert data['externalId'] is None + assert data['profileUrl'] is None + assert data['email'] is None + assert data['custom'] == {'XXX': 'YYYY'} @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/user/update_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_update_user(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.update_user().user_id('user-1').data({'name': 'John Doe', - 'externalId': None, 'profileUrl': None, - 'email': 'jack@twitter.com'}).future() + envelope = yield from pn.update_user().user_id('mg').data({'name': 'number 3'}).include('custom').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() @@ -85,21 +86,24 @@ def test_update_user(event_loop): assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert set(['name', 'id', 'externalId', 'profileUrl', 'email', - 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'user-1' - assert data['name'] == 'John Doe' + 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'mg' + assert data['name'] == 'number 3' + assert data['externalId'] is None + assert data['profileUrl'] is None + assert data['email'] is None + assert data['custom'] == {'XXX': 'YYYY'} @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/user/delete_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_delete_user(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.delete_user().user_id('user-1').future() + envelope = yield from pn.delete_user().user_id('mg').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNDeleteUserResult) assert isinstance(envelope.status, PNStatus) - assert envelope.result.data == {} diff --git a/tests/integrational/fixtures/asyncio/user/create_user.yaml b/tests/integrational/fixtures/asyncio/user/create_user.yaml index a57f19d1..8d2fd2ba 100644 --- a/tests/integrational/fixtures/asyncio/user/create_user.yaml +++ b/tests/integrational/fixtures/asyncio/user/create_user.yaml @@ -1,25 +1,20 @@ interactions: - request: - body: '{"id": "user-1", "name": "John Doe", "externalId": null, "profileUrl": - null, "email": "jack@twitter.com"}' + body: '{"id": "mg", "name": "MAGNUM", "custom": {"XXX": "YYYY"}}' headers: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: POST - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users + uri: http://ps.pndsn.com/v1/objects/demo/users?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ - \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ - : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ - \n}" + string: '{"status":200,"data":{"id":"mg","name":"MAGNUM","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-08-19T21:04:00.148418Z","updated":"2019-08-19T21:04:00.148418Z","eTag":"Aaa/h+eBi9elsgE"}}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '319' + Connection: keep-alive + Content-Length: '227' Content-Type: application/json - Date: Sun, 14 Jul 2019 21:56:58 GMT + Date: Mon, 19 Aug 2019 21:04:00 GMT + Server: nginx/1.15.6 status: code: 200 message: OK @@ -28,7 +23,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users - - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=4a32bdb1-122d-4c1d-902b-2ee854c3b151 + - /v1/objects/demo/users + - include=custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=9065de8e-c73a-4fd8-80bc-a59644b08df8 - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/user/delete_user.yaml b/tests/integrational/fixtures/asyncio/user/delete_user.yaml index 08b59ee5..38ca141d 100644 --- a/tests/integrational/fixtures/asyncio/user/delete_user.yaml +++ b/tests/integrational/fixtures/asyncio/user/delete_user.yaml @@ -5,15 +5,16 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: DELETE - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg response: body: - string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":null}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '34' + Connection: keep-alive + Content-Length: '26' Content-Type: application/json - Date: Wed, 17 Jul 2019 18:02:00 GMT + Date: Mon, 19 Aug 2019 21:02:59 GMT + Server: nginx/1.15.6 status: code: 200 message: OK @@ -22,7 +23,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 - - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=b3eb632c-e5da-4649-bd60-bc0a9ecd95ed + - /v1/objects/demo/users/mg + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=1e0a67ef-817e-4f95-a90d-c089b4f6f8d8 - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/user/fetch_user.yaml b/tests/integrational/fixtures/asyncio/user/fetch_user.yaml index 8bf0df7a..38d3edbb 100644 --- a/tests/integrational/fixtures/asyncio/user/fetch_user.yaml +++ b/tests/integrational/fixtures/asyncio/user/fetch_user.yaml @@ -5,19 +5,16 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ - \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ - : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" + string: '{"status":200,"data":{"id":"mg","name":"MAGNUM","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-08-19T21:04:00.148418Z","updated":"2019-08-19T21:04:00.148418Z","eTag":"Aaa/h+eBi9elsgE"}}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '318' + Connection: keep-alive + Content-Length: '227' Content-Type: application/json - Date: Sun, 04 Aug 2019 17:36:22 GMT + Date: Mon, 19 Aug 2019 21:04:07 GMT + Server: nginx/1.15.6 status: code: 200 message: OK @@ -26,7 +23,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 - - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=fa2600b7-d476-4080-8e43-1666b030b661 + - /v1/objects/demo/users/mg + - include=custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=16409448-274c-4414-be17-da487e2f3798 - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/user/update_user.yaml b/tests/integrational/fixtures/asyncio/user/update_user.yaml index 5f5d4535..40d0a85c 100644 --- a/tests/integrational/fixtures/asyncio/user/update_user.yaml +++ b/tests/integrational/fixtures/asyncio/user/update_user.yaml @@ -1,25 +1,20 @@ interactions: - request: - body: '{"id": "user-1", "name": "John Doe", "externalId": null, "profileUrl": - null, "email": "jack@twitter.com"}' + body: '{"name": "number 3"}' headers: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ - \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ - : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ - \n}" + string: '{"status":200,"data":{"id":"mg","name":"number 3","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-08-19T21:04:00.148418Z","updated":"2019-08-19T21:04:59.878283Z","eTag":"Af/+vv+glMjK3gE"}}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '319' + Connection: keep-alive + Content-Length: '229' Content-Type: application/json - Date: Tue, 16 Jul 2019 17:28:55 GMT + Date: Mon, 19 Aug 2019 21:04:59 GMT + Server: nginx/1.15.6 status: code: 200 message: OK @@ -28,7 +23,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 - - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=4c5beff4-a917-4e22-b539-d00806703889 + - /v1/objects/demo/users/mg + - include=custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=9a39324e-5c80-4d99-952e-565748cc858d - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/user/users_get.yaml b/tests/integrational/fixtures/asyncio/user/users_get.yaml index 914e2f81..310c3ece 100644 --- a/tests/integrational/fixtures/asyncio/user/users_get.yaml +++ b/tests/integrational/fixtures/asyncio/user/users_get.yaml @@ -5,25 +5,18 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users + uri: http://ps.pndsn.com/v1/objects/demo/users?include=custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ - ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \ - \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n\ - \ \"created\": \"2019-02-19T13:10:20.893755\",\n \"custom\": {\n\ - \ \"phone\": \"999-999-9999\"\n },\n \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ - ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n \ - \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n ],\n\ - \ \"status\": 200\n}" + string: '{"status":200,"data":[{"id":"3108","name":"azur","externalId":null,"profileUrl":null,"email":"491f2abe.@pn.com","custom":null,"created":"2019-08-16T07:46:33.23638Z","updated":"2019-08-16T07:54:25.842767Z","eTag":"AY3N6Ni2ubyrOA"},{"id":"OVJNQMICNO","name":"SEGFOXYJXD","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:03:06.303625Z","updated":"2019-08-16T08:03:06.303625Z","eTag":"AdWR6Kv47fz3gAE"},{"id":"FZFATJTVGG","name":"XGHICGRVBX","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:03:35.295516Z","updated":"2019-08-16T08:03:35.295516Z","eTag":"AcO2sKG/5t7ZVw"},{"id":"ODZDOEBNWX","name":"KUHDBKFLXI","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:06:17.256709Z","updated":"2019-08-16T08:06:17.256709Z","eTag":"Aa7Y+tPvi4T/GA"},{"id":"CTWFHMLCHA","name":"VMOPKHSWBG","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:08:50.894636Z","updated":"2019-08-16T08:08:50.894636Z","eTag":"AZfXvfXchOST8wE"},{"id":"FPYPHNJZPA","name":"ZHZFSLEMKP","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:10:31.398245Z","updated":"2019-08-16T08:10:31.398245Z","eTag":"AffEh+Kt5uGmrAE"},{"id":"ZBKYHOKPOH","name":"ZXWOMNFJTV","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:10:59.627747Z","updated":"2019-08-16T08:10:59.627747Z","eTag":"AdiW+N/dnpzCoAE"},{"id":"UJNPRWCKNI","name":"VBSHVLMPEO","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:12:02.242563Z","updated":"2019-08-16T08:12:02.242563Z","eTag":"AaeFrJLq79bxMg"},{"id":"YAJNBVKTTY","name":"SZRNRVXLGS","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:13:26.571666Z","updated":"2019-08-16T08:13:26.571666Z","eTag":"AZG6vojJlPjuvwE"},{"id":"QTIVDQJAOJ","name":"XMRZLEINKB","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:51:20.763757Z","updated":"2019-08-16T08:51:20.763757Z","eTag":"AcHMvZj9rpTj/wE"},{"id":"SAHHGSCVBO","name":"LRXSBWCRND","externalId":null,"profileUrl":null,"email":null,"custom":{"text":"CGJYKWBJWS","uncd":"=--+=!=="},"created":"2019-08-16T08:55:18.96962Z","updated":"2019-08-16T08:55:18.96962Z","eTag":"AeWkrM7ducOORA"},{"id":"SRMNJAHHNT","name":"XNQAYAJVQE","externalId":null,"profileUrl":null,"email":null,"custom":{"text":"TQONNXSYTR","uncd":"!!++!!-+"},"created":"2019-08-16T08:55:54.795609Z","updated":"2019-08-16T08:55:54.795609Z","eTag":"Af+0/7Gt6oKBNw"},{"id":"TPTCRFVYZS","name":"ODKJGLOLTY","externalId":null,"profileUrl":null,"email":null,"custom":{"text":"ULRJDNGWFW","uncd":"+-???+--"},"created":"2019-08-16T08:56:40.671708Z","updated":"2019-08-16T08:56:40.671708Z","eTag":"AdHu4IydrIjAfw"},{"id":"ETFSVEPLTS","name":"VEFYZIPITX","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"UGWJNKDV","text":"YOWZPZDATB","uncd":"-?+++?-!"},"created":"2019-08-16T08:58:03.973696Z","updated":"2019-08-16T08:58:03.973696Z","eTag":"AcarrLO0xdmOHw"},{"id":"SGFOFKHTWD","name":"AIKZPVKFNW","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"WOSPJEPS","text":"WUAYARIILQ","uncd":"+???!+!+"},"created":"2019-08-16T10:53:03.989453Z","updated":"2019-08-16T10:53:03.989453Z","eTag":"Abz7j5TvvfC/Rw"},{"id":"FTOCLCUVUO","name":"BWMONOWQNW","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"OQXNKKLN","text":"OJDPGZWIUD","uncd":"+!-=+?=+"},"created":"2019-08-16T10:53:38.020339Z","updated":"2019-08-16T10:53:38.020339Z","eTag":"Acb8ldys/qm3uwE"},{"id":"OXRNFEDKSY","name":"KARPOSQJWY","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"HHCHNHFG","text":"HCPPLMKDHE","uncd":"?-+!=???"},"created":"2019-08-16T10:57:54.702644Z","updated":"2019-08-16T10:57:54.702644Z","eTag":"AebyoP3BmLHv2QE"},{"id":"NVQMPLHYTZ","name":"CVBNCCVOJQ","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"KZWYLFPI","text":"OSSPMUPTVR","uncd":"+=!?++--"},"created":"2019-08-16T10:59:37.301934Z","updated":"2019-08-16T10:59:37.301934Z","eTag":"Ac3WnK7JvOPcVA"},{"id":"DVOXFAVFTE","name":"NMXQTIDLVM","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"XVLCMYNJ","text":"VSXSHNOMSI","uncd":"-+?+==-!"},"created":"2019-08-16T11:02:35.329312Z","updated":"2019-08-16T11:02:35.329312Z","eTag":"AeX7mdCgqeSu7wE"},{"id":"NFPBYFXYCE","name":"JMFVCKIBTE","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"GZBWUIYW","text":"KFRTYPBUEE","uncd":"??+!=-!!"},"created":"2019-08-16T11:05:58.725668Z","updated":"2019-08-16T11:05:58.725668Z","eTag":"Ae69huXki9W/jQE"},{"id":"ZRURJREIKA","name":"KYEUYDXEGM","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T12:05:43.784224Z","updated":"2019-08-16T12:05:43.784224Z","eTag":"Ac6f5pLf7JqGAQ"},{"id":"TEQEEPKLKV","name":"HOMTMXVAHT","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T12:07:04.787204Z","updated":"2019-08-16T12:07:04.787204Z","eTag":"AYymuJP1hsOs+wE"},{"id":"HNLTUANAZK","name":"VKCBVHRFHM","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"OLXSTORS","text":"WPPWSRXMHF","uncd":"+=!?+==!"},"created":"2019-08-16T12:08:10.571082Z","updated":"2019-08-16T12:08:10.571082Z","eTag":"Af+oiruP0p2uRA"},{"id":"WKFRSHRMBD","name":"IJOGVLHDKE","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"PPJLRJEF","text":"IQACMEDCJN","uncd":"-?+?--!+"},"created":"2019-08-16T12:15:10.842681Z","updated":"2019-08-16T12:15:10.842681Z","eTag":"AYKn4c3s37XZEw"},{"id":"HVVBFXUEFB","name":"YVCLLUYBOA","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"FSUPCADP","text":"UVSKSYQVQW","uncd":"?+++=?-+"},"created":"2019-08-16T12:16:00.471351Z","updated":"2019-08-16T12:16:00.471351Z","eTag":"Acnp3vn344uOsQE"},{"id":"TIOSHKXGNA","name":"JLOMGCIRVM","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"DTUGXGCO","text":"TBJLMWLEEX","uncd":"!+!+=!=?"},"created":"2019-08-16T12:17:06.908126Z","updated":"2019-08-16T12:17:06.908126Z","eTag":"AancsayMpP3ZngE"},{"id":"SLEEFDVMJS","name":"WOPJTXCMNR","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"KQRHEDKG","text":"UEWQTBSMIK","uncd":"+=??+-??"},"created":"2019-08-16T12:18:14.282765Z","updated":"2019-08-16T12:18:14.282765Z","eTag":"AcD00KOisrnjhAE"},{"id":"PYTUFWGHFQ","name":"TYFKEOLQYJ","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"BBJXEAGE","text":"VVXTKLMJZP","uncd":"+=!+!?+?"},"created":"2019-08-16T12:20:40.994268Z","updated":"2019-08-16T12:20:40.994268Z","eTag":"Aa2Y4Zmf0r3MkwE"},{"id":"DNWBBHDWNY","name":"JWWQTYBTEV","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"SQTLFWRC","text":"KWBIAKTJWU","uncd":"--+=!?+-"},"created":"2019-08-16T12:21:59.201763Z","updated":"2019-08-16T12:21:59.201763Z","eTag":"Abnf2LjPjai/kgE"},{"id":"ITSMBSAGEY","name":"MOARKTIOXD","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T12:23:14.781585Z","updated":"2019-08-16T12:23:14.781585Z","eTag":"AbD+19mloNiX0wE"},{"id":"EHKQGHQSZN","name":"CBXRBOIVYY","externalId":null,"profileUrl":null,"email":"KCSTUHDTDI@.pn.com","custom":null,"created":"2019-08-16T12:25:29.121119Z","updated":"2019-08-16T12:25:29.121119Z","eTag":"AdD/lOO1/NC3OA"},{"id":"AEEUZRSFHG","name":"FNYEQWVGHW","externalId":null,"profileUrl":null,"email":"RWZYKLWVXH@.pn.com","custom":null,"created":"2019-08-16T12:25:57.194035Z","updated":"2019-08-16T12:25:57.194035Z","eTag":"Abzf/sLBoLWOsAE"},{"id":"GHWJGVRWVL","name":"MXRKPYXUBA","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:10:39.995435Z","updated":"2019-08-16T13:10:39.995435Z","eTag":"AdX7qt3I7OXnIw"},{"id":"XHNKWNBRWR","name":"UMNQDOVLJT","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:11:16.215538Z","updated":"2019-08-16T13:11:16.215538Z","eTag":"AceNxtPMuvDfOA"},{"id":"QFBWHNAEDQ","name":"PBRWGZNWWN","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"KROPTEOI","text":"WETPEVSIOH","uncd":"+---+-?+"},"created":"2019-08-16T13:16:09.919126Z","updated":"2019-08-16T13:16:09.919126Z","eTag":"Afaw7OeHo9vRDA"},{"id":"FWRIDDOVZY","name":"EWLQOXAKUL","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:16:10.398808Z","updated":"2019-08-16T13:16:10.398808Z","eTag":"Aa6j7dX7yKMK"},{"id":"QIJROQBIVK","name":"CKBYFQANOQ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:16:10.864168Z","updated":"2019-08-16T13:16:10.864168Z","eTag":"AYaI2rDV86bwkgE"},{"id":"ADJOHGSJJN","name":"XTVGGOFNVS","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"JTTHFYND","text":"DTSRFIONYC","uncd":"+=!=!+--"},"created":"2019-08-16T13:16:11.286465Z","updated":"2019-08-16T13:16:11.286465Z","eTag":"AZ2Uv+Tk4JeCFg"},{"id":"QEMGCEXDVF","name":"MCILPPWAEL","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"TYSVDWGB","text":"INCZMORGHL","uncd":"+-=?+!++"},"created":"2019-08-16T13:18:30.601156Z","updated":"2019-08-16T13:18:30.601156Z","eTag":"AYifn5im0NG9ggE"},{"id":"FCMAOJUMZD","name":"SQBRFEYQFW","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:18:31.147398Z","updated":"2019-08-16T13:18:31.147398Z","eTag":"AYuD5JnunsnJlgE"},{"id":"ZPXZTGBJMC","name":"UKCWJFQFNF","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:18:31.580071Z","updated":"2019-08-16T13:18:31.580071Z","eTag":"AYjThuC19N3upwE"},{"id":"FYMOADEDHN","name":"AJDYLGENJH","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"VZUPTKYS","text":"NMXINAMLQG","uncd":"--+==-++"},"created":"2019-08-16T13:18:31.930928Z","updated":"2019-08-16T13:18:31.930928Z","eTag":"Aczqn5CGgenB6AE"},{"id":"VILYLRUPKD","name":"AOTODVYODU","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:18:32.306348Z","updated":"2019-08-16T13:18:32.306348Z","eTag":"AYSeu5ekyJmOVA"},{"id":"NVFBQBQVVI","name":"AYFJPJQHVD","externalId":null,"profileUrl":null,"email":"JIZTRKTWES@.pn.com","custom":null,"created":"2019-08-16T13:18:32.779024Z","updated":"2019-08-16T13:18:32.779024Z","eTag":"AfDAvJG/+cqQkQE"},{"id":"BUXGVFPHIF","name":"SVVZJHNWFP","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"BLANLFZZ","text":"GAKEKSTPRA","uncd":"-?=+++=!"},"created":"2019-08-16T13:27:25.984687Z","updated":"2019-08-16T13:27:25.984687Z","eTag":"AdSJ/rWmzcDFAw"},{"id":"GPABYVBOBC","name":"UXKGLQDWTG","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:27:26.410804Z","updated":"2019-08-16T13:27:26.410804Z","eTag":"Ae7UrtySjd76TQ"},{"id":"METGOIZYZB","name":"QLALWNTZNY","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:27:27.054876Z","updated":"2019-08-16T13:27:27.054876Z","eTag":"AbTB6JzEjeXYNQ"},{"id":"CQEBSLNYRY","name":"TGKJIIEFWE","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"FMTKFUJP","text":"XKHZMETPSG","uncd":"-+=-!?=?"},"created":"2019-08-16T13:27:27.533384Z","updated":"2019-08-16T13:27:27.533384Z","eTag":"Ab2rk8CDiMzP9wE"},{"id":"HWYFWZNJVO","name":"PHCBZGALCZ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:27:28.019614Z","updated":"2019-08-16T13:27:28.019614Z","eTag":"AZHimJborfmuyQE"},{"id":"CZDJYIIMVA","name":"FTIAFHSKEJ","externalId":null,"profileUrl":null,"email":"FEAIBGHEPL@.pn.com","custom":null,"created":"2019-08-16T13:27:28.371029Z","updated":"2019-08-16T13:27:28.371029Z","eTag":"Aczohpv816mLhgE"},{"id":"RQQPRVYGBP","name":"EDIUSUDTUN","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"UJKVKAXF","text":"MTSJXUTCWR","uncd":"=?+-?+?="},"created":"2019-08-16T13:28:12.359743Z","updated":"2019-08-16T13:28:12.359743Z","eTag":"Afqg3Of4iZnsmQE"},{"id":"IMYNWXLJPY","name":"UAEAZJANHS","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:28:12.782264Z","updated":"2019-08-16T13:28:12.782264Z","eTag":"AfDO6/y/i+eCLg"},{"id":"MPEVLOMEYM","name":"FNOCNBKYIU","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:28:13.265298Z","updated":"2019-08-16T13:28:13.265298Z","eTag":"AerBxJmkt5iJ/wE"},{"id":"BMWLVDCRLY","name":"OYITRBBJAQ","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"AMICBHGN","text":"YRCEZDBZVA","uncd":"!!===!++"},"created":"2019-08-16T13:28:13.800063Z","updated":"2019-08-16T13:28:13.800063Z","eTag":"AeKerLzFtYXB5gE"},{"id":"JGINMOZHBY","name":"ASUDXIIRTU","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:28:14.318677Z","updated":"2019-08-16T13:28:14.318677Z","eTag":"Acr0pqCu1o7qVg"},{"id":"QRIPUZLBQU","name":"ZUDLPKCCOR","externalId":null,"profileUrl":null,"email":"TCWFJABMNY@.pn.com","custom":null,"created":"2019-08-16T13:28:14.699419Z","updated":"2019-08-16T13:28:14.699419Z","eTag":"Aa/OgeLh7Oa2Pw"},{"id":"DPGUGXKVUH","name":"RBAVJZDJMM","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:42:25.725776Z","updated":"2019-08-16T13:42:25.725776Z","eTag":"AYvgtuTkxa3+MQ"},{"id":"WDQKNALOXV","name":"YRJDFWYVBE","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:42:46.679707Z","updated":"2019-08-16T13:42:46.679707Z","eTag":"AeLWl4jyq+ubvQE"},{"id":"KTGKRAIJHA","name":"NZQDAIKAXX","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:44:11.68776Z","updated":"2019-08-16T13:44:11.68776Z","eTag":"Acr/mOG58tGvSg"},{"id":"NLYSTUSODX","name":"ENPGRQEIGT","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:44:47.748469Z","updated":"2019-08-16T13:44:48.15622Z","eTag":"AaLgxeD5kIOZkAE"},{"id":"VPALGTRFJR","name":"OQEFDRRMRF","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:45:14.26986Z","updated":"2019-08-16T13:45:14.26986Z","eTag":"AZ3TgcnRhuWzuwE"},{"id":"QMOCTKMNFA","name":"ICLVLBQJDJ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:45:35.935131Z","updated":"2019-08-16T13:45:36.236855Z","eTag":"AcW5yvyoktyN4wE"},{"id":"FDHREELNBC","name":"MFDUZTIVSJ","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"NOZYFDUX","text":"ALKMOPZPPN","uncd":"?!-=!?=!"},"created":"2019-08-16T13:46:01.68376Z","updated":"2019-08-16T13:46:01.68376Z","eTag":"AaPX3a+X7vWpaQ"},{"id":"NYFRLXLXVS","name":"OCRWVYQXFX","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:46:02.022135Z","updated":"2019-08-16T13:46:02.022135Z","eTag":"Ad2A1vih1sbOFg"},{"id":"RCKRBEETNY","name":"GTKWWRNHCY","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:46:02.54377Z","updated":"2019-08-16T13:46:02.54377Z","eTag":"Af/5z/eMlsK8Mg"},{"id":"RTXLQTEQKR","name":"TTRQOKGCLF","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"DHRURRMG","text":"OYEKIZBWSS","uncd":"?----!=?"},"created":"2019-08-16T13:46:02.921376Z","updated":"2019-08-16T13:46:02.921376Z","eTag":"AZ/woOeE3NnIjQE"},{"id":"MUNKXFPPME","name":"GYSSAGZSLB","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:46:03.52327Z","updated":"2019-08-16T13:46:03.52327Z","eTag":"AdDqxZKL/vCepgE"},{"id":"XOADTVKZVU","name":"JVBDVMVKHQ","externalId":null,"profileUrl":null,"email":"MVLMRCVWVL@.pn.com","custom":null,"created":"2019-08-16T13:46:03.922267Z","updated":"2019-08-16T13:46:03.922267Z","eTag":"Aab3urPF8Jvk2gE"},{"id":"GCWFNXOWWP","name":"YDGZPDJZAN","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:46:04.624236Z","updated":"2019-08-16T13:46:05.051613Z","eTag":"AdnO0//F8N+hXg"},{"id":"YPMFCCAFVY","name":"EGRYTRERKD","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:50:10.111546Z","updated":"2019-08-16T13:50:10.111546Z","eTag":"AbqQ/sulutzucQ"},{"id":"MNCBSMAUBY","name":"EMEHXQWCAO","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:51:02.654251Z","updated":"2019-08-16T13:51:02.654251Z","eTag":"Aa7J7KXHirribw"},{"id":"LIVQXPMNHB","name":"PLCUUVSJFX","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:51:29.023827Z","updated":"2019-08-16T13:51:29.511293Z","eTag":"AdzmvvH68frLeA"},{"id":"UNQJCTOMFR","name":"MCIORVWKBG","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:51:29.895152Z","updated":"2019-08-16T13:51:29.895152Z","eTag":"AcCGq6HIsrbnHw"},{"id":"AOBISKSGFK","name":"YZOGPBRRRE","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:52:18.157899Z","updated":"2019-08-16T13:52:18.157899Z","eTag":"AZ/Z0vnw0r3qrAE"},{"id":"IOMZDYIXVV","name":"DXEJGDECGP","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:53:18.571826Z","updated":"2019-08-16T13:53:18.840775Z","eTag":"AabFrqms767ixQE"},{"id":"OMFIAFSABC","name":"AZUDRZYQXD","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:53:21.232013Z","updated":"2019-08-16T13:53:21.232013Z","eTag":"AZyC2t3WvcDM/AE"},{"id":"XNHFKOUFSK","name":"NILVAXCRFU","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:53:59.691314Z","updated":"2019-08-16T13:53:59.691314Z","eTag":"AZW+9dHX9LzoqgE"},{"id":"TXVRYDKNBL","name":"SKFBMKRDXJ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:55:01.145786Z","updated":"2019-08-16T13:55:01.145786Z","eTag":"AYXWy//HrKrzCQ"},{"id":"ZIJBWCPKIV","name":"HLGRAZWBZF","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:55:19.375932Z","updated":"2019-08-16T13:55:19.375932Z","eTag":"AczXqcXxtZXbcA"},{"id":"ZPNPYGKYNB","name":"QDRFOXFKKO","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:56:02.138425Z","updated":"2019-08-16T13:56:02.138425Z","eTag":"Ad/EnI7wu/Pm7QE"},{"id":"QWJZQAXPTK","name":"CLORXLKVUM","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:56:43.227105Z","updated":"2019-08-16T13:56:43.666575Z","eTag":"AeHzmcyciJq5Kw"},{"id":"IYXBSGUUWV","name":"PTPNXDHIZQ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:56:46.109453Z","updated":"2019-08-16T13:56:46.109453Z","eTag":"AYeIxMTm7fnVYw"},{"id":"VMKEKRAFHZ","name":"FARQWLCODK","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"EZFZMHUK","text":"TGLZDRNXCQ"},"created":"2019-08-16T13:57:30.474028Z","updated":"2019-08-16T13:57:30.845373Z","eTag":"AYCLg4Cfgu2JpgE"},{"id":"FGLYFKBJWW","name":"IMGAAZDZUY","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"EQCDECQQ","text":"HAGGDPZNEH"},"created":"2019-08-16T13:59:36.387347Z","updated":"2019-08-16T13:59:36.676079Z","eTag":"AZzd9au3zvrNCg"},{"id":"EOSSPEYTLH","name":"VDCYYAKJFM","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"MUOYBOFK","text":"NOLYXLOGTT"},"created":"2019-08-16T14:00:51.185766Z","updated":"2019-08-16T14:00:51.5663Z","eTag":"AfelnffmkNjlzQE"},{"id":"NUPBUHKPFI","name":"SIGWKPIIEG","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:01:10.227494Z","updated":"2019-08-16T14:01:10.227494Z","eTag":"AaH3/u7fp9HiQg"},{"id":"OJUVGURUIY","name":"JASTOMNING","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:01:58.689971Z","updated":"2019-08-16T14:01:58.689971Z","eTag":"AZHT7M7Q6MGYYw"},{"id":"AMAWMAGKMY","name":"EAKIJRWDFZ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:03:14.822497Z","updated":"2019-08-16T14:03:14.822497Z","eTag":"AYXhw9D36pbmAw"},{"id":"GQYKQMHSTH","name":"CNUSRZFGPF","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"OGTFQYAO","text":"BSCMCAUGGW","uncd":"-!?-!+=+"},"created":"2019-08-16T14:04:22.848132Z","updated":"2019-08-16T14:04:23.225084Z","eTag":"AYDGvb3Dm+3/QQ"},{"id":"EFXTVEFOXD","name":"NKXUCYAPCU","externalId":"RJIOPVCMSK","profileUrl":"GVSIFCNBXS","email":"CVLACZQOIT","custom":null,"created":"2019-08-16T14:09:03.280378Z","updated":"2019-08-16T14:09:03.724409Z","eTag":"AYLp6+fnjsSKVA"},{"id":"ZJAVJFVXKA","name":"IMEVEOEBOM","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:09:54.934711Z","updated":"2019-08-16T14:09:54.934711Z","eTag":"Ae/PkIXTvsi4pgE"},{"id":"IEJHQILHLZ","name":"JRMSUFWJIT","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:11:16.389571Z","updated":"2019-08-16T14:11:16.756215Z","eTag":"AdOWkpz7nLXaPA"},{"id":"HKNSPJTSBO","name":"EQUILQEULC","externalId":"WUACVXFYAY","profileUrl":"VEGBHFQATF","email":"JPBSNHHZMO","custom":null,"created":"2019-08-16T14:11:17.259465Z","updated":"2019-08-16T14:11:17.612334Z","eTag":"AZm26byZiIHSwQE"},{"id":"FSKROTRMAU","name":"SWGIUDVCQU","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"FUBZVUDG","text":"CHUKAKCJSZ","uncd":"+++!==--"},"created":"2019-08-16T14:11:20.139482Z","updated":"2019-08-16T14:11:20.508525Z","eTag":"AfG46Irqhc3BZQ"},{"id":"FYMJUJNNVK","name":"CJCODDBZJZ","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"SSBOYJAS","text":"TNYXLTGLKT","uncd":"!!??!==+"},"created":"2019-08-16T14:11:20.954753Z","updated":"2019-08-16T14:11:21.376416Z","eTag":"AcqA1/e1wpjwrQE"},{"id":"FIVMVQTPBF","name":"YCPUBCAZAY","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"YCWUTUBW","text":"QWRADDGIDQ","uncd":"!-+!++!+"},"created":"2019-08-16T14:12:34.859046Z","updated":"2019-08-16T14:12:35.3608Z","eTag":"AZb+uO3epqDfTA"},{"id":"PBSUXXXZXW","name":"HUAUKGZQQU","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:13:13.01875Z","updated":"2019-08-16T14:13:13.377229Z","eTag":"Abvzseir6KeSmQE"},{"id":"CWYOAYBSGT","name":"WJBLWWMIVS","externalId":"ILHJVQVVNL","profileUrl":"LIKLGXGJHS","email":"PHYSLEZCNK","custom":null,"created":"2019-08-16T14:13:13.776457Z","updated":"2019-08-16T14:13:14.278106Z","eTag":"AdK58v3L/7/r7gE"},{"id":"LDMFISBSPY","name":"ZBPJFYMLOL","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"PPXXLKDO","text":"OELEQYNQZW","uncd":"--=-+=-?"},"created":"2019-08-16T14:13:16.630211Z","updated":"2019-08-16T14:13:17.158502Z","eTag":"Ac3H6Kvk8/nS4wE"},{"id":"IIHGWLYLJF","name":"QCIZUKCANU","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"MCFRFHYF","text":"FAYONGCXYZ","uncd":"??=+++=="},"created":"2019-08-16T14:13:17.714708Z","updated":"2019-08-16T14:13:18.039766Z","eTag":"AZr1y6DWrqmQDA"}],"next":"MTAw"}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '737' + Connection: keep-alive + Content-Encoding: gzip Content-Type: application/json - Date: Sun, 04 Aug 2019 18:44:33 GMT + Date: Mon, 19 Aug 2019 21:02:47 GMT + Server: nginx/1.15.6 + Transfer-Encoding: chunked + Vary: Accept-Encoding status: code: 200 message: OK @@ -32,7 +25,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users - - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=2f59bc97-a946-4abe-b1f8-0efebbacde4d + - /v1/objects/demo/users + - include=custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=1055f507-e325-4537-994b-cbcdbffb9b80 - '' version: 1 diff --git a/tests/integrational/fixtures/native_sync/user/create_user.yaml b/tests/integrational/fixtures/native_sync/user/create_user.yaml index c934edcb..41751462 100644 --- a/tests/integrational/fixtures/native_sync/user/create_user.yaml +++ b/tests/integrational/fixtures/native_sync/user/create_user.yaml @@ -1,7 +1,6 @@ interactions: - request: - body: '{"id": "user-1", "name": "John Doe", "externalId": null, "profileUrl": - null, "email": "jack@twitter.com"}' + body: '{"id": "mg", "name": "MAGNUM", "custom": {"XXX": "YYYY"}}' headers: Accept: - '*/*' @@ -10,28 +9,25 @@ interactions: Connection: - keep-alive Content-Length: - - '105' + - '57' User-Agent: - PubNub-Python/4.1.0 method: POST - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users + uri: http://ps.pndsn.com/v1/objects/demo/users?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ - \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ - : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ - \n}" + string: '{"status":200,"data":{"id":"mg","name":"MAGNUM","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-08-19T20:50:08.99614Z","updated":"2019-08-19T20:50:08.99614Z","eTag":"Aaa/h+eBi9elsgE"}}' headers: - Access-Control-Allow-Origin: - - '*' + Connection: + - keep-alive Content-Length: - - '319' + - '225' Content-Type: - application/json Date: - - Sun, 14 Jul 2019 21:57:11 GMT + - Mon, 19 Aug 2019 20:50:09 GMT + Server: + - nginx/1.15.6 status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/user/delete_user.yaml b/tests/integrational/fixtures/native_sync/user/delete_user.yaml index 43a0494a..f3df3f1d 100644 --- a/tests/integrational/fixtures/native_sync/user/delete_user.yaml +++ b/tests/integrational/fixtures/native_sync/user/delete_user.yaml @@ -13,19 +13,21 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: DELETE - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg response: body: - string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":null}' headers: - Access-Control-Allow-Origin: - - '*' + Connection: + - keep-alive Content-Length: - - '34' + - '26' Content-Type: - application/json Date: - - Wed, 17 Jul 2019 18:02:08 GMT + - Mon, 19 Aug 2019 20:48:48 GMT + Server: + - nginx/1.15.6 status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/user/fetch_user.yaml b/tests/integrational/fixtures/native_sync/user/fetch_user.yaml index aa7f39a3..90994828 100644 --- a/tests/integrational/fixtures/native_sync/user/fetch_user.yaml +++ b/tests/integrational/fixtures/native_sync/user/fetch_user.yaml @@ -11,23 +11,21 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ - \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ - : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" + string: '{"status":200,"data":{"id":"mg","name":"MAGNUM","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-08-19T20:50:08.99614Z","updated":"2019-08-19T20:50:08.99614Z","eTag":"Aaa/h+eBi9elsgE"}}' headers: - Access-Control-Allow-Origin: - - '*' + Connection: + - keep-alive Content-Length: - - '318' + - '225' Content-Type: - application/json Date: - - Sun, 04 Aug 2019 17:38:55 GMT + - Mon, 19 Aug 2019 20:51:04 GMT + Server: + - nginx/1.15.6 status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/user/update_user.yaml b/tests/integrational/fixtures/native_sync/user/update_user.yaml index 50c9f17d..cbc3a64a 100644 --- a/tests/integrational/fixtures/native_sync/user/update_user.yaml +++ b/tests/integrational/fixtures/native_sync/user/update_user.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{"name": "number 3"}' headers: Accept: - '*/*' @@ -9,28 +9,25 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '20' User-Agent: - PubNub-Python/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ - \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ - : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ - \n}" + string: '{"status":200,"data":{"id":"mg","name":"number 3","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-08-19T20:50:08.99614Z","updated":"2019-08-19T20:52:17.656249Z","eTag":"Af/+vv+glMjK3gE"}}' headers: - Access-Control-Allow-Origin: - - '*' + Connection: + - keep-alive Content-Length: - - '319' + - '228' Content-Type: - application/json Date: - - Mon, 15 Jul 2019 21:33:34 GMT + - Mon, 19 Aug 2019 20:52:17 GMT + Server: + - nginx/1.15.6 status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/user/users_get.yaml b/tests/integrational/fixtures/native_sync/user/users_get.yaml index 49eb1e21..9a29e3a3 100644 --- a/tests/integrational/fixtures/native_sync/user/users_get.yaml +++ b/tests/integrational/fixtures/native_sync/user/users_get.yaml @@ -11,29 +11,136 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users + uri: http://ps.pndsn.com/v1/objects/demo/users?include=custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ - ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \ - \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n\ - \ \"created\": \"2019-02-19T13:10:20.893755\",\n \"custom\": {\n\ - \ \"phone\": \"999-999-9999\"\n },\n \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ - ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n \ - \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n ],\n\ - \ \"status\": 200\n}" + string: !!binary | + H4sIAAAAAAAAA7TVy3KbMBgF4Hdha4eAhCRgVbC5gyA25tYVsSFxxrdicNJk+u4lM3FM3NRpF+wQ + cxj4Rv8RL8y+zutmz8iA44bMIq9zRv7+wiwXjMxAnhOZIbPJ10W7yp+bql0VT3VRbfKV1SY2zWo1 + ZHbVtlyuilm1Ot4p1vmyXTCCxJcgvy3Yb7sNO9+u28fnzb5uL96C86rI6+L1XYDjpStOvOJxyBFZ + wDKELIAYiln7ULNbfBpDggwQKwqAYPKaK8L8rg0pKaSYLkFz+7PyFebX8M3jRza98awR9U+qqWbo + fpLayfj/bG/f/w8aUeagzGEWchAD9HfOn7kjZxFPsHMQSPkM7xTt5NEzXQntMDKMkycxTGtkTCI1 + 6dUDEQskhHj8hedD7uiZ+2DvGNeoJln02NmecTb2NZXGyYnjzMyx6uhuYvXIwTJPWIAw4aSLnLPc + kZOTdFAHh6UQXhudaRuFsW567shUTpzI8wPHnMaq0SNHlBHHipKA4eXdOcsdOVmZHMpkfu9PQ/Gx + O21BGpjUzoKOJzMzfepqnhP05+E5GfIslEQgXGzPee7oKUvtfuDUqDHWVbc9meqkpu8EvtnxJLHv + Ub3tVK8eJLEYECKQLzwfcu+nwTIe0OvFZvc82nY9M5sGk3jkUKszb+rUjFwv0PwePUDmAAuEthjw + oucs916fQq9s9weRbp+8uxMnVWyqRk4Ypp3DOpvQSZS4xrRHDpQBZhHhMb5Yn/Pce30MfNg+2Kvg + oTl063MTWtH4xlZ8u3NYe5PM1SzqqP15EN/+2lmCIUGfjNtvAAAA//+sls2SmkAUhZ+FbLtQRhR0 + qiiK/waa7gZaWtjFMS5MHBMzWjF5+YA1Ax0zMgvdHwrOx73n3Ou6Nqxhcqw2s/13thmKfnILwiB3 + ClsoU5Qtcps7Gb6pTP98eqmfbRI0iMqY2xFvfvfh+al5rSHLwJAMo/6Q65Ynjw/TwUybaaNex//K + 3gx/4V/3ib46PBGSCXGeZwmOas+YCf8Pp1Y9p0Xq3cUvSwnGi7xkWedXkgCQJBl84HcyHuizidZf + YJe6NiGBMtSDF20X21joY0aZk/lFWeWdY+LGUYAIOm/l7Y7nKItcHHCfd46BbJomkOVex9rjWBlo + +oOu9ByI/+vaDIWHcXha7cONtRYce8zPC48iJjguPL+sQhqymw6q+gXP613jOOARjt2mX14ZlIRX + tHItZncMZBMAYMpSL4PmwBrMdLUe4F4GF7p2sT/v94gov1ZbAgUGeX0P+zFk3O0YWGFc0SL2Mb8L + A05yGnk07xjweb1HWRiiVJiDegwkIF2f/KYg1bO3+oiZXO+ed3RvDJa/9c2EHY9rZ5gJDHxGHOTM + i7mQbTZPCCY8vRMDki5wHCPcMSCRS4OKh3NXYCDJBjCNjxio04EyUlT1+va/o2vnYDn9tjr9HP7Y + qgcx4Mkiw77nxrlQwLGVUZKnEb9x/V8hQOhADP2ggwAdSlESu9DrIJgykIx6GHoh6OdoU0baeNwL + 4ULXhv7ytKOqvUXwOEoFCLhIE4pgyaoOQt152HEKEqW3Q/gLAAD//wKFaVR4pI9bgCdSSggODvAN + DQgJQ6oHgJUesEzAUyqCm4tWxubA/qOhpTH+QECoAwAAAP//tJjLjtowFEC/pWs0NC9IQEIocewk + jh2bPByHXUU7j1aTMkWMNH8/TjVKXAaygS6R7iL3cB/n+h8IO7tuUxe/Mr4T2uYLBZPIF6iEA4OM + SiU0IRH0JgykIIA2GR4YiEIWccZokWhTcbKerFYjU9E0lWJ2N6dtLWzz8vI/E9cXgnSfv4OHlx/F + 0dW7IUM8aJBsgAYBUyRAmgTllev/A0K0DeoqaeoBQorysuFBBfVuWKtuuPsyDkEtem/qKtOeX16P + Z+J6CPPF41H+elrUX3/q3bDNqxznMEm1EzBtYNWEEkZXVcLHr7P5WN13OvbU9RzLGinsz3F9Yc/v + Z3ty7+KXyN9oggM3EPKUpGJIJ2a0pFL4cfkf03GXhhpCnmsZ4+mcxPXPW2/PR8zNxwM7TPQajTNS + Vn7mb9MhH5GCQMQ5iq/6e4a1RWRRslxf3ZzXRS5pjE6G1Wo1UqPW8u+F291PhjfSqJ/jBmn9/fTn + yI29ddQ1vVY9U8Q5DTR9STCLBInD9DZ9yjlW2grRwCDZ+IDCEOBMG1ZrJXB3Y/piLc1Zl5sq17ln + jjE4jesLIW2dnX2wXbmFmr7EQgRIVhAFA4NGAEKqJmD+TRigouLAD/nAoBKFUoWN2Ggq31nsaj1y + vHS5zZeGMXVc056NMziJ63u73duvre04R3bQZ1WZsCJOZZRpswoTRiOQ5DfaWmFZRTICbIBQBpjQ + mkAoBwidw6qLdURfVHJu9/K7MDzTuuzyZ+L6N5R2d/j2Rvfc3rYP+pGuPgWFgmLtoKkZx6UENOvs + 4h0AAP//tFlNc5swEP0vuWaKEZhgcgqyAIFAIPEhwa2HemIncaZx2unPr8gBFMfVjOPmyrwD7+1q + 9+3u5SIQxrFyiZqHayPBGlgXKdErwjjTmTycIqde+tJyVo5/8+9F3wnclAnItkm5Pbzsd/f6Yqzq + mzYWCY7ZLELTxyQqc9Zn/0UECDMZhUk0i9B1siF5kQ3Vu7J4rQqjUQTHHifWIBjfukmEY9yUCU6/ + HJ429otbPOi9AVEBIUaCam4+EypQvbIvF207JxFq1uSx4OtZBCJgGpImE61WF7+9dQeDkVXkwLj6 + VN98w0rxBG4a6/YbJ99Vu+/bxYP+HNKmLmCt4qSJUJQhJ6pYfNkBaPxPd8xYfwW8lTGzj3ETH3QN + gqfHZ7qVth7UCBOWYFYPdOazhpLDMu36M0e0K7KumxajBqV31jnnuvG/vVsnsIADADCMoB9x0zoG + LR7LEizo2tXvdWEUtQOvY6zdt2LaR0x0CT5zDL/iYuhJLjqJP0PP8y0QLG3XHL4j3Lxl2CwOOXzO + RXnQC5MikSUdF12upaPkpOplCy/q0yY+7tulJFC1w1ua+HzETeGS/s9XN/VLuU812yExJYJCLvhM + py0oQ2WXZ19mp9VvAmUOLAd4nuFafAI39Y0f9M9rVfz6jTZ69rEYCkzDCGlto1LskoEKQT9N5y8A + AAD//0KpO4P8A0Jc/ZG6/uGuIQGuYcGe4Ekp+IAosMwENidxl5jG4NYRMKoMLfE2IDDVAQAAAP// + tFrbbpwwEP2W9rXqCpZ7pSgCGwMG7DUY78JbKtE0SUNvIlHy9fW2idfpVpAV6vt54Myc8ZyZQbnp + i3uP9unX4K6CWgzkc55Bmb9OezDjbcHoLsybYkkMZlLq7g2vFfj+xH73HzjVBd1rT6r0IS9zLaEZ + riiLMqGNRyCXUz0LCV20y3kNGd+1zamWfoxTLv8iW/+Awnc/3r/oZiHENE1qjLXXf7f/G4AiIhZd + yJRAMecpan+fc54ECnldoYySFmgClfb2zeRu6g85U5o2154yd8c4dVZbN3fv+I2Ne4C0KyGLpaGP + d1Ag7QkFWSGH0jBeJFAVA97WAm6T6BCDjICupFWSFnqRnp1Loz9dpP4Hy1i5hmk600X6F04J4erT + 4FzdGiQJLnUhIFCGFDdlp828NYsqFLcMndgnTxK2v7+4m7YnC3COj45TfEbo4GEcfg74i86n2+w6 + nkS4BAc+TQ62GDFE0P/m4/iG4U2Mosc4xeeafx6BGRBr/Pbiz4lWmkwYw1Qr1BDDtkhigtMlfJRI + RddseN5qexlS7jISlgVLDiLde++z9/MiNVeBZQTrVyT1gFPd9PH74IDksh8iVzc7Iivaomo2uX5X + opxC0VLYLAnCfFLXK8twLXuWj45TSa370elvHvAt1ZfiRKCIRUwI7W+LsEV4g1kqThwl3uKs43II + 2cb1id70+bM9LzCmVqPHuCd6vwAAAP//tJpbb5swFMc/y/YaLRcgQCZFkQEbbIyBYG5+XNesaZV1 + zbZKyadfWDs4a1aiKN0r+j/4+BzO5eeDVh56ZP5ocPWQ3kF84uSVX5AkoCCxZkWhWCBKctG2Tzc0 + cyQ4UaqLWR+FOMxkskQgZhfzhiL1sET9o2Y1e4Az2zDt13cc/qFrG9qMjbblZn/lEQQaWj9BTl04 + sQPzUBX6PPVK+b82uJ6PaQ6Nydju48PHuhbfW/n2xy67/WyZEuDuCEs/pqpWAAumHPFSSCXOnBbP + NccajqeGbfWWvZe6dnySjsn2+Pa6qgUwx02xk3FRL0FvKv2QUYpJ+Takl0QyJDkDlLMKA3W4xySD + WXUw//Bu0Qf4/tg21XXdPulSqGvvQNve2a63jvbJ7C/kX9akVIIV4KU6CVxH+Yi76pJLOO1Te3j4 + ZE5O2gN1bTsXrDfs0/12tfm5g2nHVR6rKY0KQG2JpIgEWYjPZHXvCUbU8QOc8LPT6tO5dWsy1nqI + xrGuq4L3N98e7Ym54TewtVmmabIsat9JOvuwR/Ms92T+NkNlzsIiRBV4nohkxqpcuiV4T543OHaw + eH2PqjGuWdob6tOZZfRguGNdW1sevujxylirr9830Mk0qkVZcZaAPzdHGCmGRHDR4HLCqb/Padma + ZvYH7QtdVytjc7QbrQfXLgczSHSY2Hkc4ToCMStiVzhhTQ+dzS8AAAD//6Kld4z1jMxMjfA3v9HV + wauJIqcKAAAAAP//tFvLbqswEP2WdlspTYp5ZJEFxkBsbAwOj8AuraK0l9tHKhI1/fqaVqImlYgi + lP1ZeDyemTNnxuS5qvUn0tnsgyynGXIEVdzDC5wICIk9qE9u36jNsAPnvrL9UgjHLREsM6X0X13N + ZrMTPdWPcZKKj/uk4r+49hKC9Tv99OpiCXU1UImPQ8bLOVQuwZZRusRYJBd2KhhpE8sw+6nMEa5N + PO/jt62zm7ya20ztkwWO0pLCOP01p0wRjQLH4WcOgq5lJvGIDVlYnJ9Xv49tTKegTyn+i2uFnVu+ + WdNHk6/uIoWpochP/WWQpcout4B2RmQ5YYOGff3mgEb0bRYozH5qc4xrm4v9pt4l1cdKu2EKtclR + HIQ25UtlMaEQBHm5pKODqM1Jc4AxMsypOe59fMe4Npho/h/8O2xvdvd7NeEHkpcJGxP1K0RYxsjG + slAN2qs8YQ9oxCRJ9k94pwv7DaXbZ+7rVu3vF0oohbRYJOmCI+WbihtGvohd7F9Q5panBObIBLJ7 + 6Q2dBmeNJrpx19mXWNHNxxrpFeZl1enLI5v6ifCIotrz2PWQEExcUGwB+vcU15ha/b7pwlr+qCWb + hxfxuMs/O0uLMeNOErDQU14admgmMx9BZ/LHM63RZGep6ROtVzpqcEbzsc3Su7PrXD/sD69VfQhB + RzpCc+G6NFRbUOahtExwthhkz08t/gIAAP//tFvvb5swEP1btq9VAxhI0klTRcyPNMbYGGIbvjVb + pEarujZZsql//YyaeZdMIouq8PkJ3Ynn4975Xcdn1jbmjR2b9//iKCeU8ZZzYGe5/XD92YicXhke + DD+53TnyTxy3Q5glKNf+/ZUe7dTzPaiFRZOKXOdaQhc6Fko2pU4vWTuG3bqKi5DXf0l2jLMzBRR5 + u9WDt1kwOLAWmIhJktTwHj6riVKimOILivC3MMPA728rjmC283XCV2dJHzdkDHd0RK3zsk5KAmpH + XYuSkQzn76odlp2G/3NTiYC9hDUJuWsnqgJbIbfX5un12PxJ7cZ8p9P0hDhbcpyf39ky8YunuwNT + JJ0XRKecU+AMzZqqirK2yi+12LOP0x+EyEcnvyiAWXrGL79akjs7vHyGfa9mUVxL0krQKM7kJJZU + kumZzf9HKnMqsFTyfAH+FvYNMhrsP9L7i7PVZOFv1zwdz3bfEMwvM71roZlSQIA3cdbyeNZG7xLg + p/MxDS0KUM9W5h4XDtzQG3oHOuXrE3MdJx0XVw8abslxmmIcpRJe0GaiqUUiyJlj6HPSCd3urtLz + vDDoTecYZ+dZL6Wz2T5uf7xuv8ARZYEnFY3mUHUlNJnqUuHoUjuMXZidIXwwDAPUZ0L8F2fZNpqN + iJ6u1uvVwsiS3wAAAP//gnnHxzMsMCLA188DacQ1wMc5NBRYd9Oy7gLt5bME1knGFvjLBlNDAAAA + AP//tFzJbqNAEP2gkcxmtrmxuKFpNjcGmr7FJCPlYI8gGSf210+TGZEyM8KKLK7oHfqpi6pXWw84 + XVFU+9rYLofTKTSsH338BHoeZbqNvF2WIODuEw9ntKrJYhvN4zEtW1f0mVHhf3GjuPKCzgjxS78/ + wk0nJ3NxQYoAgXmAhmdB7lJKF8yy9GGEUQh007JnhfwU9xmIuHw6vsm91l0tNOMs4X6DWQWyRp9t + osDfeMFdLZsbfIbu0jChbc3PnvzBWWvZNK+U0sMe9d3hxTTM53cYWIWhYQcVDtS+Di99yoX0W9K3 + ad9VRWh08XW2pDTFjfdz9tRXrT61fiLB+2FpiEhWogLYW4rjymEeRQuWlMQ5h0VyW6Qms2XPKW7k + U3+zH0Nmx5efHQylO1bRxiepC8bXCoLchFCf3ZWb3OCjD/mDshY/xry9TXBj0YXVZ0kKe9JfPBB7 + OI7c2ssJhtsgcUAFf5ffJWZv0lHslWbqtjbv3Sa4z1YD61r2/srZvgXOmudp3gSkSWG3z6coY4iQ + JUPph3xWNGs989jJf3Bj7JE2R2y+/ZLygwm9wbaO+NZh+Q5Ob8UZZTGpygVLfMMKsbZSVVORb/ER + OMMw9Gvv9hReDu25fY46nYDggxvmFkFZ1sDa8l2eMj/E/Is6+6t0jJUi/92E/Q0AAP//tFxdb5sw + FP0t7WvVlgDB0JfJMdgYY8CAIeZt1Ur30VTVpHZTfv0gWYlZVGtSlPcjxMFc33Ov77GRjo6bgueB + /ub1BvTPjdLoNJxFrIQ47g50MCxFm6I8ZKfQmSrBqMMdj+X4sHe3BUm7sMzWuyj+mDEYp6lc4Frm + gZY9zh/4gjljlD66qH98tZNZpYRJqjBbJW17oEw5gbALO3lSJX+gLNCQu4U4UI4hIWHRZVFspByM + XSbHB47hipEJ5wHPAnOFsf0SfH51tm8/M6QVG9FoTI1UnWpd9iZESkGW4JNCcGLMZa5WOdYWOctT + tU5zUtcfM3bvLGtQfzcLfwkMt3ZMuKU3PwTqH56e+37zI/v+tJ25f2WxkjErsDbkU1HSsoLS6GyC + d3jLxVg1DXuOGxgy9jFuUlSxc/sK+pcg/ia09csT2RBZSqp7QGA1KPqMZuels/RvvEHGmubqjnHT + 7xjXgAPhcaL0PQdy2HJIGNeLRchoUrYh7s5IZ+fS8G3bDQzRdYw76I+vv4LQ8V7uN7NpI6GY4HFV + a9GFMlmVHSbFSfpjiq4hirBQUDOsrSrEEZSEaK6964tP1xdXpksHBm7unW0Pm6W/MImWPW7Mnktr + Ps+iQvJ274SbK+dWaBoswuu6ifDejPMukdlaIgUL9K9EviwTmhcN4jtBrX+LS9JUFKNstd5NE/zt + RqEmhagTOR0Paf5zqYOxu2T7lgMMuWPA/QEAAP//AqszNzIxQT1ZJdKnwEw7LS+rONgbefFglJdj + mJdbWATyPmpPX9cwV39XJ3+KClKC3jE10bME1gqG0IwIAAAA//+0XNty2jAQ/Rb6ygC+Gx6YjO+W + LF+ELF/0VlIypUwzQKZkmq+vDAlIdOpkhvR9H6T17p6z8p7953UkuzOXmRQb0JSHp7UhQSEIYIwB + ipGA/nCREhrWEPy3X2LGq6JD5x1/f2E52dmmpaky18zrzfbFfkTN10L4PHGSkQKWRFxtFGAKEA4o + 8q6jsKaOVzVh67TXUVgFkRuH2ClDIQph4ZIsjlmafzgKu+N3i+dmvbPzb3aWqunyXgf2U7OWv9ka + xORZhDfeiS7ycpE6wlsvqSNA/crDNzWk54oTUpdV1Bee7z1O4ZzEg4RdKs5wOBzM56MeAcHxcprC + +4WZ0acXf7Pj9caU+4qHyLDAfvf9XneZUHHCNoUUZpkkCoGctPougzeByNkHhAdSy3H24oMy45SG + s9ekvPhgMLi7407orbqnu81Mw+4j7yc7lbeKnZRE9MH9zlEnK/V5++N5LwUCqNIKl4UrDPu2XkFd + z2HO51DZ1qtpSV1huQWuF47vR8AXdv4MRp2Gok80b3R75HQOq+ZM6Xt6PtmZY92SlUFsOfyV66vt + zn8ohZTnSUmbpmGNQOZj6tAkYvi2VHgntfVuLElRp3Z/Zh/NdNvW5DHD5eHlabXeW8mKSBN2Xt3m + TssbTGFZWQ1dVNcp+Esa9IVXbljhqsrQdQVDIEFRE8FYxNEibgkKmJclH69gx/PbPCB7ltC92hlj + zZ6qihS43xJzetDRxJ7sbRF4kJ+GgLhEnCRkbgF5VqP8c+Q/RdE0KPEFzpQHKMBthpnImUbzbgy4 + 5wfk6XK829IVrR99Ozt73GmAFfmhR4+t5LCZTh6JNCMAQBzVqEVQyF7sAUYTz8neid0/AAAA//8i + MhB8nd2C3DwikdaUujlG+vu5O0dEIhXj9pCl+njWlMI8Z25ogu/kNqg6Cz0DY0tztOMViwwrzVzC + iwpzA0EbFWOBPk6FLnIFNaYBAAAA//8DAJViOKDQWAAA headers: - Access-Control-Allow-Origin: - - '*' - Content-Length: - - '737' + Connection: + - keep-alive + Content-Encoding: + - gzip Content-Type: - application/json Date: - - Sun, 04 Aug 2019 17:39:02 GMT + - Mon, 19 Aug 2019 20:48:05 GMT + Server: + - nginx/1.15.6 + Vary: + - Accept-Encoding status: code: 200 message: OK diff --git a/tests/integrational/fixtures/tornado/user/create_user.yaml b/tests/integrational/fixtures/tornado/user/create_user.yaml index dbe56ff9..0849bf44 100644 --- a/tests/integrational/fixtures/tornado/user/create_user.yaml +++ b/tests/integrational/fixtures/tornado/user/create_user.yaml @@ -1,40 +1,34 @@ interactions: - request: - body: '{"id": "user-1", "name": "John Doe", "externalId": null, "profileUrl": - null, "email": "jack@twitter.com"}' + body: '{"id": "mg", "name": "MAGNUM", "custom": {"XXX": "YYYY"}}' headers: Accept-Encoding: - utf-8 User-Agent: - PubNub-Python-Tornado/4.1.0 method: POST - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users + uri: http://ps.pndsn.com/v1/objects/demo/users?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ - \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ - : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ - \n}" + string: '{"status":200,"data":{"id":"mg","name":"MAGNUM","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-08-19T20:58:35.105244Z","updated":"2019-08-19T20:58:35.105244Z","eTag":"Aaa/h+eBi9elsgE"}}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Mon, 19 Aug 2019 20:58:35 GMT - !!python/tuple - Content-Type - - application/json - - !!python/tuple - - Date - - - Sun, 14 Jul 2019 21:53:18 GMT - !!python/tuple - Content-Length - - - '319' + - - '227' - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=180dbd47-34a5-4a71-afc8-a8a3097e0eba + url: http://ps.pndsn.com/v1/objects/demo/users?include=custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=7efb3606-842f-4148-b231-fbd69df616fd version: 1 diff --git a/tests/integrational/fixtures/tornado/user/delete_user.yaml b/tests/integrational/fixtures/tornado/user/delete_user.yaml index 872c8dab..665d3922 100644 --- a/tests/integrational/fixtures/tornado/user/delete_user.yaml +++ b/tests/integrational/fixtures/tornado/user/delete_user.yaml @@ -7,28 +7,28 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: DELETE - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg response: body: - string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":null}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Mon, 19 Aug 2019 20:58:14 GMT - !!python/tuple - Content-Type - - application/json - - !!python/tuple - - Date - - - Wed, 17 Jul 2019 18:01:23 GMT - !!python/tuple - Content-Length - - - '34' + - - '26' - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=66f1becc-0f17-4651-aa06-32eb16a07dde + url: http://ps.pndsn.com/v1/objects/demo/users/mg?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=f31366e5-e3e1-4d8c-be9f-3a437c3687de version: 1 diff --git a/tests/integrational/fixtures/tornado/user/fetch_user.yaml b/tests/integrational/fixtures/tornado/user/fetch_user.yaml index 23931493..58b73cb4 100644 --- a/tests/integrational/fixtures/tornado/user/fetch_user.yaml +++ b/tests/integrational/fixtures/tornado/user/fetch_user.yaml @@ -7,32 +7,28 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ - \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ - : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" + string: '{"status":200,"data":{"id":"mg","name":"MAGNUM","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-08-19T20:58:35.105244Z","updated":"2019-08-19T20:58:35.105244Z","eTag":"Aaa/h+eBi9elsgE"}}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Mon, 19 Aug 2019 20:58:40 GMT - !!python/tuple - Content-Type - - application/json - - !!python/tuple - - Date - - - Sun, 04 Aug 2019 17:41:24 GMT - !!python/tuple - Content-Length - - - '318' + - - '227' - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=e998d43a-3fc8-45c0-bb35-11c1ec6d8de6 + url: http://ps.pndsn.com/v1/objects/demo/users/mg?include=custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=b7c0580f-4599-4a9d-aea0-c36f5a8a1e4a version: 1 diff --git a/tests/integrational/fixtures/tornado/user/update_user.yaml b/tests/integrational/fixtures/tornado/user/update_user.yaml index c7957155..04a2c91e 100644 --- a/tests/integrational/fixtures/tornado/user/update_user.yaml +++ b/tests/integrational/fixtures/tornado/user/update_user.yaml @@ -1,40 +1,34 @@ interactions: - request: - body: '{"id": "user-1", "name": "John Doe", "externalId": null, "profileUrl": - null, "email": "jack@twitter.com"}' + body: '{"name": "number 3"}' headers: Accept-Encoding: - utf-8 User-Agent: - PubNub-Python-Tornado/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\",\n\ - \ \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \"id\"\ - : \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\": null,\n \ - \ \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\ - \n}" + string: '{"status":200,"data":{"id":"mg","name":"number 3","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-08-19T20:58:35.105244Z","updated":"2019-08-19T20:58:44.599943Z","eTag":"Af/+vv+glMjK3gE"}}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Mon, 19 Aug 2019 20:58:44 GMT - !!python/tuple - Content-Type - - application/json - - !!python/tuple - - Date - - - Mon, 15 Jul 2019 21:31:40 GMT - !!python/tuple - Content-Length - - - '319' + - - '229' - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/user-1?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=97beb33e-2c8a-4875-b551-56a4bad33c50 + url: http://ps.pndsn.com/v1/objects/demo/users/mg?include=custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=fd7bf2aa-b894-41fb-a7a6-521237ea0a02 version: 1 diff --git a/tests/integrational/fixtures/tornado/user/users_get.yaml b/tests/integrational/fixtures/tornado/user/users_get.yaml index 42451e96..fa14b5a9 100644 --- a/tests/integrational/fixtures/tornado/user/users_get.yaml +++ b/tests/integrational/fixtures/tornado/user/users_get.yaml @@ -7,38 +7,34 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users + uri: http://ps.pndsn.com/v1/objects/demo/users?include=custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ - ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n \ - \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n\ - \ \"created\": \"2019-02-19T13:10:20.893755\",\n \"custom\": {\n\ - \ \"phone\": \"999-999-9999\"\n },\n \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ - ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n \ - \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n ],\n\ - \ \"status\": 200\n}" + string: '{"status":200,"data":[{"id":"3108","name":"azur","externalId":null,"profileUrl":null,"email":"491f2abe.@pn.com","custom":null,"created":"2019-08-16T07:46:33.23638Z","updated":"2019-08-16T07:54:25.842767Z","eTag":"AY3N6Ni2ubyrOA"},{"id":"OVJNQMICNO","name":"SEGFOXYJXD","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:03:06.303625Z","updated":"2019-08-16T08:03:06.303625Z","eTag":"AdWR6Kv47fz3gAE"},{"id":"FZFATJTVGG","name":"XGHICGRVBX","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:03:35.295516Z","updated":"2019-08-16T08:03:35.295516Z","eTag":"AcO2sKG/5t7ZVw"},{"id":"ODZDOEBNWX","name":"KUHDBKFLXI","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:06:17.256709Z","updated":"2019-08-16T08:06:17.256709Z","eTag":"Aa7Y+tPvi4T/GA"},{"id":"CTWFHMLCHA","name":"VMOPKHSWBG","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:08:50.894636Z","updated":"2019-08-16T08:08:50.894636Z","eTag":"AZfXvfXchOST8wE"},{"id":"FPYPHNJZPA","name":"ZHZFSLEMKP","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:10:31.398245Z","updated":"2019-08-16T08:10:31.398245Z","eTag":"AffEh+Kt5uGmrAE"},{"id":"ZBKYHOKPOH","name":"ZXWOMNFJTV","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:10:59.627747Z","updated":"2019-08-16T08:10:59.627747Z","eTag":"AdiW+N/dnpzCoAE"},{"id":"UJNPRWCKNI","name":"VBSHVLMPEO","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:12:02.242563Z","updated":"2019-08-16T08:12:02.242563Z","eTag":"AaeFrJLq79bxMg"},{"id":"YAJNBVKTTY","name":"SZRNRVXLGS","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:13:26.571666Z","updated":"2019-08-16T08:13:26.571666Z","eTag":"AZG6vojJlPjuvwE"},{"id":"QTIVDQJAOJ","name":"XMRZLEINKB","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T08:51:20.763757Z","updated":"2019-08-16T08:51:20.763757Z","eTag":"AcHMvZj9rpTj/wE"},{"id":"SAHHGSCVBO","name":"LRXSBWCRND","externalId":null,"profileUrl":null,"email":null,"custom":{"text":"CGJYKWBJWS","uncd":"=--+=!=="},"created":"2019-08-16T08:55:18.96962Z","updated":"2019-08-16T08:55:18.96962Z","eTag":"AeWkrM7ducOORA"},{"id":"SRMNJAHHNT","name":"XNQAYAJVQE","externalId":null,"profileUrl":null,"email":null,"custom":{"text":"TQONNXSYTR","uncd":"!!++!!-+"},"created":"2019-08-16T08:55:54.795609Z","updated":"2019-08-16T08:55:54.795609Z","eTag":"Af+0/7Gt6oKBNw"},{"id":"TPTCRFVYZS","name":"ODKJGLOLTY","externalId":null,"profileUrl":null,"email":null,"custom":{"text":"ULRJDNGWFW","uncd":"+-???+--"},"created":"2019-08-16T08:56:40.671708Z","updated":"2019-08-16T08:56:40.671708Z","eTag":"AdHu4IydrIjAfw"},{"id":"ETFSVEPLTS","name":"VEFYZIPITX","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"UGWJNKDV","text":"YOWZPZDATB","uncd":"-?+++?-!"},"created":"2019-08-16T08:58:03.973696Z","updated":"2019-08-16T08:58:03.973696Z","eTag":"AcarrLO0xdmOHw"},{"id":"SGFOFKHTWD","name":"AIKZPVKFNW","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"WOSPJEPS","text":"WUAYARIILQ","uncd":"+???!+!+"},"created":"2019-08-16T10:53:03.989453Z","updated":"2019-08-16T10:53:03.989453Z","eTag":"Abz7j5TvvfC/Rw"},{"id":"FTOCLCUVUO","name":"BWMONOWQNW","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"OQXNKKLN","text":"OJDPGZWIUD","uncd":"+!-=+?=+"},"created":"2019-08-16T10:53:38.020339Z","updated":"2019-08-16T10:53:38.020339Z","eTag":"Acb8ldys/qm3uwE"},{"id":"OXRNFEDKSY","name":"KARPOSQJWY","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"HHCHNHFG","text":"HCPPLMKDHE","uncd":"?-+!=???"},"created":"2019-08-16T10:57:54.702644Z","updated":"2019-08-16T10:57:54.702644Z","eTag":"AebyoP3BmLHv2QE"},{"id":"NVQMPLHYTZ","name":"CVBNCCVOJQ","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"KZWYLFPI","text":"OSSPMUPTVR","uncd":"+=!?++--"},"created":"2019-08-16T10:59:37.301934Z","updated":"2019-08-16T10:59:37.301934Z","eTag":"Ac3WnK7JvOPcVA"},{"id":"DVOXFAVFTE","name":"NMXQTIDLVM","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"XVLCMYNJ","text":"VSXSHNOMSI","uncd":"-+?+==-!"},"created":"2019-08-16T11:02:35.329312Z","updated":"2019-08-16T11:02:35.329312Z","eTag":"AeX7mdCgqeSu7wE"},{"id":"NFPBYFXYCE","name":"JMFVCKIBTE","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"GZBWUIYW","text":"KFRTYPBUEE","uncd":"??+!=-!!"},"created":"2019-08-16T11:05:58.725668Z","updated":"2019-08-16T11:05:58.725668Z","eTag":"Ae69huXki9W/jQE"},{"id":"ZRURJREIKA","name":"KYEUYDXEGM","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T12:05:43.784224Z","updated":"2019-08-16T12:05:43.784224Z","eTag":"Ac6f5pLf7JqGAQ"},{"id":"TEQEEPKLKV","name":"HOMTMXVAHT","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T12:07:04.787204Z","updated":"2019-08-16T12:07:04.787204Z","eTag":"AYymuJP1hsOs+wE"},{"id":"HNLTUANAZK","name":"VKCBVHRFHM","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"OLXSTORS","text":"WPPWSRXMHF","uncd":"+=!?+==!"},"created":"2019-08-16T12:08:10.571082Z","updated":"2019-08-16T12:08:10.571082Z","eTag":"Af+oiruP0p2uRA"},{"id":"WKFRSHRMBD","name":"IJOGVLHDKE","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"PPJLRJEF","text":"IQACMEDCJN","uncd":"-?+?--!+"},"created":"2019-08-16T12:15:10.842681Z","updated":"2019-08-16T12:15:10.842681Z","eTag":"AYKn4c3s37XZEw"},{"id":"HVVBFXUEFB","name":"YVCLLUYBOA","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"FSUPCADP","text":"UVSKSYQVQW","uncd":"?+++=?-+"},"created":"2019-08-16T12:16:00.471351Z","updated":"2019-08-16T12:16:00.471351Z","eTag":"Acnp3vn344uOsQE"},{"id":"TIOSHKXGNA","name":"JLOMGCIRVM","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"DTUGXGCO","text":"TBJLMWLEEX","uncd":"!+!+=!=?"},"created":"2019-08-16T12:17:06.908126Z","updated":"2019-08-16T12:17:06.908126Z","eTag":"AancsayMpP3ZngE"},{"id":"SLEEFDVMJS","name":"WOPJTXCMNR","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"KQRHEDKG","text":"UEWQTBSMIK","uncd":"+=??+-??"},"created":"2019-08-16T12:18:14.282765Z","updated":"2019-08-16T12:18:14.282765Z","eTag":"AcD00KOisrnjhAE"},{"id":"PYTUFWGHFQ","name":"TYFKEOLQYJ","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"BBJXEAGE","text":"VVXTKLMJZP","uncd":"+=!+!?+?"},"created":"2019-08-16T12:20:40.994268Z","updated":"2019-08-16T12:20:40.994268Z","eTag":"Aa2Y4Zmf0r3MkwE"},{"id":"DNWBBHDWNY","name":"JWWQTYBTEV","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"SQTLFWRC","text":"KWBIAKTJWU","uncd":"--+=!?+-"},"created":"2019-08-16T12:21:59.201763Z","updated":"2019-08-16T12:21:59.201763Z","eTag":"Abnf2LjPjai/kgE"},{"id":"ITSMBSAGEY","name":"MOARKTIOXD","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T12:23:14.781585Z","updated":"2019-08-16T12:23:14.781585Z","eTag":"AbD+19mloNiX0wE"},{"id":"EHKQGHQSZN","name":"CBXRBOIVYY","externalId":null,"profileUrl":null,"email":"KCSTUHDTDI@.pn.com","custom":null,"created":"2019-08-16T12:25:29.121119Z","updated":"2019-08-16T12:25:29.121119Z","eTag":"AdD/lOO1/NC3OA"},{"id":"AEEUZRSFHG","name":"FNYEQWVGHW","externalId":null,"profileUrl":null,"email":"RWZYKLWVXH@.pn.com","custom":null,"created":"2019-08-16T12:25:57.194035Z","updated":"2019-08-16T12:25:57.194035Z","eTag":"Abzf/sLBoLWOsAE"},{"id":"GHWJGVRWVL","name":"MXRKPYXUBA","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:10:39.995435Z","updated":"2019-08-16T13:10:39.995435Z","eTag":"AdX7qt3I7OXnIw"},{"id":"XHNKWNBRWR","name":"UMNQDOVLJT","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:11:16.215538Z","updated":"2019-08-16T13:11:16.215538Z","eTag":"AceNxtPMuvDfOA"},{"id":"QFBWHNAEDQ","name":"PBRWGZNWWN","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"KROPTEOI","text":"WETPEVSIOH","uncd":"+---+-?+"},"created":"2019-08-16T13:16:09.919126Z","updated":"2019-08-16T13:16:09.919126Z","eTag":"Afaw7OeHo9vRDA"},{"id":"FWRIDDOVZY","name":"EWLQOXAKUL","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:16:10.398808Z","updated":"2019-08-16T13:16:10.398808Z","eTag":"Aa6j7dX7yKMK"},{"id":"QIJROQBIVK","name":"CKBYFQANOQ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:16:10.864168Z","updated":"2019-08-16T13:16:10.864168Z","eTag":"AYaI2rDV86bwkgE"},{"id":"ADJOHGSJJN","name":"XTVGGOFNVS","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"JTTHFYND","text":"DTSRFIONYC","uncd":"+=!=!+--"},"created":"2019-08-16T13:16:11.286465Z","updated":"2019-08-16T13:16:11.286465Z","eTag":"AZ2Uv+Tk4JeCFg"},{"id":"QEMGCEXDVF","name":"MCILPPWAEL","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"TYSVDWGB","text":"INCZMORGHL","uncd":"+-=?+!++"},"created":"2019-08-16T13:18:30.601156Z","updated":"2019-08-16T13:18:30.601156Z","eTag":"AYifn5im0NG9ggE"},{"id":"FCMAOJUMZD","name":"SQBRFEYQFW","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:18:31.147398Z","updated":"2019-08-16T13:18:31.147398Z","eTag":"AYuD5JnunsnJlgE"},{"id":"ZPXZTGBJMC","name":"UKCWJFQFNF","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:18:31.580071Z","updated":"2019-08-16T13:18:31.580071Z","eTag":"AYjThuC19N3upwE"},{"id":"FYMOADEDHN","name":"AJDYLGENJH","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"VZUPTKYS","text":"NMXINAMLQG","uncd":"--+==-++"},"created":"2019-08-16T13:18:31.930928Z","updated":"2019-08-16T13:18:31.930928Z","eTag":"Aczqn5CGgenB6AE"},{"id":"VILYLRUPKD","name":"AOTODVYODU","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:18:32.306348Z","updated":"2019-08-16T13:18:32.306348Z","eTag":"AYSeu5ekyJmOVA"},{"id":"NVFBQBQVVI","name":"AYFJPJQHVD","externalId":null,"profileUrl":null,"email":"JIZTRKTWES@.pn.com","custom":null,"created":"2019-08-16T13:18:32.779024Z","updated":"2019-08-16T13:18:32.779024Z","eTag":"AfDAvJG/+cqQkQE"},{"id":"BUXGVFPHIF","name":"SVVZJHNWFP","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"BLANLFZZ","text":"GAKEKSTPRA","uncd":"-?=+++=!"},"created":"2019-08-16T13:27:25.984687Z","updated":"2019-08-16T13:27:25.984687Z","eTag":"AdSJ/rWmzcDFAw"},{"id":"GPABYVBOBC","name":"UXKGLQDWTG","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:27:26.410804Z","updated":"2019-08-16T13:27:26.410804Z","eTag":"Ae7UrtySjd76TQ"},{"id":"METGOIZYZB","name":"QLALWNTZNY","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:27:27.054876Z","updated":"2019-08-16T13:27:27.054876Z","eTag":"AbTB6JzEjeXYNQ"},{"id":"CQEBSLNYRY","name":"TGKJIIEFWE","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"FMTKFUJP","text":"XKHZMETPSG","uncd":"-+=-!?=?"},"created":"2019-08-16T13:27:27.533384Z","updated":"2019-08-16T13:27:27.533384Z","eTag":"Ab2rk8CDiMzP9wE"},{"id":"HWYFWZNJVO","name":"PHCBZGALCZ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:27:28.019614Z","updated":"2019-08-16T13:27:28.019614Z","eTag":"AZHimJborfmuyQE"},{"id":"CZDJYIIMVA","name":"FTIAFHSKEJ","externalId":null,"profileUrl":null,"email":"FEAIBGHEPL@.pn.com","custom":null,"created":"2019-08-16T13:27:28.371029Z","updated":"2019-08-16T13:27:28.371029Z","eTag":"Aczohpv816mLhgE"},{"id":"RQQPRVYGBP","name":"EDIUSUDTUN","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"UJKVKAXF","text":"MTSJXUTCWR","uncd":"=?+-?+?="},"created":"2019-08-16T13:28:12.359743Z","updated":"2019-08-16T13:28:12.359743Z","eTag":"Afqg3Of4iZnsmQE"},{"id":"IMYNWXLJPY","name":"UAEAZJANHS","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:28:12.782264Z","updated":"2019-08-16T13:28:12.782264Z","eTag":"AfDO6/y/i+eCLg"},{"id":"MPEVLOMEYM","name":"FNOCNBKYIU","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:28:13.265298Z","updated":"2019-08-16T13:28:13.265298Z","eTag":"AerBxJmkt5iJ/wE"},{"id":"BMWLVDCRLY","name":"OYITRBBJAQ","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"AMICBHGN","text":"YRCEZDBZVA","uncd":"!!===!++"},"created":"2019-08-16T13:28:13.800063Z","updated":"2019-08-16T13:28:13.800063Z","eTag":"AeKerLzFtYXB5gE"},{"id":"JGINMOZHBY","name":"ASUDXIIRTU","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:28:14.318677Z","updated":"2019-08-16T13:28:14.318677Z","eTag":"Acr0pqCu1o7qVg"},{"id":"QRIPUZLBQU","name":"ZUDLPKCCOR","externalId":null,"profileUrl":null,"email":"TCWFJABMNY@.pn.com","custom":null,"created":"2019-08-16T13:28:14.699419Z","updated":"2019-08-16T13:28:14.699419Z","eTag":"Aa/OgeLh7Oa2Pw"},{"id":"DPGUGXKVUH","name":"RBAVJZDJMM","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:42:25.725776Z","updated":"2019-08-16T13:42:25.725776Z","eTag":"AYvgtuTkxa3+MQ"},{"id":"WDQKNALOXV","name":"YRJDFWYVBE","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:42:46.679707Z","updated":"2019-08-16T13:42:46.679707Z","eTag":"AeLWl4jyq+ubvQE"},{"id":"KTGKRAIJHA","name":"NZQDAIKAXX","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:44:11.68776Z","updated":"2019-08-16T13:44:11.68776Z","eTag":"Acr/mOG58tGvSg"},{"id":"NLYSTUSODX","name":"ENPGRQEIGT","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:44:47.748469Z","updated":"2019-08-16T13:44:48.15622Z","eTag":"AaLgxeD5kIOZkAE"},{"id":"VPALGTRFJR","name":"OQEFDRRMRF","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:45:14.26986Z","updated":"2019-08-16T13:45:14.26986Z","eTag":"AZ3TgcnRhuWzuwE"},{"id":"QMOCTKMNFA","name":"ICLVLBQJDJ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:45:35.935131Z","updated":"2019-08-16T13:45:36.236855Z","eTag":"AcW5yvyoktyN4wE"},{"id":"FDHREELNBC","name":"MFDUZTIVSJ","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"NOZYFDUX","text":"ALKMOPZPPN","uncd":"?!-=!?=!"},"created":"2019-08-16T13:46:01.68376Z","updated":"2019-08-16T13:46:01.68376Z","eTag":"AaPX3a+X7vWpaQ"},{"id":"NYFRLXLXVS","name":"OCRWVYQXFX","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:46:02.022135Z","updated":"2019-08-16T13:46:02.022135Z","eTag":"Ad2A1vih1sbOFg"},{"id":"RCKRBEETNY","name":"GTKWWRNHCY","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:46:02.54377Z","updated":"2019-08-16T13:46:02.54377Z","eTag":"Af/5z/eMlsK8Mg"},{"id":"RTXLQTEQKR","name":"TTRQOKGCLF","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"DHRURRMG","text":"OYEKIZBWSS","uncd":"?----!=?"},"created":"2019-08-16T13:46:02.921376Z","updated":"2019-08-16T13:46:02.921376Z","eTag":"AZ/woOeE3NnIjQE"},{"id":"MUNKXFPPME","name":"GYSSAGZSLB","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:46:03.52327Z","updated":"2019-08-16T13:46:03.52327Z","eTag":"AdDqxZKL/vCepgE"},{"id":"XOADTVKZVU","name":"JVBDVMVKHQ","externalId":null,"profileUrl":null,"email":"MVLMRCVWVL@.pn.com","custom":null,"created":"2019-08-16T13:46:03.922267Z","updated":"2019-08-16T13:46:03.922267Z","eTag":"Aab3urPF8Jvk2gE"},{"id":"GCWFNXOWWP","name":"YDGZPDJZAN","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:46:04.624236Z","updated":"2019-08-16T13:46:05.051613Z","eTag":"AdnO0//F8N+hXg"},{"id":"YPMFCCAFVY","name":"EGRYTRERKD","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:50:10.111546Z","updated":"2019-08-16T13:50:10.111546Z","eTag":"AbqQ/sulutzucQ"},{"id":"MNCBSMAUBY","name":"EMEHXQWCAO","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:51:02.654251Z","updated":"2019-08-16T13:51:02.654251Z","eTag":"Aa7J7KXHirribw"},{"id":"LIVQXPMNHB","name":"PLCUUVSJFX","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:51:29.023827Z","updated":"2019-08-16T13:51:29.511293Z","eTag":"AdzmvvH68frLeA"},{"id":"UNQJCTOMFR","name":"MCIORVWKBG","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:51:29.895152Z","updated":"2019-08-16T13:51:29.895152Z","eTag":"AcCGq6HIsrbnHw"},{"id":"AOBISKSGFK","name":"YZOGPBRRRE","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:52:18.157899Z","updated":"2019-08-16T13:52:18.157899Z","eTag":"AZ/Z0vnw0r3qrAE"},{"id":"IOMZDYIXVV","name":"DXEJGDECGP","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:53:18.571826Z","updated":"2019-08-16T13:53:18.840775Z","eTag":"AabFrqms767ixQE"},{"id":"OMFIAFSABC","name":"AZUDRZYQXD","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:53:21.232013Z","updated":"2019-08-16T13:53:21.232013Z","eTag":"AZyC2t3WvcDM/AE"},{"id":"XNHFKOUFSK","name":"NILVAXCRFU","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:53:59.691314Z","updated":"2019-08-16T13:53:59.691314Z","eTag":"AZW+9dHX9LzoqgE"},{"id":"TXVRYDKNBL","name":"SKFBMKRDXJ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:55:01.145786Z","updated":"2019-08-16T13:55:01.145786Z","eTag":"AYXWy//HrKrzCQ"},{"id":"ZIJBWCPKIV","name":"HLGRAZWBZF","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:55:19.375932Z","updated":"2019-08-16T13:55:19.375932Z","eTag":"AczXqcXxtZXbcA"},{"id":"ZPNPYGKYNB","name":"QDRFOXFKKO","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:56:02.138425Z","updated":"2019-08-16T13:56:02.138425Z","eTag":"Ad/EnI7wu/Pm7QE"},{"id":"QWJZQAXPTK","name":"CLORXLKVUM","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:56:43.227105Z","updated":"2019-08-16T13:56:43.666575Z","eTag":"AeHzmcyciJq5Kw"},{"id":"IYXBSGUUWV","name":"PTPNXDHIZQ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T13:56:46.109453Z","updated":"2019-08-16T13:56:46.109453Z","eTag":"AYeIxMTm7fnVYw"},{"id":"VMKEKRAFHZ","name":"FARQWLCODK","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"EZFZMHUK","text":"TGLZDRNXCQ"},"created":"2019-08-16T13:57:30.474028Z","updated":"2019-08-16T13:57:30.845373Z","eTag":"AYCLg4Cfgu2JpgE"},{"id":"FGLYFKBJWW","name":"IMGAAZDZUY","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"EQCDECQQ","text":"HAGGDPZNEH"},"created":"2019-08-16T13:59:36.387347Z","updated":"2019-08-16T13:59:36.676079Z","eTag":"AZzd9au3zvrNCg"},{"id":"EOSSPEYTLH","name":"VDCYYAKJFM","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"MUOYBOFK","text":"NOLYXLOGTT"},"created":"2019-08-16T14:00:51.185766Z","updated":"2019-08-16T14:00:51.5663Z","eTag":"AfelnffmkNjlzQE"},{"id":"NUPBUHKPFI","name":"SIGWKPIIEG","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:01:10.227494Z","updated":"2019-08-16T14:01:10.227494Z","eTag":"AaH3/u7fp9HiQg"},{"id":"OJUVGURUIY","name":"JASTOMNING","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:01:58.689971Z","updated":"2019-08-16T14:01:58.689971Z","eTag":"AZHT7M7Q6MGYYw"},{"id":"AMAWMAGKMY","name":"EAKIJRWDFZ","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:03:14.822497Z","updated":"2019-08-16T14:03:14.822497Z","eTag":"AYXhw9D36pbmAw"},{"id":"GQYKQMHSTH","name":"CNUSRZFGPF","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"OGTFQYAO","text":"BSCMCAUGGW","uncd":"-!?-!+=+"},"created":"2019-08-16T14:04:22.848132Z","updated":"2019-08-16T14:04:23.225084Z","eTag":"AYDGvb3Dm+3/QQ"},{"id":"EFXTVEFOXD","name":"NKXUCYAPCU","externalId":"RJIOPVCMSK","profileUrl":"GVSIFCNBXS","email":"CVLACZQOIT","custom":null,"created":"2019-08-16T14:09:03.280378Z","updated":"2019-08-16T14:09:03.724409Z","eTag":"AYLp6+fnjsSKVA"},{"id":"ZJAVJFVXKA","name":"IMEVEOEBOM","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:09:54.934711Z","updated":"2019-08-16T14:09:54.934711Z","eTag":"Ae/PkIXTvsi4pgE"},{"id":"IEJHQILHLZ","name":"JRMSUFWJIT","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:11:16.389571Z","updated":"2019-08-16T14:11:16.756215Z","eTag":"AdOWkpz7nLXaPA"},{"id":"HKNSPJTSBO","name":"EQUILQEULC","externalId":"WUACVXFYAY","profileUrl":"VEGBHFQATF","email":"JPBSNHHZMO","custom":null,"created":"2019-08-16T14:11:17.259465Z","updated":"2019-08-16T14:11:17.612334Z","eTag":"AZm26byZiIHSwQE"},{"id":"FSKROTRMAU","name":"SWGIUDVCQU","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"FUBZVUDG","text":"CHUKAKCJSZ","uncd":"+++!==--"},"created":"2019-08-16T14:11:20.139482Z","updated":"2019-08-16T14:11:20.508525Z","eTag":"AfG46Irqhc3BZQ"},{"id":"FYMJUJNNVK","name":"CJCODDBZJZ","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"SSBOYJAS","text":"TNYXLTGLKT","uncd":"!!??!==+"},"created":"2019-08-16T14:11:20.954753Z","updated":"2019-08-16T14:11:21.376416Z","eTag":"AcqA1/e1wpjwrQE"},{"id":"FIVMVQTPBF","name":"YCPUBCAZAY","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"YCWUTUBW","text":"QWRADDGIDQ","uncd":"!-+!++!+"},"created":"2019-08-16T14:12:34.859046Z","updated":"2019-08-16T14:12:35.3608Z","eTag":"AZb+uO3epqDfTA"},{"id":"PBSUXXXZXW","name":"HUAUKGZQQU","externalId":null,"profileUrl":null,"email":null,"custom":null,"created":"2019-08-16T14:13:13.01875Z","updated":"2019-08-16T14:13:13.377229Z","eTag":"Abvzseir6KeSmQE"},{"id":"CWYOAYBSGT","name":"WJBLWWMIVS","externalId":"ILHJVQVVNL","profileUrl":"LIKLGXGJHS","email":"PHYSLEZCNK","custom":null,"created":"2019-08-16T14:13:13.776457Z","updated":"2019-08-16T14:13:14.278106Z","eTag":"AdK58v3L/7/r7gE"},{"id":"LDMFISBSPY","name":"ZBPJFYMLOL","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"PPXXLKDO","text":"OELEQYNQZW","uncd":"--=-+=-?"},"created":"2019-08-16T14:13:16.630211Z","updated":"2019-08-16T14:13:17.158502Z","eTag":"Ac3H6Kvk8/nS4wE"},{"id":"IIHGWLYLJF","name":"QCIZUKCANU","externalId":null,"profileUrl":null,"email":null,"custom":{"info":"MCFRFHYF","text":"FAYONGCXYZ","uncd":"??=+++=="},"created":"2019-08-16T14:13:17.714708Z","updated":"2019-08-16T14:13:18.039766Z","eTag":"AZr1y6DWrqmQDA"}],"next":"MTAw"}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Mon, 19 Aug 2019 20:58:07 GMT - !!python/tuple - Content-Type - - application/json - !!python/tuple - - Date - - - Sun, 04 Aug 2019 17:41:52 GMT - - !!python/tuple - - Content-Length - - - '737' + - Transfer-Encoding + - - chunked - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 + - !!python/tuple + - Vary + - - Accept-Encoding + - !!python/tuple + - X-Consumed-Content-Encoding + - - gzip status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=e9e04c00-2d03-4409-b1fd-a41f379cdad0 + url: http://ps.pndsn.com/v1/objects/demo/users?include=custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=3abcf5e8-de78-49d6-b261-366a39731f55 version: 1 diff --git a/tests/integrational/native_sync/test_user.py b/tests/integrational/native_sync/test_user.py index de7f3e82..e59540ac 100644 --- a/tests/integrational/native_sync/test_user.py +++ b/tests/integrational/native_sync/test_user.py @@ -1,4 +1,4 @@ -from tests.helper import pnconf_copy +from tests.helper import pnconf_obj_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.structures import Envelope from pubnub.pubnub import PubNub @@ -10,16 +10,16 @@ @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/user/users_get.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_get_users(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.get_users().sync() + envelope = pn.get_users().include('custom').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetUsersResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert len(data) == 2 + assert len(data) == 100 assert set(['name', 'id', 'externalId', 'profileUrl', 'email', 'custom', 'created', 'updated', 'eTag']) == set(data[0]) assert set(['name', 'id', 'externalId', 'profileUrl', 'email', @@ -29,31 +29,30 @@ def test_get_users(): @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/user/create_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_create_user(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.create_user().data({'id': 'user-1', 'name': 'John Doe', - 'externalId': None, 'profileUrl': None, 'email': 'jack@twitter.com'}).sync() + envelope = pn.create_user().data({'id': 'mg', 'name': 'MAGNUM', 'custom': { + 'XXX': 'YYYY'}}).include('custom').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNCreateUserResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert data['id'] == 'user-1' - assert data['name'] == 'John Doe' + assert data['id'] == 'mg' + assert data['name'] == 'MAGNUM' assert data['externalId'] is None assert data['profileUrl'] is None - assert data['email'] == 'jack@twitter.com' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert data['email'] is None + assert data['custom'] == {'XXX': 'YYYY'} @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/user/fetch_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_get_user(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.get_user().user_id('user-1').sync() + envelope = pn.get_user().user_id('mg').include('custom').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() @@ -61,18 +60,21 @@ def test_get_user(): assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert set(['name', 'id', 'externalId', 'profileUrl', 'email', - 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'user-1' + 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'mg' + assert data['name'] == 'MAGNUM' + assert data['externalId'] is None + assert data['profileUrl'] is None + assert data['email'] is None + assert data['custom'] == {'XXX': 'YYYY'} @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/user/update_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_update_user(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.update_user().user_id('user-1').data({'name': 'John Doe', - 'externalId': None, 'profileUrl': None, - 'email': 'jack@twitter.com'}).sync() + envelope = pn.update_user().user_id('mg').data({'name': 'number 3'}).include('custom').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() @@ -80,20 +82,23 @@ def test_update_user(): assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert set(['name', 'id', 'externalId', 'profileUrl', 'email', - 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'user-1' - assert data['name'] == 'John Doe' + 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'mg' + assert data['name'] == 'number 3' + assert data['externalId'] is None + assert data['profileUrl'] is None + assert data['email'] is None + assert data['custom'] == {'XXX': 'YYYY'} @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/user/delete_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_delete_user(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.delete_user().user_id('user-1').sync() + envelope = pn.delete_user().user_id('mg').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNDeleteUserResult) assert isinstance(envelope.status, PNStatus) - assert envelope.result.data == {} diff --git a/tests/integrational/tornado/test_user.py b/tests/integrational/tornado/test_user.py index 7622d840..dbbd1e08 100644 --- a/tests/integrational/tornado/test_user.py +++ b/tests/integrational/tornado/test_user.py @@ -5,28 +5,28 @@ from pubnub.models.consumer.user import (PNGetUsersResult, PNCreateUserResult, PNGetUserResult, PNUpdateUserResult, PNDeleteUserResult) from pubnub.models.consumer.common import PNStatus -from tests.helper import pnconf_copy +from tests.helper import pnconf_obj_copy from tests.integrational.vcr_helper import pn_vcr class TestUser(AsyncTestCase): def setUp(self): AsyncTestCase.setUp(self) - config = pnconf_copy() + config = pnconf_obj_copy() self.pn = PubNubTornado(config, custom_ioloop=self.io_loop) @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/user/users_get.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test - def test_single_channel(self): - envelope = yield self.pn.get_users().future() + def test_get_users(self): + envelope = yield self.pn.get_users().include('custom').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetUsersResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert len(data) == 2 + assert len(data) == 100 assert set(['name', 'id', 'externalId', 'profileUrl', 'email', 'custom', 'created', 'updated', 'eTag']) == set(data[0]) assert set(['name', 'id', 'externalId', 'profileUrl', 'email', @@ -37,29 +37,27 @@ def test_single_channel(self): filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_create_user(self): - data = {'id': 'user-1', 'name': 'John Doe', - 'externalId': None, 'profileUrl': None, 'email': 'jack@twitter.com'} - envelope = yield self.pn.create_user().data(data).future() + data = {'id': 'mg', 'name': 'MAGNUM', 'custom': {'XXX': 'YYYY'}} + envelope = yield self.pn.create_user().data(data).include('custom').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNCreateUserResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert data['id'] == 'user-1' - assert data['name'] == 'John Doe' + assert data['id'] == 'mg' + assert data['name'] == 'MAGNUM' assert data['externalId'] is None assert data['profileUrl'] is None - assert data['email'] == 'jack@twitter.com' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert data['email'] is None + assert data['custom'] == {'XXX': 'YYYY'} self.pn.stop() @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/user/fetch_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_get_user(self): - envelope = yield self.pn.get_user().user_id('user-1').future() + envelope = yield self.pn.get_user().user_id('mg').include('custom').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() @@ -67,17 +65,20 @@ def test_get_user(self): assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert set(['name', 'id', 'externalId', 'profileUrl', 'email', - 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'user-1' + 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'mg' + assert data['name'] == 'MAGNUM' + assert data['externalId'] is None + assert data['profileUrl'] is None + assert data['email'] is None + assert data['custom'] == {'XXX': 'YYYY'} self.pn.stop() @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/user/update_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_update_user(self): - envelope = yield self.pn.update_user().user_id('user-1').data({'name': 'John Doe', - 'externalId': None, 'profileUrl': None, - 'email': 'jack@twitter.com'}).future() + envelope = yield self.pn.update_user().user_id('mg').data({'name': 'number 3'}).include('custom').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() @@ -85,20 +86,23 @@ def test_update_user(self): assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert set(['name', 'id', 'externalId', 'profileUrl', 'email', - 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'user-1' - assert data['name'] == 'John Doe' + 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'mg' + assert data['name'] == 'number 3' + assert data['externalId'] is None + assert data['profileUrl'] is None + assert data['email'] is None + assert data['custom'] == {'XXX': 'YYYY'} self.pn.stop() @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/user/delete_user.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_delete_user(self): - envelope = yield self.pn.delete_user().user_id('user-1').future() + envelope = yield self.pn.delete_user().user_id('mg').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNDeleteUserResult) assert isinstance(envelope.status, PNStatus) - assert envelope.result.data == {} self.pn.stop() From d18ed692b207873a243f9251d50083a184059f35 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Mon, 19 Aug 2019 23:26:09 +0200 Subject: [PATCH 22/26] Update space tests. --- tests/functional/spaces/test_get_space.py | 2 +- tests/functional/spaces/test_get_spaces.py | 2 +- tests/integrational/asyncio/test_space.py | 60 ++++---- .../fixtures/asyncio/space/create_space.yaml | 21 ++- .../fixtures/asyncio/space/delete_space.yaml | 15 +- .../fixtures/asyncio/space/get_space.yaml | 18 ++- .../fixtures/asyncio/space/get_spaces.yaml | 28 ++-- .../fixtures/asyncio/space/update_space.yaml | 21 ++- .../native_sync/space/create_space.yaml | 22 ++- .../native_sync/space/delete_space.yaml | 14 +- .../fixtures/native_sync/space/get_space.yaml | 17 ++- .../native_sync/space/get_spaces.yaml | 134 +++++++++++++++--- .../native_sync/space/update_space.yaml | 21 ++- .../fixtures/tornado/space/create_space.yaml | 24 ++-- .../fixtures/tornado/space/delete_space.yaml | 18 +-- .../fixtures/tornado/space/get_space.yaml | 21 ++- .../fixtures/tornado/space/get_spaces.yaml | 37 +++-- .../fixtures/tornado/space/update_space.yaml | 24 ++-- tests/integrational/native_sync/test_space.py | 59 ++++---- tests/integrational/tornado/test_space.py | 53 ++++--- 20 files changed, 331 insertions(+), 280 deletions(-) diff --git a/tests/functional/spaces/test_get_space.py b/tests/functional/spaces/test_get_space.py index d86a2c95..2f2043d5 100644 --- a/tests/functional/spaces/test_get_space.py +++ b/tests/functional/spaces/test_get_space.py @@ -23,5 +23,5 @@ def test_get_space(): assert space.build_path() == GetSpace.GET_SPACE_PATH % (SUB_KEY, 'foo') params = space.custom_params() - assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' + assert params['include'] == ['a', 'b'] assert AUTH == space.build_params_callback()({})['auth'] diff --git a/tests/functional/spaces/test_get_spaces.py b/tests/functional/spaces/test_get_spaces.py index a0a9e543..b32a43cf 100644 --- a/tests/functional/spaces/test_get_spaces.py +++ b/tests/functional/spaces/test_get_spaces.py @@ -17,7 +17,7 @@ def test_get_spaces(): assert spaces.build_path() == GetSpaces.GET_SPACES_PATH % SUB_KEY params = spaces.custom_params() - assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' + assert params['include'] == ['a', 'b'] assert params['limit'] == 30 assert params['end'] == 'XXX' assert 'count' not in params diff --git a/tests/integrational/asyncio/test_space.py b/tests/integrational/asyncio/test_space.py index eabf0f35..ae57076a 100644 --- a/tests/integrational/asyncio/test_space.py +++ b/tests/integrational/asyncio/test_space.py @@ -1,6 +1,6 @@ import pytest -from tests.helper import pnconf_copy +from tests.helper import pnconf_obj_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope from pubnub.models.consumer.space import (PNGetSpacesResult, PNCreateSpaceResult, PNGetSpaceResult, @@ -12,16 +12,16 @@ filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_get_spaces(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.get_spaces().future() + envelope = yield from pn.get_spaces().include('custom').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetSpacesResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert len(data) == 2 + assert len(data) == 100 assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[0]) assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[1]) @@ -30,76 +30,72 @@ def test_get_spaces(event_loop): filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_create_space(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.create_space().data({'id': 'my-channel', 'name': 'My space', - 'description': 'A space that is mine'}).future() + envelope = yield from pn.create_space().data({'id': 'in_space', 'name': 'some_name', + 'custom': {'a': 3}}).include('custom').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNCreateSpaceResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert data['id'] == 'my-channel' - assert data['name'] == 'My space' - assert data['description'] == 'A space that is mine' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert data['id'] == 'in_space' + assert data['name'] == 'some_name' + assert data['custom'] == {'a': 3} + assert data['description'] is None @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/space/get_space.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_get_space(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.get_space().space_id('my-chanel').future() + envelope = yield from pn.get_space().space_id('in_space').include('custom').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetSpaceResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'my-channel' - assert data['name'] == 'My space' - assert data['description'] == 'A space that is mine' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'in_space' + assert data['name'] == 'some_name' + assert data['custom'] == {'a': 3} + assert data['description'] is None @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/space/update_space.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_update_space(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - data = {'name': 'My space', 'description': 'A space that is mine'} - envelope = yield from pn.update_space().space_id('my-channel').data(data).future() + data = {'description': 'desc'} + envelope = yield from pn.update_space().space_id('in_space').data(data).include('custom').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNUpdateSpaceResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'my-channel' - assert data['name'] == 'My space' - assert data['description'] == 'A space that is mine' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'in_space' + assert data['name'] == 'some_name' + assert data['custom'] == {'a': 3} + assert data['description'] == 'desc' @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/space/delete_space.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_delete_space(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.delete_space().space_id('main').future() + envelope = yield from pn.delete_space().space_id('in_space').future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNDeleteSpaceResult) assert isinstance(envelope.status, PNStatus) - assert envelope.result.data == {} diff --git a/tests/integrational/fixtures/asyncio/space/create_space.yaml b/tests/integrational/fixtures/asyncio/space/create_space.yaml index 8778bf7d..50c25605 100644 --- a/tests/integrational/fixtures/asyncio/space/create_space.yaml +++ b/tests/integrational/fixtures/asyncio/space/create_space.yaml @@ -1,23 +1,20 @@ interactions: - request: - body: '{"id": "my-channel", "name": "My space", "description": "A space that is - mine"}' + body: '{"id": "in_space", "name": "some_name", "custom": {"a": 3}}' headers: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: POST - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces + uri: http://ps.pndsn.com/v1/objects/demo/spaces?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":{"id":"in_space","name":"some_name","description":null,"custom":{"a":3},"created":"2019-08-19T21:24:47.720337Z","updated":"2019-08-19T21:24:47.720337Z","eTag":"AYfFv4PUk4yMOg"}}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '285' + Connection: keep-alive + Content-Length: '198' Content-Type: application/json - Date: Sun, 21 Jul 2019 11:50:35 GMT + Date: Mon, 19 Aug 2019 21:24:47 GMT + Server: nginx/1.15.6 status: code: 200 message: OK @@ -26,7 +23,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces - - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=d4cb114b-f8b6-4eb7-b37d-886a613629c4 + - /v1/objects/demo/spaces + - include=custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=30b485f7-38c6-4e5b-8911-06f5016d415d - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/space/delete_space.yaml b/tests/integrational/fixtures/asyncio/space/delete_space.yaml index ad25f1f1..ca8a4189 100644 --- a/tests/integrational/fixtures/asyncio/space/delete_space.yaml +++ b/tests/integrational/fixtures/asyncio/space/delete_space.yaml @@ -5,15 +5,16 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: DELETE - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main + uri: http://ps.pndsn.com/v1/objects/demo/spaces/in_space response: body: - string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":null}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '34' + Connection: keep-alive + Content-Length: '26' Content-Type: application/json - Date: Sun, 21 Jul 2019 11:50:36 GMT + Date: Mon, 19 Aug 2019 21:24:38 GMT + Server: nginx/1.15.6 status: code: 200 message: OK @@ -22,7 +23,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main - - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=a08a0bdc-6626-4926-ac86-ff77e8af18be + - /v1/objects/demo/spaces/in_space + - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=982fa2bc-479b-4f37-a3a0-1a44f7a00011 - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/space/get_space.yaml b/tests/integrational/fixtures/asyncio/space/get_space.yaml index 0e8f79f2..06ff4816 100644 --- a/tests/integrational/fixtures/asyncio/space/get_space.yaml +++ b/tests/integrational/fixtures/asyncio/space/get_space.yaml @@ -5,18 +5,16 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel + uri: http://ps.pndsn.com/v1/objects/demo/spaces/in_space?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" + string: '{"status":200,"data":{"id":"in_space","name":"some_name","description":null,"custom":{"a":3},"created":"2019-08-19T21:24:47.720337Z","updated":"2019-08-19T21:24:47.720337Z","eTag":"AYfFv4PUk4yMOg"}}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '284' + Connection: keep-alive + Content-Length: '198' Content-Type: application/json - Date: Sun, 04 Aug 2019 17:47:30 GMT + Date: Mon, 19 Aug 2019 21:24:55 GMT + Server: nginx/1.15.6 status: code: 200 message: OK @@ -25,7 +23,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel - - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=87ecbfb8-86c2-4967-82bd-e39c65334189 + - /v1/objects/demo/spaces/in_space + - include=custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=51ba448e-4a65-424f-a1ec-27fb53cf6d6d - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/space/get_spaces.yaml b/tests/integrational/fixtures/asyncio/space/get_spaces.yaml index 8e6d2d6b..0c0b146f 100644 --- a/tests/integrational/fixtures/asyncio/space/get_spaces.yaml +++ b/tests/integrational/fixtures/asyncio/space/get_spaces.yaml @@ -5,26 +5,18 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces + uri: http://ps.pndsn.com/v1/objects/demo/spaces?include=custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": null,\n \"description\": \"A space that is mine\"\ - ,\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"\ - updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n \"created\"\ - : \"2019-02-20T23:11:20.893755\",\n \"custom\": {\n \"motd\":\ - \ \"Always check your spelling!\",\n \"public\": true\n },\n \ - \ \"description\": \"The main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"MUIwQTAwMUItQkRBRC00NDkyLTgyMEMtODg2OUU1N0REMTNBCg==\"\ - ,\n \"prev\": \"M0FFODRENzMtNjY2Qy00RUExLTk4QzktNkY1Q0I2MUJFNDRCCg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 9\n}" + string: '{"status":200,"data":[{"id":"value1","name":"value2","description":"abcd","custom":null,"created":"2019-08-12T22:57:54.167167Z","updated":"2019-08-12T22:57:54.167167Z","eTag":"AaHahZqsyr6AOg"},{"id":"QVHNASRBFJ","name":"KYTGVPDKKX","description":"JEGUOMRNUK","custom":null,"created":"2019-08-18T12:09:59.72272Z","updated":"2019-08-18T12:09:59.72272Z","eTag":"AceoluqQlcyqyQE"},{"id":"WQQUUGJPCV","name":"ZMKFUWNNHT","description":null,"custom":null,"created":"2019-08-18T12:10:00.227479Z","updated":"2019-08-18T12:10:00.227479Z","eTag":"Aam4p9bSz4e6ZA"},{"id":"DODWRIZUPN","name":"YUOZNNNOCI","description":null,"custom":{"info":"YVKCALSJ","text":"JBMGASPFHZ","uncd":"?=!!=!?+"},"created":"2019-08-18T12:10:00.574818Z","updated":"2019-08-18T12:10:00.574818Z","eTag":"AdaR5aWmr4DPKw"},{"id":"GSMKNDROTG","name":"ZZEZRCQMXB","description":null,"custom":null,"created":"2019-08-18T12:10:01.005708Z","updated":"2019-08-18T12:10:01.005708Z","eTag":"AfGkmNjMhu/YUQ"},{"id":"EQHWQCYDSO","name":"ENNXGHTAXO","description":null,"custom":{"info":"IYSHJXBK","text":"HYIZPJRLQE","uncd":"++=?++-="},"created":"2019-08-18T12:10:01.54778Z","updated":"2019-08-18T12:10:01.54778Z","eTag":"AcLY973wnsiCAw"},{"id":"NMLWPOUHLV","name":"ZAGXJVHXZL","description":null,"custom":null,"created":"2019-08-18T12:10:01.873873Z","updated":"2019-08-18T12:10:01.873873Z","eTag":"AY6XzPic6t+aNg"},{"id":"YGVRVMOZIK","name":"FZJWFBWKZM","description":"GKRYWOMDRG","custom":null,"created":"2019-08-18T12:16:37.379839Z","updated":"2019-08-18T12:16:37.848793Z","eTag":"AdGc85ajmIDoXg"},{"id":"PXBRDJJWOI","name":"AOQFCTWRZF","description":null,"custom":{"info":"CJIOSKYG","text":"YWHVBDKUHF","uncd":"=!=?-+-?"},"created":"2019-08-18T12:16:40.302258Z","updated":"2019-08-18T12:16:40.609418Z","eTag":"AbzMs+nb/JmowgE"},{"id":"ZZHUEGVHWM","name":"YUUOXZEKDW","description":null,"custom":{"info":"RDZQEIYH","text":"MVCSBQVYEZ","uncd":"-=--?!=!"},"created":"2019-08-18T12:16:41.154746Z","updated":"2019-08-18T12:16:41.564938Z","eTag":"Ab79ksvrz77S6QE"},{"id":"OTCGLMCVEQ","name":"KLRDJADJSG","description":null,"custom":null,"created":"2019-08-18T12:16:42.062339Z","updated":"2019-08-18T12:16:42.062339Z","eTag":"Adbut8mspafpYw"},{"id":"RWYDVWVTZX","name":"CDDRNYZDMT","description":"EFIFENXTZF","custom":null,"created":"2019-08-18T12:16:42.606681Z","updated":"2019-08-18T12:16:43.105138Z","eTag":"Ae2ooKP4r+XTugE"},{"id":"CLWYFBFQML","name":"TJPULOGVKL","description":null,"custom":null,"created":"2019-08-18T12:16:43.644081Z","updated":"2019-08-18T12:16:43.644081Z","eTag":"AcTn+6Kmmq/1/QE"},{"id":"NYYPTUPMZW","name":"FZDHQVTHYR","description":null,"custom":null,"created":"2019-08-18T12:17:36.59525Z","updated":"2019-08-18T12:17:36.59525Z","eTag":"Afam+JHN5aiD6QE"},{"id":"QOMSOGQBXK","name":"YAAEZHUOLE","description":null,"custom":null,"created":"2019-08-18T12:17:45.98346Z","updated":"2019-08-18T12:17:45.98346Z","eTag":"Ac3EjJij+ZyBUg"},{"id":"BXZLUFSFEJ","name":"FHRXMYBLPQ","description":null,"custom":null,"created":"2019-08-18T12:18:38.721756Z","updated":"2019-08-18T12:18:38.721756Z","eTag":"AYSizPeF26X4bQ"},{"id":"FCOEHHSWVT","name":"DVGINIXGMN","description":null,"custom":null,"created":"2019-08-18T12:19:03.217285Z","updated":"2019-08-18T12:19:03.217285Z","eTag":"Ade92+b65ZOgDw"},{"id":"LGJTNXDMYB","name":"HMOZHZFROD","description":null,"custom":null,"created":"2019-08-18T12:19:52.725769Z","updated":"2019-08-18T12:19:52.725769Z","eTag":"AYuFh+nHge+S9QE"},{"id":"DQWVIKHPQR","name":"JZEGVDPHWT","description":"FAWMPCTWDP","custom":null,"created":"2019-08-18T12:20:43.618912Z","updated":"2019-08-18T12:20:44.002742Z","eTag":"Aeiuq9yv7OvPaQ"},{"id":"BSQWQYPJIN","name":"HSKRUEQVOQ","description":null,"custom":{"info":"CGERPNTQ","text":"HCFEZDSNFF","uncd":"?=-==+-="},"created":"2019-08-18T12:20:46.446655Z","updated":"2019-08-18T12:20:46.839561Z","eTag":"AaKDvayC2475wwE"},{"id":"EHNANWTJIQ","name":"RZZEICBOXA","description":null,"custom":{"info":"ENEKLTVQ","text":"OOLLBVCSRH","uncd":"=!?!==!?"},"created":"2019-08-18T12:20:47.250268Z","updated":"2019-08-18T12:20:47.629433Z","eTag":"AaX2srfuwO3j4gE"},{"id":"PKWMEMBBSV","name":"CAORBKPLSG","description":null,"custom":null,"created":"2019-08-18T12:20:48.051968Z","updated":"2019-08-18T12:20:48.051968Z","eTag":"AZaJh+CH05vCXg"},{"id":"XSLYFXQTKK","name":"DUIXJLANRO","description":"HFMEJZAIZE","custom":null,"created":"2019-08-18T12:20:48.536682Z","updated":"2019-08-18T12:20:48.800611Z","eTag":"AbbDltDTu9KECQ"},{"id":"YFOMDUYJZR","name":"BUOTHUHIRU","description":null,"custom":null,"created":"2019-08-18T12:20:49.428686Z","updated":"2019-08-18T12:20:49.428686Z","eTag":"Ad2J9L+Iur37qgE"},{"id":"AFMOPZQFPV","name":"AJICQOQCDR","description":null,"custom":null,"created":"2019-08-18T12:20:50.313281Z","updated":"2019-08-18T12:20:50.607238Z","eTag":"Aa+W/ozOnN7CAg"},{"id":"LXLAUYQHXO","name":"VLHSKCBDXZ","description":null,"custom":null,"created":"2019-08-18T12:20:51.07498Z","updated":"2019-08-18T12:20:51.07498Z","eTag":"AYn25L3p7PuVvwE"},{"id":"YXZANGEVHS","name":"TSEAPATQJM","description":null,"custom":null,"created":"2019-08-18T14:38:27.290933Z","updated":"2019-08-18T14:38:27.290933Z","eTag":"AfHchq3Y65G2GQ"},{"id":"MNSYHMFMVZ","name":"RYYDPGCJJH","description":"LUWVPOTJCF","custom":null,"created":"2019-08-18T14:49:34.174685Z","updated":"2019-08-18T14:49:34.174685Z","eTag":"AfX+q4jFxNi0fg"},{"id":"OSHBPUZTKF","name":"AXFIFXHIBR","description":null,"custom":null,"created":"2019-08-18T14:49:34.598839Z","updated":"2019-08-18T14:49:34.598839Z","eTag":"AcaRpsqngbqipAE"},{"id":"KPZEUAYCQQ","name":"JBRSPSYWEG","description":null,"custom":{"info":"INQIXPIY","text":"HNTLPLJMYZ","uncd":"!--=+=+="},"created":"2019-08-18T14:49:34.9134Z","updated":"2019-08-18T14:49:34.9134Z","eTag":"Afezp/6b4eTW+wE"},{"id":"QZDHGDTMPV","name":"YNFJGSVJNY","description":null,"custom":null,"created":"2019-08-18T14:49:35.38937Z","updated":"2019-08-18T14:49:35.38937Z","eTag":"AZTBhPLm0PHuOw"},{"id":"GAZJKUDXGE","name":"EOBLJOSSTR","description":null,"custom":{"info":"ANJRKYGG","text":"WSHWGHXDWH","uncd":"=-+????-"},"created":"2019-08-18T14:49:36.020848Z","updated":"2019-08-18T14:49:36.020848Z","eTag":"AYSVvoy12tT8Rg"},{"id":"RSNDNUAVMN","name":"VBKZBHEMGZ","description":null,"custom":null,"created":"2019-08-18T14:49:36.536453Z","updated":"2019-08-18T14:49:36.536453Z","eTag":"AaiwupnzsKGk1QE"},{"id":"PRDUXVPYLH","name":"VJRQDINGJR","description":null,"custom":null,"created":"2019-08-18T14:49:36.966137Z","updated":"2019-08-18T14:49:36.966137Z","eTag":"AY3DzpHxxrGo4AE"},{"id":"JDHZJFVFRM","name":"UWPSLRVSNO","description":"PRYYFBWMKV","custom":null,"created":"2019-08-18T14:49:37.573133Z","updated":"2019-08-18T14:49:37.991219Z","eTag":"AeW5ktq4lIKNXQ"},{"id":"NBMQZAMIKF","name":"TSACRSEPUF","description":null,"custom":{"info":"KBBXPPUT","text":"IYWQBBERLW","uncd":"-+?!===!"},"created":"2019-08-18T14:49:40.414212Z","updated":"2019-08-18T14:49:40.805301Z","eTag":"AaP6pJPEv93eBg"},{"id":"XMDJBTNKHH","name":"NEWTZUBNKL","description":null,"custom":{"info":"EWBTVCMR","text":"NMGTQVTNKG","uncd":"--!+?++="},"created":"2019-08-18T14:49:41.212917Z","updated":"2019-08-18T14:49:41.534113Z","eTag":"AbTp/N6x1s+0dg"},{"id":"XZGINRXJOV","name":"GXHCVVFIVM","description":"MFIVLXFBEV","custom":null,"created":"2019-08-18T14:49:41.963843Z","updated":"2019-08-18T14:49:42.292059Z","eTag":"Af7+iZj3sY+mgwE"},{"id":"MOFWOQCHVY","name":"WDKAKYOKUA","description":null,"custom":null,"created":"2019-08-18T14:49:43.034128Z","updated":"2019-08-18T14:49:43.034128Z","eTag":"AfDuzM7ngoycgAE"},{"id":"PODWPUOJOU","name":"IMDFGXPTGQ","description":null,"custom":null,"created":"2019-08-18T14:49:43.555632Z","updated":"2019-08-18T14:49:43.927589Z","eTag":"AYGVzZLa3baFCg"},{"id":"URYGJZAEDR","name":"DEXBJEQYIR","description":"WGFMZPHMKK","custom":null,"created":"2019-08-18T21:22:38.600658Z","updated":"2019-08-18T21:22:38.600658Z","eTag":"AYfmlcCM/Jz3Og"},{"id":"TPMMEMARDY","name":"VCGXPXNNJK","description":null,"custom":null,"created":"2019-08-18T21:22:39.416745Z","updated":"2019-08-18T21:22:39.416745Z","eTag":"Aey1zd2t9a+p9AE"},{"id":"AWDQWQHHQJ","name":"OZECFKCCAT","description":null,"custom":{"info":"SNGLBDBC","text":"QRMCCLKSTJ","uncd":"++=+?-!-"},"created":"2019-08-18T21:22:39.753019Z","updated":"2019-08-18T21:22:39.753019Z","eTag":"AcfXnqbhrZiLrgE"},{"id":"OYHUISNKUF","name":"GJKIVRQSNH","description":null,"custom":null,"created":"2019-08-18T21:22:40.072012Z","updated":"2019-08-18T21:22:40.072012Z","eTag":"AZmk8KrXqeX+WQ"},{"id":"ZVDFTELRNU","name":"XOMTIYANFZ","description":null,"custom":{"info":"DTPPLRYX","text":"PAHIQLRGLO","uncd":"!++-=-+="},"created":"2019-08-18T21:22:40.656215Z","updated":"2019-08-18T21:22:40.656215Z","eTag":"AejTitaAt6aa5QE"},{"id":"CNJDEVBYJL","name":"IYOUIEJTPA","description":null,"custom":null,"created":"2019-08-18T21:22:41.041639Z","updated":"2019-08-18T21:22:41.041639Z","eTag":"AaXw5oivg8GVDg"},{"id":"NQPQMUJTXE","name":"FRTUYSWIKM","description":null,"custom":null,"created":"2019-08-18T21:22:42.788436Z","updated":"2019-08-18T21:22:42.788436Z","eTag":"AZqL7OPCmdLJRA"},{"id":"VIVYYMYJPO","name":"DCJMVVSFFN","description":"OCHSQMSNYA","custom":null,"created":"2019-08-18T21:23:02.478615Z","updated":"2019-08-18T21:23:02.478615Z","eTag":"AZW284bsm4n/MA"},{"id":"NDVIPIGIPI","name":"ZIJWFMEHUP","description":null,"custom":null,"created":"2019-08-18T21:23:02.979219Z","updated":"2019-08-18T21:23:02.979219Z","eTag":"AefIh5ilu/27Gg"},{"id":"BDQQGJWIYU","name":"EVMSAPGJDZ","description":null,"custom":{"info":"AXCXSJVQ","text":"NMCHPSIWFH","uncd":"-=!+=--+"},"created":"2019-08-18T21:23:03.307516Z","updated":"2019-08-18T21:23:03.307516Z","eTag":"AeCXjN263YrlHA"},{"id":"QDQUDZDTMR","name":"XDUOXCEOBP","description":null,"custom":null,"created":"2019-08-18T21:23:03.829449Z","updated":"2019-08-18T21:23:03.829449Z","eTag":"AaCZ+PD1ioXW6QE"},{"id":"TLPPVRLVQC","name":"WTQFQFHSTI","description":null,"custom":{"info":"ZTESUQKK","text":"SNDOBQQRTU","uncd":"?!=!?-=+"},"created":"2019-08-18T21:23:04.402982Z","updated":"2019-08-18T21:23:04.402982Z","eTag":"Adz7/OCOq7P0kgE"},{"id":"SVONJPGVGE","name":"XJKBIEKRGL","description":null,"custom":null,"created":"2019-08-18T21:23:04.723001Z","updated":"2019-08-18T21:23:04.723001Z","eTag":"AYrw86Cbxdz9XQ"},{"id":"HFRKXPFNYJ","name":"NWNPTDRNMU","description":null,"custom":null,"created":"2019-08-18T21:23:06.205621Z","updated":"2019-08-18T21:23:06.205621Z","eTag":"AcXIg6P5mKWjsQE"},{"id":"NHPCVGQDIB","name":"JZIZIAQVOY","description":null,"custom":null,"created":"2019-08-18T21:23:07.881844Z","updated":"2019-08-18T21:23:07.881844Z","eTag":"AZuU0rHGq9OI/AE"},{"id":"HVUHTPSNJV","name":"OAJBRLOBVA","description":"NGHSPQFTZF","custom":null,"created":"2019-08-18T21:24:14.339679Z","updated":"2019-08-18T21:24:14.339679Z","eTag":"AfKBq9+N4OusvAE"},{"id":"GYCISMASWU","name":"LUSUSXNRKZ","description":null,"custom":null,"created":"2019-08-18T21:24:14.792546Z","updated":"2019-08-18T21:24:14.792546Z","eTag":"AaCq8/ij5MrXfg"},{"id":"XOFEWVPBYT","name":"FZRBIHCNLB","description":null,"custom":{"info":"OVNDXMQL","text":"LYXRISIUIW","uncd":"-++==!+="},"created":"2019-08-18T21:24:15.405803Z","updated":"2019-08-18T21:24:15.405803Z","eTag":"AaDe6t6MiLSlzgE"},{"id":"MCYQMZFFSP","name":"AEOLPETAGN","description":null,"custom":null,"created":"2019-08-18T21:24:15.911298Z","updated":"2019-08-18T21:24:15.911298Z","eTag":"AcuJstya/t6eSQ"},{"id":"QWQZCDGFYF","name":"JSWBHXKUGA","description":null,"custom":{"info":"DEWXFQFW","text":"XDEFVUFTQD","uncd":"!???-!-?"},"created":"2019-08-18T21:24:16.761975Z","updated":"2019-08-18T21:24:16.761975Z","eTag":"AZ6KmcT0hZ6YpAE"},{"id":"MJRGAAKECY","name":"VQJELZXPBY","description":null,"custom":null,"created":"2019-08-18T21:24:17.224998Z","updated":"2019-08-18T21:24:17.224998Z","eTag":"Acn9i8rZr6zA2wE"},{"id":"VVDZSBUGEW","name":"XGQHKCZRKN","description":null,"custom":null,"created":"2019-08-18T21:24:18.982048Z","updated":"2019-08-18T21:24:18.982048Z","eTag":"AdGi4+Ctr8SgjwE"},{"id":"TYYUDVKGQR","name":"LZQDXETTON","description":null,"custom":null,"created":"2019-08-18T21:24:20.520254Z","updated":"2019-08-18T21:24:20.520254Z","eTag":"AZCO9ZTn5ZjTAw"},{"id":"DEYCSZTWEZ","name":"NCQRFEIWMZ","description":null,"custom":null,"created":"2019-08-18T21:24:31.17775Z","updated":"2019-08-18T21:24:31.17775Z","eTag":"Ae/tzNepyr2nGQ"},{"id":"MPKHWUGRCA","name":"MUVMFNZILT","description":null,"custom":null,"created":"2019-08-18T21:25:18.186032Z","updated":"2019-08-18T21:25:18.186032Z","eTag":"AZu3mKDYjeHGmAE"},{"id":"AOOTHKXAXG","name":"FEUJRAIAQJ","description":null,"custom":null,"created":"2019-08-18T21:43:50.769822Z","updated":"2019-08-18T21:43:50.769822Z","eTag":"AZ3LyqD+jIuuuQE"},{"id":"STJCXMQQVE","name":"EBWBMNZQYQ","description":"GVFXNQBHTY","custom":null,"created":"2019-08-19T07:28:48.928273Z","updated":"2019-08-19T07:28:48.928273Z","eTag":"Aai+pozhqZisLA"},{"id":"WRHCCOSNJQ","name":"ULQSKYMSMD","description":"AEKUWSCIWZ","custom":null,"created":"2019-08-19T07:31:05.38396Z","updated":"2019-08-19T07:31:05.38396Z","eTag":"AfrfgornzeayQg"},{"id":"FDMSRIGWGG","name":"UXDWZNMWHL","description":null,"custom":null,"created":"2019-08-19T07:31:05.77799Z","updated":"2019-08-19T07:31:05.77799Z","eTag":"AbfUteLYpO+EKg"},{"id":"IRPMSCNBLR","name":"AKOIADHXSU","description":null,"custom":{"info":"CPSDLMYC","text":"ZHOHXKKZVS","uncd":"!+++??-+"},"created":"2019-08-19T07:31:06.11949Z","updated":"2019-08-19T07:31:06.11949Z","eTag":"Aef7gKbnp5K0VA"},{"id":"WQVTNKVQQN","name":"WYPNCWTLXP","description":null,"custom":null,"created":"2019-08-19T07:31:06.540724Z","updated":"2019-08-19T07:31:06.540724Z","eTag":"AejQxe2CsdKo5gE"},{"id":"IFUVVZPTZA","name":"TYDRBNJEBI","description":null,"custom":{"info":"HFMWWPDR","text":"VYLFSXZODN","uncd":"!+-!=!++"},"created":"2019-08-19T07:31:07.149769Z","updated":"2019-08-19T07:31:07.149769Z","eTag":"Aebzkb3wt7yc+AE"},{"id":"VSKDBSCJPE","name":"DQJLKVSRAM","description":null,"custom":null,"created":"2019-08-19T07:31:07.557496Z","updated":"2019-08-19T07:31:07.557496Z","eTag":"Adf21JzAjreqMA"},{"id":"UDPSXUUMKP","name":"GNWOMKZCHP","description":null,"custom":null,"created":"2019-08-19T07:31:08.884387Z","updated":"2019-08-19T07:31:08.884387Z","eTag":"AfPP2bKa0br4DA"},{"id":"IITFJOEHRR","name":"FTKWXWPMLP","description":null,"custom":null,"created":"2019-08-19T07:31:10.28202Z","updated":"2019-08-19T07:31:10.28202Z","eTag":"AeKIkunpmqyKgQE"},{"id":"CHAJOURONZ","name":"NVSBJMBXMP","description":null,"custom":null,"created":"2019-08-19T07:31:10.907857Z","updated":"2019-08-19T07:31:10.907857Z","eTag":"AeP92Ni54e+FpgE"},{"id":"BKADKLVSPL","name":"XXFOPLCMRF","description":null,"custom":null,"created":"2019-08-19T07:31:11.864586Z","updated":"2019-08-19T07:31:11.864586Z","eTag":"AZG2zeLxz4jInQE"},{"id":"JALDYWSARM","name":"OZVXPGEHAO","description":null,"custom":{"info":"JQZZSODY","text":"TQFJRXCCGQ","uncd":"+?+-!+-="},"created":"2019-08-19T07:31:12.562219Z","updated":"2019-08-19T07:31:12.902189Z","eTag":"Af+5gPy50a3OOQ"},{"id":"KOXMRTRQMQ","name":"XTNHUHJKFR","description":null,"custom":null,"created":"2019-08-19T07:31:13.456612Z","updated":"2019-08-19T07:31:13.456612Z","eTag":"Abuug5Dt7JTgUg"},{"id":"MFRFIGQQAJ","name":"UGGZWTLFBQ","description":null,"custom":{"info":"HDWKUOHR","text":"DNXINOZNAK","uncd":"?=!+?++!"},"created":"2019-08-19T07:31:14.108159Z","updated":"2019-08-19T07:31:14.381965Z","eTag":"AeKckovzsp395gE"},{"id":"IHDKDOOYNQ","name":"MUDDCCVNFP","description":null,"custom":null,"created":"2019-08-19T07:31:15.05718Z","updated":"2019-08-19T07:31:15.05718Z","eTag":"AYrZ0O/pl9bv5wE"},{"id":"OMJKOIHNOF","name":"ERALARDBNP","description":"FNKELHRNGV","custom":null,"created":"2019-08-19T07:31:15.502465Z","updated":"2019-08-19T07:31:15.967798Z","eTag":"AdjajZ3D0/TnVg"},{"id":"GAVSRCLHXJ","name":"XOUKCUCHAH","description":"VHUSMXOAPJ","custom":null,"created":"2019-08-19T07:31:54.394383Z","updated":"2019-08-19T07:31:54.394383Z","eTag":"AaDA9/CRhsn5owE"},{"id":"WDGMXBEUDR","name":"SYXFMHYDYM","description":null,"custom":null,"created":"2019-08-19T07:31:54.718181Z","updated":"2019-08-19T07:31:54.718181Z","eTag":"AezvvM2p4P+oag"},{"id":"NPFSQNTOZJ","name":"BNJQBLILYE","description":null,"custom":{"info":"RKORJISZ","text":"OUSILZNYEP","uncd":"=---!?--"},"created":"2019-08-19T07:31:55.045567Z","updated":"2019-08-19T07:31:55.045567Z","eTag":"Af6Sn7uJwZ3L3gE"},{"id":"TPDUHWODEG","name":"SNQEMYPIMK","description":null,"custom":null,"created":"2019-08-19T07:31:55.388578Z","updated":"2019-08-19T07:31:55.388578Z","eTag":"AYe3nfGXw8Tk3AE"},{"id":"YUOHPJWHVU","name":"HQHXLSQQFL","description":null,"custom":{"info":"KLNEOKGN","text":"EHMKAVJYPM","uncd":"!!?!!??="},"created":"2019-08-19T07:31:56.283689Z","updated":"2019-08-19T07:31:56.283689Z","eTag":"Adeels7v6emADA"},{"id":"TFHMWFTZJY","name":"ICNFWWNXGV","description":null,"custom":null,"created":"2019-08-19T07:31:56.621971Z","updated":"2019-08-19T07:31:56.621971Z","eTag":"AZf3mKXl3uLsXw"},{"id":"OAUJCNYDKO","name":"RGIFONVWEI","description":null,"custom":null,"created":"2019-08-19T07:31:58.33158Z","updated":"2019-08-19T07:31:58.33158Z","eTag":"Af7BkLvc2+KKVA"},{"id":"ZIFEDVAIHQ","name":"CUAMBNWUOW","description":null,"custom":null,"created":"2019-08-19T07:31:59.733232Z","updated":"2019-08-19T07:31:59.733232Z","eTag":"AY3XuePmxJapbw"},{"id":"OTWPAMATZA","name":"ACMQLSMXRH","description":null,"custom":null,"created":"2019-08-19T07:32:00.408933Z","updated":"2019-08-19T07:32:00.408933Z","eTag":"Adafx8iGxaTXzgE"},{"id":"XSENSRDACJ","name":"MKIKPZPRLV","description":null,"custom":null,"created":"2019-08-19T07:32:01.609681Z","updated":"2019-08-19T07:32:01.609681Z","eTag":"AZHKrK3Kzq3srAE"},{"id":"EGDTAOXWRB","name":"EUURFAQVSR","description":null,"custom":{"info":"CHLUHHOB","text":"HVKFLQYZXX","uncd":"+=++++=!"},"created":"2019-08-19T07:32:02.333899Z","updated":"2019-08-19T07:32:02.750111Z","eTag":"AbOVtu/K+rHuzwE"},{"id":"CDNVXVGLDY","name":"PYUNFUSEKW","description":null,"custom":null,"created":"2019-08-19T07:32:03.404042Z","updated":"2019-08-19T07:32:03.404042Z","eTag":"AfS188zRn6invQE"},{"id":"RTCWQGJDES","name":"LFJNQVGAPO","description":null,"custom":{"info":"JRNGVUBI","text":"USDJBKWZHC","uncd":"!=!+?++?"},"created":"2019-08-19T07:32:04.141156Z","updated":"2019-08-19T07:32:04.553559Z","eTag":"AZ7Lgre+iJ3b6AE"},{"id":"EUCYGXITOX","name":"HAASUZANIQ","description":null,"custom":null,"created":"2019-08-19T07:32:05.174579Z","updated":"2019-08-19T07:32:05.174579Z","eTag":"AYGc28LE1syj3QE"},{"id":"RMENEQVKRV","name":"BGIXGXFJNB","description":"YIUTNTSOPC","custom":null,"created":"2019-08-19T07:32:05.755729Z","updated":"2019-08-19T07:32:06.054514Z","eTag":"AbOJjM2y19vanAE"},{"id":"HCGOZXCXQL","name":"GMHSZQLDSW","description":"RYRTTKZDBV","custom":null,"created":"2019-08-19T07:32:42.32839Z","updated":"2019-08-19T07:32:42.32839Z","eTag":"AZCqoff89dy/pQE"},{"id":"XSKVACOWBT","name":"QXKJEODSBC","description":null,"custom":null,"created":"2019-08-19T07:32:42.659385Z","updated":"2019-08-19T07:32:42.659385Z","eTag":"AdLundy4qb6NJw"},{"id":"DZYWZNPCWZ","name":"EKXJPZFNKC","description":null,"custom":{"info":"MZXYSYNF","text":"HDLPFUFSOP","uncd":"-?+-!--="},"created":"2019-08-19T07:32:43.072387Z","updated":"2019-08-19T07:32:43.072387Z","eTag":"AdOK4paw+5a0Wg"}],"next":"MTAw"}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '841' + Connection: keep-alive + Content-Encoding: gzip Content-Type: application/json - Date: Sun, 04 Aug 2019 17:47:30 GMT + Date: Mon, 19 Aug 2019 21:24:54 GMT + Server: nginx/1.15.6 + Transfer-Encoding: chunked + Vary: Accept-Encoding status: code: 200 message: OK @@ -33,7 +25,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces - - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=b1d0b6fd-2356-4969-9a82-89acdc9c4121 + - /v1/objects/demo/spaces + - include=custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=bcf17a92-51a3-4ede-ad5c-975f84ccc235 - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/space/update_space.yaml b/tests/integrational/fixtures/asyncio/space/update_space.yaml index 7d4894b8..ad05a50c 100644 --- a/tests/integrational/fixtures/asyncio/space/update_space.yaml +++ b/tests/integrational/fixtures/asyncio/space/update_space.yaml @@ -1,23 +1,20 @@ interactions: - request: - body: '{"id": "my-channel", "name": "My space", "description": "A space that is - mine"}' + body: '{"description": "desc"}' headers: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-channel + uri: http://ps.pndsn.com/v1/objects/demo/spaces/in_space?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":{"id":"in_space","name":"some_name","description":"desc","custom":{"a":3},"created":"2019-08-19T21:24:47.720337Z","updated":"2019-08-19T21:25:07.19264Z","eTag":"Ad/T8bjmyoKQWw"}}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '285' + Connection: keep-alive + Content-Length: '199' Content-Type: application/json - Date: Sun, 21 Jul 2019 11:50:36 GMT + Date: Mon, 19 Aug 2019 21:25:07 GMT + Server: nginx/1.15.6 status: code: 200 message: OK @@ -26,7 +23,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-channel - - pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=5944dcec-c3e7-4837-a830-f66132e36fad + - /v1/objects/demo/spaces/in_space + - include=custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=116bf7ab-5fa8-4735-8f23-3b458cfc336f - '' version: 1 diff --git a/tests/integrational/fixtures/native_sync/space/create_space.yaml b/tests/integrational/fixtures/native_sync/space/create_space.yaml index 5ed92bf0..ca0b0a18 100644 --- a/tests/integrational/fixtures/native_sync/space/create_space.yaml +++ b/tests/integrational/fixtures/native_sync/space/create_space.yaml @@ -1,7 +1,6 @@ interactions: - request: - body: '{"id": "my-channel", "name": "My space", "description": "A space that is - mine"}' + body: '{"id": "in_space", "name": "some_name", "custom": {"a": 3}}' headers: Accept: - '*/*' @@ -10,26 +9,25 @@ interactions: Connection: - keep-alive Content-Length: - - '79' + - '59' User-Agent: - PubNub-Python/4.1.0 method: POST - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces + uri: http://ps.pndsn.com/v1/objects/demo/spaces?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":{"id":"in_space","name":"some_name","description":null,"custom":{"a":3},"created":"2019-08-19T21:14:43.478021Z","updated":"2019-08-19T21:14:43.478021Z","eTag":"AYfFv4PUk4yMOg"}}' headers: - Access-Control-Allow-Origin: - - '*' + Connection: + - keep-alive Content-Length: - - '285' + - '198' Content-Type: - application/json Date: - - Sun, 21 Jul 2019 11:36:49 GMT + - Mon, 19 Aug 2019 21:14:43 GMT + Server: + - nginx/1.15.6 status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/space/delete_space.yaml b/tests/integrational/fixtures/native_sync/space/delete_space.yaml index e5509d58..ddf34cb6 100644 --- a/tests/integrational/fixtures/native_sync/space/delete_space.yaml +++ b/tests/integrational/fixtures/native_sync/space/delete_space.yaml @@ -13,19 +13,21 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: DELETE - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main + uri: http://ps.pndsn.com/v1/objects/demo/spaces/in_space response: body: - string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":null}' headers: - Access-Control-Allow-Origin: - - '*' + Connection: + - keep-alive Content-Length: - - '34' + - '26' Content-Type: - application/json Date: - - Sun, 21 Jul 2019 11:37:02 GMT + - Mon, 19 Aug 2019 21:14:38 GMT + Server: + - nginx/1.15.6 status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/space/get_space.yaml b/tests/integrational/fixtures/native_sync/space/get_space.yaml index d859d9e7..f0993ecf 100644 --- a/tests/integrational/fixtures/native_sync/space/get_space.yaml +++ b/tests/integrational/fixtures/native_sync/space/get_space.yaml @@ -11,22 +11,21 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel + uri: http://ps.pndsn.com/v1/objects/demo/spaces/in_space?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" + string: '{"status":200,"data":{"id":"in_space","name":"some_name","description":null,"custom":{"a":3},"created":"2019-08-19T21:14:43.478021Z","updated":"2019-08-19T21:14:43.478021Z","eTag":"AYfFv4PUk4yMOg"}}' headers: - Access-Control-Allow-Origin: - - '*' + Connection: + - keep-alive Content-Length: - - '284' + - '198' Content-Type: - application/json Date: - - Sun, 04 Aug 2019 17:45:09 GMT + - Mon, 19 Aug 2019 21:15:34 GMT + Server: + - nginx/1.15.6 status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/space/get_spaces.yaml b/tests/integrational/fixtures/native_sync/space/get_spaces.yaml index 0a09b0d2..65c7baa6 100644 --- a/tests/integrational/fixtures/native_sync/space/get_spaces.yaml +++ b/tests/integrational/fixtures/native_sync/space/get_spaces.yaml @@ -11,30 +11,128 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces + uri: http://ps.pndsn.com/v1/objects/demo/spaces?include=custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": null,\n \"description\": \"A space that is mine\"\ - ,\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"\ - updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n \"created\"\ - : \"2019-02-20T23:11:20.893755\",\n \"custom\": {\n \"motd\":\ - \ \"Always check your spelling!\",\n \"public\": true\n },\n \ - \ \"description\": \"The main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"MUIwQTAwMUItQkRBRC00NDkyLTgyMEMtODg2OUU1N0REMTNBCg==\"\ - ,\n \"prev\": \"M0FFODRENzMtNjY2Qy00RUExLTk4QzktNkY1Q0I2MUJFNDRCCg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 9\n}" + string: !!binary | + H4sIAAAAAAAAA6SVW2+qQBSFf4u8WiwgMEBiDAJyv9/nPKHS1tZLq9ie2pz/frCpDm3PUZImvAxZ + M/Mt1t6bN2xbFdVuiwkUQVxhs6IqMOHXGzafYQL2XCx2JYldYatiWR7XVL2eldvpZv5Yzder+nUx + mc7ql9PdtlovMWG1Wyzq1aYsqvJwCkWQPE5wOElFFCUwQGDoHsmC+oH1rt3jrJWujIrbWiQWWnEH + n7avG1Z0b7E/Vx+ofqI5YhiMxgbCNfNITTzZNLNvyIaixq4dOLHZBpyLSEogeIHhe4CiAPUf7n/J + jtjTcr3YPfmL6evTq68g7tT341g1PClB3NA2x3HqOFr0lfuDsBUvSQgE0as5aMCfA/6qO33oJf3I + T8I9XbJQRMCyK6eBDmPPQcB57ELHcVxJPw9cH7G6WR82JKYkWuEhq6r8XR0CGdmqGHpj7R11NT1c + NRx0OoPOsFtffsElA2iO5C67RLqjy1kRMEW63NCyZ74gl2pom44cuJHaiAUqMJB8Oxv9NBayRxAM + IC4CN3VH4Bv1Yenc23e76zz2EbDia6kv5XLoImDFcTJVi8TMbRmLnoeakY1MFIuW69AzAqsu2VMs + 3e5g2O3ig0uxkD2GBqCFyZPs1CxWzoP+y2o7l8RGKI5tpZ4ba1azV0Q1MxItg9bPQ+FAv34u8yLd + EThns703n7JVt3AaQylXkyCxXaibCHgMjXQ8Sk1ofxtKqhnkqWvLgdp6KJGs0Ae9PuC5/vkmf9dx + NAf4T+Azdcoxxf1Sl9dZA9zLRoFsGKmrI3DR9cdSlAZw3LKaJEN3QzNXUTXlqZaMZDPWxqiaBp3B + EO/iw7PVxAo00esTFMWcL6d3HUvw9Ocmn+ztbXc1uTaW65fbxvCFUIsVNdFSuznLYjeDiimnLW0G + MvQVPdeQTTuRwpGf5EpjluEDHB/W0+ySTbJH1u1As5ds1l3D0nz/s03AP2yfN3sAQrb5j3EjSbVs + KVF8ZNO06oBF2fgLAAD//6SXWY/aMBSF/0tfo2ay2QQkVJHYjrM7C9negkSnjMQsbWHE/PoaqiYO + IwWqvJ+HLzfnnnucOZP2hpNosgI1/ab9BrrOfpvDb3P/67X9/loLi56WNSrKIm+qHthGKI3qBoWf + juIXTFyCoyq/OPN/wKECoaneAtdlVQHqcNRb7eXFZ8ZPqcoPoqPsoKyJRZIw6Mlzj62D2Cn8aRF1 + IYGGodxD3Ou6TM2fJejv928P6oNojqiuWb5mYVOKGYVoUuS0TicRzxY6lMEcaGAUeCjr7ly7lzwa + gXaHBmZO4jCLncSqhEytVyvMVzkO8EReA8g8SW9s31DWzVfHT97uSWpO1lpIUotfpjXJCBZ6KaFp + FdZWwJJJuOZCN3nRVGdgnPdK192sbPfBtkSDlbERigSxY0xpxrevB0aF40Zu5YTRJOD5QtFlzqGZ + 44a40nVhsZ1r0gaCJn5EQlgEjpdHFeID7YEpP7q0IWmMJgIDjU8OzOB4ul3pugkfyA/pmT5upWwu + WhglZeH6lCVpT+w1/BAhRsvP8UZWZcj45UXs7njTlEsIqOZcHX2snHUGL5m8/A9eK9vd4W1+Os7i + I2sFb1hZUiY181yh+9PMT9c4KeIbZu5rgYNTFuVn+b+SaRPcoCwiQi34tvy6XN4omWd6KBsGhGDU + UH91vCEBOIjE1kfH9mRrxgy8vwv/B/OnZFTmnivcy5S3f9e24mp152fiCPtBXgifGcdBYPFqkNL+ + M5d/AAAA//9SBDYKgAQhb5rrGZkaGJnhbf1A1JkZWZoYo7TxEiOMiovSSsv9jbNMkOuqAO9wX1cA + AAAA//+kWNtymzAU/JbmlTHB3AyZ6XTEVQgBAgRIvNmdtE6ndew29qT5+qrNGCulMekYXvdhQXt2 + 9yjzvFqq0z4oKi8l+LJa8JuJo4rQdKcZy7gj436J1ooPNevgy62U1ZhHrKSpZP1BkzCEQV6Ndpwr + GGUh6kHSh/81N45qGaIWTM6NozqaZs9fKGq1Cr4+BHTvpqEvzQ2PRKtvOOqlgfeagsIGJlVz6Z92 + VVN3bOdsCPyNGzxVRy5Wkv13Y7GTtQGirCB9GRFJGwAlflmUfnBRKxBMLNHl54Z+vsc842xtob9s + Xkulu75/Kjb5wgeSNjDDoOElZNL+22JhTr4XsP5SwmIRX5julJZl2JABG93CxnZB9u1B9hjOepDH + YQvrE19ah4AAWqLRavh2vqYI+xtd2IWrucaZXXaMG4oX/LjeGdy2Yj2WNJzlNYdZlLW9ZIqcByT2 + EYKj4cNN15KCIv+tndwUAr0xTHUulp9z/WCMG4gzZWd+iR7zO+2TpIyihh5peppGkpSZWBkYTLwL + pHwkYrnO2eV7jBsq47La/thtPq92d1sgaSMlfdgA7pdS/iCvqknNu3DCmE93OXmZMJLwq1PM5hQT + jDL+h+tz/rybzd4r4n09f4703blhTn/kETWcye3T9tpembe0U2T5l2LDiAOayf7C8wjFdYtyfumh + WKrhuMZr18v/gg3JQ701wd80AveFfB0IepQ2AYvDE92w8DAq6ppOaGg4EZCjKuWxdB/S1bCLIQs6 + uRHMlA/imU2diK1quuaYZzxpjDtV//Zw/3OuP1DnFwAAAP//pFnJktowFPyW5OqKx/KKc0lZlnck + C2HLy43ZqMlsJLOE8ddHpAKWwwSTcKVeUS3V61Z3m0lMYXOCSOlxLNk7DrMWxgGOTtDQLRDxrprW + QU36c24n+jc/XlYP3VMW3QLZSVOGyprTZhpLiFM2QwmJ0pO5bauubYPxPZLndldsoG4Vr9ffo0dT + 5naK4jYNecikyqms6HzK+JzsexgqJDaEFc42PDkeuaNajnhiR+/aUV2REMBAla4q6/b5m3mXZKSW + 9J9APGs9nMgyWsw9n80DWh5bCWYQ1pSWRU+BpKlmEAZsWvUUEAwQpvhQV/YLvampJjD1QwlnOzfR + LEMben9qr1IavLrGFZQtJkYpLEgWSwtFgqpoS0jG+pve+lew4D5m/SkJjooZF/8bSaf89EH5ooxK + rwlEFNZdMLaFm0bQMAEY8Oa8WJ0Rew2eFO1SPmUr8jyr01xS36iOfc7DhO/30lj8Oq1DGPzTEgpA + rm1MzLElNHVhQnTNGizhtaPctF+Np0a5X8rvBs7DSljQmDc98gplXtbkWTkSzcYRG6omrlAf09TB + 3A4xeumw87B8fLtYyoSnOapomad52SNOMAqjmhbRCQXQFollWbYxSgFDdXXHmgzriYh37XRhnC9C + X1qOkjWRiE0BksIKCmqYBrMm2dPUj1UU4pbGODvyS6oOPuv6ppGyRXo6UOe/M7cDfn1/d+Hjs7Qz + 5E/ABcUiz3oMSbvBfXHPNSFp9t83/RuISE/Adsy/O9N35naS+ga6S/3ZXSgr1/sJAAD//0LuZYW7 + BIYHengEIg0O+ke5Ort5Ozs7Epj8hZc2wX7uPk4uTs6I0iYwyNfZ2cc7OMQLUdoACxpte11FjGYF + AAAA//+kWsty2jAU/ZZ0y2CMMbbpDNMByQ/JL8kPWfIOJk1DEpKBpk0nX1/TYWwFDKZhwe4sDj73 + de7VMX1zVypPz7MtuHqevePPm+X9tlwFW9lMxsLLURr5udQ6XOwjltA0OrIO/ylMVd0rj6ie6QIt + uHrcWz9a/pZvvvNeIfW6kkEns4MkknKWx2GGxCxyOgahWheYERIkgje6kJmHaJC4QdzocrO7pPbP + dIGavTE2tGFX+H3A1eH3kK1eF7NXY7EYy9MTiDC02Vxg6ViBRJwjG2fk88V0z6Qyw1UmnHFGLbhm + ZfU2fln9/mG5DEoZHlFCwxxnXBrDnSTLRVog//OmeU9EU0yralen9ygtuDqQNoEZE7C+DXAiPZZg + iAkRCkykrQQEOGQsdZyjZfqXGHgpDdNI7D7+hcRHX1VN0U3L6IiNA1xNvNAsfflzrT8PQol4BBki + yK1+DfES4cIJbS8nV33pf0Qm5kTrKDIHuDqY79D9ePX0a6CZrnxngZS6uEBCSlmbhemMuBhemrIz + DniK5Z1tFAKPpKhwJIfWn970pv3+6Wcpe/YjZaSa4+H5eDrA1f8S8IdIM0Zi++RJslBIc1hWvlnq + zRzmMQeVG71alpFiaRNd75RFxtUZC8oegcPVCy8+nOuygBCWBIyChnGRUYc6Xppd+lyozOw0p770 + LqVyqvGc0ir3G1125/Vv/WmnLrqiq9rkzIK3BVfvS9/NQQzijUnUR7nFpSyOMHGZvCDg2J8j26/q + /bXC6IqpjVT19L60BVcPS9s3ywDLP7fvE9nOeU7ic+JEfwEAAP//pFpNj5swEP0t22skAiw4UKkH + wMZ8f9mA8a2qVttE3ZVCkkrdX19HihynZUmU3N/hWTN+M/NmBqX1KPqiorAp8vst6RMRoImGXpSh + a4RVnOwiWPwKKvst7Te7i0V1VAUdFqO9sudLeMxjr+7K+y2jE5OV5jiGY31ucU3gpIYeWn2M8NYt + 46Xa3kVdG9GKFIkyZpVe4jdZ6Xf/1dcvBY5IVYc3nzEcGVlfDUt7fnbBzI3fBE4OLam/dReFVR52 + v1XmeAhiknukV9Q0a0lLWNGkV9T0FsZC1e2ZLfsE7qwzW2e53tj5yFSTl5Uh6rvKH5StdcgbP46C + IrtyrydlpuwKyPI6O8tMNrAmJnEbX7gTi2/HCjArM4K9LeTDdvTPx98JnHwlfAF7kK8z8utDlZk8 + GOqchyGpzs/0UJlViHr4/uW8ZOIahjmz5pjAyV97SHb7P9+Xe/BCFJkR4w0PIA4HpfVPSO9HLG3x + ratUiHomCkZ/jguDKOzakNbwHJeno2v6NHNIdmIPtBUw3NV8t/QPTv50kL79oPpPDoYLxz5PGux5 + KQrU0bNOUMaZyMlH47LSTNNyr8dFxcm4vLtrZ+Qj+PBM1UjpOsiJ32KknP0wXEdpwJv04UxyNFE3 + 9RlzegInSyxeW4tgPzrkdaMypsPQwi7F6tVExmvIEKXlo4xNXbNNXYjNFcYXOJkVQely+m7zDVXP + VSEaAsJpj/4CAAD//4pCONjPOTDIzdUz3JfSQtTYUM/Q3JxgKkZWBm9b6pdU+aUWVBYZ5bkHAgAA + AP//pFpNc6JAEP0ve6XWAhTR3ICRr2FgYBgGuMVEs3Er8SOxdvXXZ9gD9iagKb2/w6Om6ff6dYMa + ptgX3Msc60SX8IK4cR1E11+iNzyM5qW1yVg9E1R14E76OnzBqFotfO/lv/gkSXIfl1YJjrTdGZcT + mPQE4S2MR8Nm+WyOZXWeZfwZ1zIeRoctUlbBfr+HHobloSMVJi3gHskWNonrtPoSBv7wCreMU9vP + mxZykfk0V807fdJcJkz1id57ydyJa5XnWdmsj7+29fNbBAYPkfmOk0grA1aSPEoZrggjX46spCZh + LpgTiPrbxIfandos5KRHOcf7E6w1Mrvl03r3elzcH1JgC1xEWBZ4wgMVwksk6pgI/1pbDnjIX2va + Z7y6YG0uv+Tvi6jaJMoMA7pBRglzYjsCLc7CSWAhv2QXTHmrlg5lKCIVyANrP5F6i+uiuTU45U6K + 1Mu+YaklPx5o2rR3JOyCnQZ18wnPXzcGVgtYSf/2IEWagiWjqGjsiDwqrx1hAQ9jpJp6XxvvxJ1i + svTvQnfeHvHagKYrcHlR1DSvQWPMK5TZcTizvzvC+i4RgiKwEyqqyGVlnaAYvspPOcQqF1/FHGij + af9VYieu/cz58fd8+OfdPDwosJsWDCObOSEFvQmlYYQLllnXhmuAiWGYo8v/NsS1jmCpa+HRWu0W + W5hRcURZyTnBwAx7sUgIrh3/5kqaDJqQb9K3duvEtd2IUn2O79X5boQA4SDI3TCZ+Rn4vd0ci1JQ + Et1KWFMHspmrfXLVBWvofgAAAP//rFvRkpowFP2W9tVRAQnKw44TiBAISSCABt5sZ2vrtmpnq7Pr + 1zfjTDFUqbbb9/NwJvfe3JN7T04ZQaKn/Wb37fsrWbXmwxjGvBSc6QJmnnsx9ST9D3xdYzwBtw64 + hWsYp67FvgD7sRfs9FL1CEQkmeepNtGWMuBp4lNxY0l9m7E5mDg26DTaXcU1iiC0jo/Jy9FeRxv9 + jGOYoGqRQ90PwOu5TMMZhvf+24qzus450rw+RRbEQvr+acP4awU0VbdLt6W2oW8NgGN1T2c1nGtY + Znun+KkHVukrMJYjzjVtSbikohAZ1eSDLBgucUyCf/VpNERGAxs4TucG6Cqu6cT7/QqgH+O4WOm2 + fRqIIAqzDGrjsTIMa9WkAu9epzNGC1JyrN35iMmI8ZpBcg7L9OHkA+hyOzTs7YFpTExwMyy2Ukem + 67QlP/n4tD0cn3cjt93aMCKI84ppcaElQr4/Z8GbKxwMDDDu/JZ5DXYeWtYGH+6+uh8OQH8Dchor + OYQZ18YJMwETKJDHLvi+DxiZJViw8C7jgkYIGJbtdL2tNJzrKGXXfr2ul+t6hIxhsZlr+RRC1UX9 + BEstnyQviV+qS/bSPTnHZU4lh2n8N8SBCr2retEfhf/vuPPICbpDX3x+3oCtfuQLFFLpzUrdDpBX + MqC4QtVbZYFioiJvdjqBr+KapD4eDtTa2Wlvu9SXhGmQZ6zgtXbUSqplXhIl1Y0PQk3pCsJFHOX1 + uXR5mUdJzapZei7dh36//27av1yq/wQAAP//QnM9MIWbmJri3O+OVR28RDULzjMv9SoHdimNkbNu + SIBLqEe4v4srUtcm2C/Q1TcywNOX+NUOAAAAAP//pFxbb6JAFP4tPpu4ysilD5tmhIGBgeE6MPBm + G9y4rWZXV9f66xdtMw6NLKaKj9/DCeec79zplAQYTczt890WTjhvDdYLh/81shcgJ5hlw4WRV+Bc + airjGHM/jWP71t0q4lMUknOv80MxCAcE5l4ZBRfFDAaPzf+xL9SpWpMMAc3o49QWTnh6Xb9u9b1W + r6Cc5GU2Dgo7qzypFeia1C4Kys88dJdetJHWRGa9119knEhBFmBF+CvY+VsutalCyDyTlhaRZtSJ + 49ohzQvUU970C2yMAJh0rvlcgwnD12cv/v5ZGRIi14+VayMrhy6WQpbJYDCjBQt7bnb7xX0Y6QAo + oC+VaOGE3QO+q6PVwZv/epLfb1ZEMICt8hGaQew3DJ98dfvlXRDl9E2D6djo3vS/ihMWPF8cjKVz + mGe8NWXgKaJpYkFTYtCAuCSqosS/z4SV0/28Nn7oPru9ihMmjMmGAHL8DbYbmVqQY2Uw5EUizQYR + Y4kN4ybu3kgtJvYZxuHsQi04J7YflxXnF2oZfh82v87lVCG+0lg0MHq6Q2ecro4nn86IwvzP7hsZ + bvDuKMdi06I5zx1f3nCLSkZtliJyn+0rp7H+dNw8/7f9TzjhrOnEMI7JWluu93J5k2RmETuehaQz + F9/2aJw7MLq5vDllcOzcavlQDEstb0aKCpsXxQze8+iu+Y8Qv8mjp5NJ582shFNVoLbXUivd/7Gp + h0sPPGkt+2Nm6XA3C6WDdQxhyipI3a8ueQpJ1NOxi9o54b2KE6TkPCuGjybbt5+gpZgAURTn5B8A + AAD//6RcPQ+CMBD9L67GqEhRVoqgfBUohraJA4YwOCAMavj3lkYRFCXG/YZre+/ad++uYUub1swt + MQk/nTfBdES3u8iLMPLrDf/F8yUAS2nQc4VTABnM5S4IrKMrVXP1kuQdVR2aiBFIghbHN90NZoGj + 4zcQjEIaRpHNdO0HDiCavBbS57GePrMmRmB5yrKVmlbTIuhkVX6PQRRrLYk6ILa1RjoW3Zv/xEj9 + mQFQFx8Hp3rtmnvAOedpJZcHxbPa+hWjMfN8KIr4j6RqE8tnnFcNONxg12WEYuoZT+xudMc3dgaP + pSd2J3VpYjJQmpBE43U9D/j9If1i16wS2XKRXMcgmcWcLuz5mu7fdQjV7gYAAP//AwCbXyEYCUsA + AA== headers: - Access-Control-Allow-Origin: - - '*' - Content-Length: - - '841' + Connection: + - keep-alive + Content-Encoding: + - gzip Content-Type: - application/json Date: - - Sun, 04 Aug 2019 17:45:14 GMT + - Mon, 19 Aug 2019 21:12:03 GMT + Server: + - nginx/1.15.6 + Vary: + - Accept-Encoding status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/space/update_space.yaml b/tests/integrational/fixtures/native_sync/space/update_space.yaml index d56a39d8..79447cc6 100644 --- a/tests/integrational/fixtures/native_sync/space/update_space.yaml +++ b/tests/integrational/fixtures/native_sync/space/update_space.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{"description": "desc"}' headers: Accept: - '*/*' @@ -9,26 +9,25 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '23' User-Agent: - PubNub-Python/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-channel + uri: http://ps.pndsn.com/v1/objects/demo/spaces/in_space?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":{"id":"in_space","name":"some_name","description":"desc","custom":{"a":3},"created":"2019-08-19T21:14:43.478021Z","updated":"2019-08-19T21:17:16.324888Z","eTag":"Ad/T8bjmyoKQWw"}}' headers: - Access-Control-Allow-Origin: - - '*' + Connection: + - keep-alive Content-Length: - - '285' + - '200' Content-Type: - application/json Date: - - Sun, 21 Jul 2019 11:36:49 GMT + - Mon, 19 Aug 2019 21:17:16 GMT + Server: + - nginx/1.15.6 status: code: 200 message: OK diff --git a/tests/integrational/fixtures/tornado/space/create_space.yaml b/tests/integrational/fixtures/tornado/space/create_space.yaml index 299044eb..4add04d1 100644 --- a/tests/integrational/fixtures/tornado/space/create_space.yaml +++ b/tests/integrational/fixtures/tornado/space/create_space.yaml @@ -1,38 +1,34 @@ interactions: - request: - body: '{"id": "my-channel", "name": "My space", "description": "A space that is - mine"}' + body: '{"id": "in_space", "name": "some_name", "custom": {"a": 3}}' headers: Accept-Encoding: - utf-8 User-Agent: - PubNub-Python-Tornado/4.1.0 method: POST - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces + uri: http://ps.pndsn.com/v1/objects/demo/spaces?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":{"id":"in_space","name":"some_name","description":null,"custom":{"a":3},"created":"2019-08-19T21:20:47.314439Z","updated":"2019-08-19T21:20:47.314439Z","eTag":"AYfFv4PUk4yMOg"}}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Mon, 19 Aug 2019 21:20:47 GMT - !!python/tuple - Content-Type - - application/json - - !!python/tuple - - Date - - - Sun, 21 Jul 2019 11:57:06 GMT - !!python/tuple - Content-Length - - - '285' + - - '198' - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=40461998-ccdc-4768-83f7-f0005f11b10c + url: http://ps.pndsn.com/v1/objects/demo/spaces?include=custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=8248e1b8-1266-4b48-917b-2732580d8fa4 version: 1 diff --git a/tests/integrational/fixtures/tornado/space/delete_space.yaml b/tests/integrational/fixtures/tornado/space/delete_space.yaml index d36fce01..9ce29b2d 100644 --- a/tests/integrational/fixtures/tornado/space/delete_space.yaml +++ b/tests/integrational/fixtures/tornado/space/delete_space.yaml @@ -7,28 +7,28 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: DELETE - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main + uri: http://ps.pndsn.com/v1/objects/demo/spaces/in_space response: body: - string: "{\n \"data\": {},\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":null}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Mon, 19 Aug 2019 21:20:42 GMT - !!python/tuple - Content-Type - - application/json - - !!python/tuple - - Date - - - Sun, 21 Jul 2019 11:57:06 GMT - !!python/tuple - Content-Length - - - '34' + - - '26' - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=93064877-8c6b-4882-8152-83eed20d09e4 + url: http://ps.pndsn.com/v1/objects/demo/spaces/in_space?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=5b19a0b7-dcb7-409e-94e1-a235d1cdd1ad version: 1 diff --git a/tests/integrational/fixtures/tornado/space/get_space.yaml b/tests/integrational/fixtures/tornado/space/get_space.yaml index 76b8fc08..88659e84 100644 --- a/tests/integrational/fixtures/tornado/space/get_space.yaml +++ b/tests/integrational/fixtures/tornado/space/get_space.yaml @@ -7,31 +7,28 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel + uri: http://ps.pndsn.com/v1/objects/demo/spaces/in_space?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": 200\n}" + string: '{"status":200,"data":{"id":"in_space","name":"some_name","description":null,"custom":{"a":3},"created":"2019-08-19T21:20:47.314439Z","updated":"2019-08-19T21:20:47.314439Z","eTag":"AYfFv4PUk4yMOg"}}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Mon, 19 Aug 2019 21:20:52 GMT - !!python/tuple - Content-Type - - application/json - - !!python/tuple - - Date - - - Sun, 04 Aug 2019 17:43:40 GMT - !!python/tuple - Content-Length - - - '284' + - - '198' - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-chanel?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=54fdaf57-ca7b-4fcd-a4b8-b8a0c1b87998 + url: http://ps.pndsn.com/v1/objects/demo/spaces/in_space?include=custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=31a5a22a-6d9b-4cad-a0c6-086f25cc0553 version: 1 diff --git a/tests/integrational/fixtures/tornado/space/get_spaces.yaml b/tests/integrational/fixtures/tornado/space/get_spaces.yaml index a22ac62c..d8301381 100644 --- a/tests/integrational/fixtures/tornado/space/get_spaces.yaml +++ b/tests/integrational/fixtures/tornado/space/get_spaces.yaml @@ -7,39 +7,34 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces + uri: http://ps.pndsn.com/v1/objects/demo/spaces?include=custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": null,\n \"description\": \"A space that is mine\"\ - ,\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"\ - updated\": \"2019-02-20T23:11:20.893755\"\n },\n {\n \"created\"\ - : \"2019-02-20T23:11:20.893755\",\n \"custom\": {\n \"motd\":\ - \ \"Always check your spelling!\",\n \"public\": true\n },\n \ - \ \"description\": \"The main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"MUIwQTAwMUItQkRBRC00NDkyLTgyMEMtODg2OUU1N0REMTNBCg==\"\ - ,\n \"prev\": \"M0FFODRENzMtNjY2Qy00RUExLTk4QzktNkY1Q0I2MUJFNDRCCg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 9\n}" + string: '{"status":200,"data":[{"id":"value1","name":"value2","description":"abcd","custom":null,"created":"2019-08-12T22:57:54.167167Z","updated":"2019-08-12T22:57:54.167167Z","eTag":"AaHahZqsyr6AOg"},{"id":"QVHNASRBFJ","name":"KYTGVPDKKX","description":"JEGUOMRNUK","custom":null,"created":"2019-08-18T12:09:59.72272Z","updated":"2019-08-18T12:09:59.72272Z","eTag":"AceoluqQlcyqyQE"},{"id":"WQQUUGJPCV","name":"ZMKFUWNNHT","description":null,"custom":null,"created":"2019-08-18T12:10:00.227479Z","updated":"2019-08-18T12:10:00.227479Z","eTag":"Aam4p9bSz4e6ZA"},{"id":"DODWRIZUPN","name":"YUOZNNNOCI","description":null,"custom":{"info":"YVKCALSJ","text":"JBMGASPFHZ","uncd":"?=!!=!?+"},"created":"2019-08-18T12:10:00.574818Z","updated":"2019-08-18T12:10:00.574818Z","eTag":"AdaR5aWmr4DPKw"},{"id":"GSMKNDROTG","name":"ZZEZRCQMXB","description":null,"custom":null,"created":"2019-08-18T12:10:01.005708Z","updated":"2019-08-18T12:10:01.005708Z","eTag":"AfGkmNjMhu/YUQ"},{"id":"EQHWQCYDSO","name":"ENNXGHTAXO","description":null,"custom":{"info":"IYSHJXBK","text":"HYIZPJRLQE","uncd":"++=?++-="},"created":"2019-08-18T12:10:01.54778Z","updated":"2019-08-18T12:10:01.54778Z","eTag":"AcLY973wnsiCAw"},{"id":"NMLWPOUHLV","name":"ZAGXJVHXZL","description":null,"custom":null,"created":"2019-08-18T12:10:01.873873Z","updated":"2019-08-18T12:10:01.873873Z","eTag":"AY6XzPic6t+aNg"},{"id":"YGVRVMOZIK","name":"FZJWFBWKZM","description":"GKRYWOMDRG","custom":null,"created":"2019-08-18T12:16:37.379839Z","updated":"2019-08-18T12:16:37.848793Z","eTag":"AdGc85ajmIDoXg"},{"id":"PXBRDJJWOI","name":"AOQFCTWRZF","description":null,"custom":{"info":"CJIOSKYG","text":"YWHVBDKUHF","uncd":"=!=?-+-?"},"created":"2019-08-18T12:16:40.302258Z","updated":"2019-08-18T12:16:40.609418Z","eTag":"AbzMs+nb/JmowgE"},{"id":"ZZHUEGVHWM","name":"YUUOXZEKDW","description":null,"custom":{"info":"RDZQEIYH","text":"MVCSBQVYEZ","uncd":"-=--?!=!"},"created":"2019-08-18T12:16:41.154746Z","updated":"2019-08-18T12:16:41.564938Z","eTag":"Ab79ksvrz77S6QE"},{"id":"OTCGLMCVEQ","name":"KLRDJADJSG","description":null,"custom":null,"created":"2019-08-18T12:16:42.062339Z","updated":"2019-08-18T12:16:42.062339Z","eTag":"Adbut8mspafpYw"},{"id":"RWYDVWVTZX","name":"CDDRNYZDMT","description":"EFIFENXTZF","custom":null,"created":"2019-08-18T12:16:42.606681Z","updated":"2019-08-18T12:16:43.105138Z","eTag":"Ae2ooKP4r+XTugE"},{"id":"CLWYFBFQML","name":"TJPULOGVKL","description":null,"custom":null,"created":"2019-08-18T12:16:43.644081Z","updated":"2019-08-18T12:16:43.644081Z","eTag":"AcTn+6Kmmq/1/QE"},{"id":"NYYPTUPMZW","name":"FZDHQVTHYR","description":null,"custom":null,"created":"2019-08-18T12:17:36.59525Z","updated":"2019-08-18T12:17:36.59525Z","eTag":"Afam+JHN5aiD6QE"},{"id":"QOMSOGQBXK","name":"YAAEZHUOLE","description":null,"custom":null,"created":"2019-08-18T12:17:45.98346Z","updated":"2019-08-18T12:17:45.98346Z","eTag":"Ac3EjJij+ZyBUg"},{"id":"BXZLUFSFEJ","name":"FHRXMYBLPQ","description":null,"custom":null,"created":"2019-08-18T12:18:38.721756Z","updated":"2019-08-18T12:18:38.721756Z","eTag":"AYSizPeF26X4bQ"},{"id":"FCOEHHSWVT","name":"DVGINIXGMN","description":null,"custom":null,"created":"2019-08-18T12:19:03.217285Z","updated":"2019-08-18T12:19:03.217285Z","eTag":"Ade92+b65ZOgDw"},{"id":"LGJTNXDMYB","name":"HMOZHZFROD","description":null,"custom":null,"created":"2019-08-18T12:19:52.725769Z","updated":"2019-08-18T12:19:52.725769Z","eTag":"AYuFh+nHge+S9QE"},{"id":"DQWVIKHPQR","name":"JZEGVDPHWT","description":"FAWMPCTWDP","custom":null,"created":"2019-08-18T12:20:43.618912Z","updated":"2019-08-18T12:20:44.002742Z","eTag":"Aeiuq9yv7OvPaQ"},{"id":"BSQWQYPJIN","name":"HSKRUEQVOQ","description":null,"custom":{"info":"CGERPNTQ","text":"HCFEZDSNFF","uncd":"?=-==+-="},"created":"2019-08-18T12:20:46.446655Z","updated":"2019-08-18T12:20:46.839561Z","eTag":"AaKDvayC2475wwE"},{"id":"EHNANWTJIQ","name":"RZZEICBOXA","description":null,"custom":{"info":"ENEKLTVQ","text":"OOLLBVCSRH","uncd":"=!?!==!?"},"created":"2019-08-18T12:20:47.250268Z","updated":"2019-08-18T12:20:47.629433Z","eTag":"AaX2srfuwO3j4gE"},{"id":"PKWMEMBBSV","name":"CAORBKPLSG","description":null,"custom":null,"created":"2019-08-18T12:20:48.051968Z","updated":"2019-08-18T12:20:48.051968Z","eTag":"AZaJh+CH05vCXg"},{"id":"XSLYFXQTKK","name":"DUIXJLANRO","description":"HFMEJZAIZE","custom":null,"created":"2019-08-18T12:20:48.536682Z","updated":"2019-08-18T12:20:48.800611Z","eTag":"AbbDltDTu9KECQ"},{"id":"YFOMDUYJZR","name":"BUOTHUHIRU","description":null,"custom":null,"created":"2019-08-18T12:20:49.428686Z","updated":"2019-08-18T12:20:49.428686Z","eTag":"Ad2J9L+Iur37qgE"},{"id":"AFMOPZQFPV","name":"AJICQOQCDR","description":null,"custom":null,"created":"2019-08-18T12:20:50.313281Z","updated":"2019-08-18T12:20:50.607238Z","eTag":"Aa+W/ozOnN7CAg"},{"id":"LXLAUYQHXO","name":"VLHSKCBDXZ","description":null,"custom":null,"created":"2019-08-18T12:20:51.07498Z","updated":"2019-08-18T12:20:51.07498Z","eTag":"AYn25L3p7PuVvwE"},{"id":"YXZANGEVHS","name":"TSEAPATQJM","description":null,"custom":null,"created":"2019-08-18T14:38:27.290933Z","updated":"2019-08-18T14:38:27.290933Z","eTag":"AfHchq3Y65G2GQ"},{"id":"MNSYHMFMVZ","name":"RYYDPGCJJH","description":"LUWVPOTJCF","custom":null,"created":"2019-08-18T14:49:34.174685Z","updated":"2019-08-18T14:49:34.174685Z","eTag":"AfX+q4jFxNi0fg"},{"id":"OSHBPUZTKF","name":"AXFIFXHIBR","description":null,"custom":null,"created":"2019-08-18T14:49:34.598839Z","updated":"2019-08-18T14:49:34.598839Z","eTag":"AcaRpsqngbqipAE"},{"id":"KPZEUAYCQQ","name":"JBRSPSYWEG","description":null,"custom":{"info":"INQIXPIY","text":"HNTLPLJMYZ","uncd":"!--=+=+="},"created":"2019-08-18T14:49:34.9134Z","updated":"2019-08-18T14:49:34.9134Z","eTag":"Afezp/6b4eTW+wE"},{"id":"QZDHGDTMPV","name":"YNFJGSVJNY","description":null,"custom":null,"created":"2019-08-18T14:49:35.38937Z","updated":"2019-08-18T14:49:35.38937Z","eTag":"AZTBhPLm0PHuOw"},{"id":"GAZJKUDXGE","name":"EOBLJOSSTR","description":null,"custom":{"info":"ANJRKYGG","text":"WSHWGHXDWH","uncd":"=-+????-"},"created":"2019-08-18T14:49:36.020848Z","updated":"2019-08-18T14:49:36.020848Z","eTag":"AYSVvoy12tT8Rg"},{"id":"RSNDNUAVMN","name":"VBKZBHEMGZ","description":null,"custom":null,"created":"2019-08-18T14:49:36.536453Z","updated":"2019-08-18T14:49:36.536453Z","eTag":"AaiwupnzsKGk1QE"},{"id":"PRDUXVPYLH","name":"VJRQDINGJR","description":null,"custom":null,"created":"2019-08-18T14:49:36.966137Z","updated":"2019-08-18T14:49:36.966137Z","eTag":"AY3DzpHxxrGo4AE"},{"id":"JDHZJFVFRM","name":"UWPSLRVSNO","description":"PRYYFBWMKV","custom":null,"created":"2019-08-18T14:49:37.573133Z","updated":"2019-08-18T14:49:37.991219Z","eTag":"AeW5ktq4lIKNXQ"},{"id":"NBMQZAMIKF","name":"TSACRSEPUF","description":null,"custom":{"info":"KBBXPPUT","text":"IYWQBBERLW","uncd":"-+?!===!"},"created":"2019-08-18T14:49:40.414212Z","updated":"2019-08-18T14:49:40.805301Z","eTag":"AaP6pJPEv93eBg"},{"id":"XMDJBTNKHH","name":"NEWTZUBNKL","description":null,"custom":{"info":"EWBTVCMR","text":"NMGTQVTNKG","uncd":"--!+?++="},"created":"2019-08-18T14:49:41.212917Z","updated":"2019-08-18T14:49:41.534113Z","eTag":"AbTp/N6x1s+0dg"},{"id":"XZGINRXJOV","name":"GXHCVVFIVM","description":"MFIVLXFBEV","custom":null,"created":"2019-08-18T14:49:41.963843Z","updated":"2019-08-18T14:49:42.292059Z","eTag":"Af7+iZj3sY+mgwE"},{"id":"MOFWOQCHVY","name":"WDKAKYOKUA","description":null,"custom":null,"created":"2019-08-18T14:49:43.034128Z","updated":"2019-08-18T14:49:43.034128Z","eTag":"AfDuzM7ngoycgAE"},{"id":"PODWPUOJOU","name":"IMDFGXPTGQ","description":null,"custom":null,"created":"2019-08-18T14:49:43.555632Z","updated":"2019-08-18T14:49:43.927589Z","eTag":"AYGVzZLa3baFCg"},{"id":"URYGJZAEDR","name":"DEXBJEQYIR","description":"WGFMZPHMKK","custom":null,"created":"2019-08-18T21:22:38.600658Z","updated":"2019-08-18T21:22:38.600658Z","eTag":"AYfmlcCM/Jz3Og"},{"id":"TPMMEMARDY","name":"VCGXPXNNJK","description":null,"custom":null,"created":"2019-08-18T21:22:39.416745Z","updated":"2019-08-18T21:22:39.416745Z","eTag":"Aey1zd2t9a+p9AE"},{"id":"AWDQWQHHQJ","name":"OZECFKCCAT","description":null,"custom":{"info":"SNGLBDBC","text":"QRMCCLKSTJ","uncd":"++=+?-!-"},"created":"2019-08-18T21:22:39.753019Z","updated":"2019-08-18T21:22:39.753019Z","eTag":"AcfXnqbhrZiLrgE"},{"id":"OYHUISNKUF","name":"GJKIVRQSNH","description":null,"custom":null,"created":"2019-08-18T21:22:40.072012Z","updated":"2019-08-18T21:22:40.072012Z","eTag":"AZmk8KrXqeX+WQ"},{"id":"ZVDFTELRNU","name":"XOMTIYANFZ","description":null,"custom":{"info":"DTPPLRYX","text":"PAHIQLRGLO","uncd":"!++-=-+="},"created":"2019-08-18T21:22:40.656215Z","updated":"2019-08-18T21:22:40.656215Z","eTag":"AejTitaAt6aa5QE"},{"id":"CNJDEVBYJL","name":"IYOUIEJTPA","description":null,"custom":null,"created":"2019-08-18T21:22:41.041639Z","updated":"2019-08-18T21:22:41.041639Z","eTag":"AaXw5oivg8GVDg"},{"id":"NQPQMUJTXE","name":"FRTUYSWIKM","description":null,"custom":null,"created":"2019-08-18T21:22:42.788436Z","updated":"2019-08-18T21:22:42.788436Z","eTag":"AZqL7OPCmdLJRA"},{"id":"VIVYYMYJPO","name":"DCJMVVSFFN","description":"OCHSQMSNYA","custom":null,"created":"2019-08-18T21:23:02.478615Z","updated":"2019-08-18T21:23:02.478615Z","eTag":"AZW284bsm4n/MA"},{"id":"NDVIPIGIPI","name":"ZIJWFMEHUP","description":null,"custom":null,"created":"2019-08-18T21:23:02.979219Z","updated":"2019-08-18T21:23:02.979219Z","eTag":"AefIh5ilu/27Gg"},{"id":"BDQQGJWIYU","name":"EVMSAPGJDZ","description":null,"custom":{"info":"AXCXSJVQ","text":"NMCHPSIWFH","uncd":"-=!+=--+"},"created":"2019-08-18T21:23:03.307516Z","updated":"2019-08-18T21:23:03.307516Z","eTag":"AeCXjN263YrlHA"},{"id":"QDQUDZDTMR","name":"XDUOXCEOBP","description":null,"custom":null,"created":"2019-08-18T21:23:03.829449Z","updated":"2019-08-18T21:23:03.829449Z","eTag":"AaCZ+PD1ioXW6QE"},{"id":"TLPPVRLVQC","name":"WTQFQFHSTI","description":null,"custom":{"info":"ZTESUQKK","text":"SNDOBQQRTU","uncd":"?!=!?-=+"},"created":"2019-08-18T21:23:04.402982Z","updated":"2019-08-18T21:23:04.402982Z","eTag":"Adz7/OCOq7P0kgE"},{"id":"SVONJPGVGE","name":"XJKBIEKRGL","description":null,"custom":null,"created":"2019-08-18T21:23:04.723001Z","updated":"2019-08-18T21:23:04.723001Z","eTag":"AYrw86Cbxdz9XQ"},{"id":"HFRKXPFNYJ","name":"NWNPTDRNMU","description":null,"custom":null,"created":"2019-08-18T21:23:06.205621Z","updated":"2019-08-18T21:23:06.205621Z","eTag":"AcXIg6P5mKWjsQE"},{"id":"NHPCVGQDIB","name":"JZIZIAQVOY","description":null,"custom":null,"created":"2019-08-18T21:23:07.881844Z","updated":"2019-08-18T21:23:07.881844Z","eTag":"AZuU0rHGq9OI/AE"},{"id":"HVUHTPSNJV","name":"OAJBRLOBVA","description":"NGHSPQFTZF","custom":null,"created":"2019-08-18T21:24:14.339679Z","updated":"2019-08-18T21:24:14.339679Z","eTag":"AfKBq9+N4OusvAE"},{"id":"GYCISMASWU","name":"LUSUSXNRKZ","description":null,"custom":null,"created":"2019-08-18T21:24:14.792546Z","updated":"2019-08-18T21:24:14.792546Z","eTag":"AaCq8/ij5MrXfg"},{"id":"XOFEWVPBYT","name":"FZRBIHCNLB","description":null,"custom":{"info":"OVNDXMQL","text":"LYXRISIUIW","uncd":"-++==!+="},"created":"2019-08-18T21:24:15.405803Z","updated":"2019-08-18T21:24:15.405803Z","eTag":"AaDe6t6MiLSlzgE"},{"id":"MCYQMZFFSP","name":"AEOLPETAGN","description":null,"custom":null,"created":"2019-08-18T21:24:15.911298Z","updated":"2019-08-18T21:24:15.911298Z","eTag":"AcuJstya/t6eSQ"},{"id":"QWQZCDGFYF","name":"JSWBHXKUGA","description":null,"custom":{"info":"DEWXFQFW","text":"XDEFVUFTQD","uncd":"!???-!-?"},"created":"2019-08-18T21:24:16.761975Z","updated":"2019-08-18T21:24:16.761975Z","eTag":"AZ6KmcT0hZ6YpAE"},{"id":"MJRGAAKECY","name":"VQJELZXPBY","description":null,"custom":null,"created":"2019-08-18T21:24:17.224998Z","updated":"2019-08-18T21:24:17.224998Z","eTag":"Acn9i8rZr6zA2wE"},{"id":"VVDZSBUGEW","name":"XGQHKCZRKN","description":null,"custom":null,"created":"2019-08-18T21:24:18.982048Z","updated":"2019-08-18T21:24:18.982048Z","eTag":"AdGi4+Ctr8SgjwE"},{"id":"TYYUDVKGQR","name":"LZQDXETTON","description":null,"custom":null,"created":"2019-08-18T21:24:20.520254Z","updated":"2019-08-18T21:24:20.520254Z","eTag":"AZCO9ZTn5ZjTAw"},{"id":"DEYCSZTWEZ","name":"NCQRFEIWMZ","description":null,"custom":null,"created":"2019-08-18T21:24:31.17775Z","updated":"2019-08-18T21:24:31.17775Z","eTag":"Ae/tzNepyr2nGQ"},{"id":"MPKHWUGRCA","name":"MUVMFNZILT","description":null,"custom":null,"created":"2019-08-18T21:25:18.186032Z","updated":"2019-08-18T21:25:18.186032Z","eTag":"AZu3mKDYjeHGmAE"},{"id":"AOOTHKXAXG","name":"FEUJRAIAQJ","description":null,"custom":null,"created":"2019-08-18T21:43:50.769822Z","updated":"2019-08-18T21:43:50.769822Z","eTag":"AZ3LyqD+jIuuuQE"},{"id":"STJCXMQQVE","name":"EBWBMNZQYQ","description":"GVFXNQBHTY","custom":null,"created":"2019-08-19T07:28:48.928273Z","updated":"2019-08-19T07:28:48.928273Z","eTag":"Aai+pozhqZisLA"},{"id":"WRHCCOSNJQ","name":"ULQSKYMSMD","description":"AEKUWSCIWZ","custom":null,"created":"2019-08-19T07:31:05.38396Z","updated":"2019-08-19T07:31:05.38396Z","eTag":"AfrfgornzeayQg"},{"id":"FDMSRIGWGG","name":"UXDWZNMWHL","description":null,"custom":null,"created":"2019-08-19T07:31:05.77799Z","updated":"2019-08-19T07:31:05.77799Z","eTag":"AbfUteLYpO+EKg"},{"id":"IRPMSCNBLR","name":"AKOIADHXSU","description":null,"custom":{"info":"CPSDLMYC","text":"ZHOHXKKZVS","uncd":"!+++??-+"},"created":"2019-08-19T07:31:06.11949Z","updated":"2019-08-19T07:31:06.11949Z","eTag":"Aef7gKbnp5K0VA"},{"id":"WQVTNKVQQN","name":"WYPNCWTLXP","description":null,"custom":null,"created":"2019-08-19T07:31:06.540724Z","updated":"2019-08-19T07:31:06.540724Z","eTag":"AejQxe2CsdKo5gE"},{"id":"IFUVVZPTZA","name":"TYDRBNJEBI","description":null,"custom":{"info":"HFMWWPDR","text":"VYLFSXZODN","uncd":"!+-!=!++"},"created":"2019-08-19T07:31:07.149769Z","updated":"2019-08-19T07:31:07.149769Z","eTag":"Aebzkb3wt7yc+AE"},{"id":"VSKDBSCJPE","name":"DQJLKVSRAM","description":null,"custom":null,"created":"2019-08-19T07:31:07.557496Z","updated":"2019-08-19T07:31:07.557496Z","eTag":"Adf21JzAjreqMA"},{"id":"UDPSXUUMKP","name":"GNWOMKZCHP","description":null,"custom":null,"created":"2019-08-19T07:31:08.884387Z","updated":"2019-08-19T07:31:08.884387Z","eTag":"AfPP2bKa0br4DA"},{"id":"IITFJOEHRR","name":"FTKWXWPMLP","description":null,"custom":null,"created":"2019-08-19T07:31:10.28202Z","updated":"2019-08-19T07:31:10.28202Z","eTag":"AeKIkunpmqyKgQE"},{"id":"CHAJOURONZ","name":"NVSBJMBXMP","description":null,"custom":null,"created":"2019-08-19T07:31:10.907857Z","updated":"2019-08-19T07:31:10.907857Z","eTag":"AeP92Ni54e+FpgE"},{"id":"BKADKLVSPL","name":"XXFOPLCMRF","description":null,"custom":null,"created":"2019-08-19T07:31:11.864586Z","updated":"2019-08-19T07:31:11.864586Z","eTag":"AZG2zeLxz4jInQE"},{"id":"JALDYWSARM","name":"OZVXPGEHAO","description":null,"custom":{"info":"JQZZSODY","text":"TQFJRXCCGQ","uncd":"+?+-!+-="},"created":"2019-08-19T07:31:12.562219Z","updated":"2019-08-19T07:31:12.902189Z","eTag":"Af+5gPy50a3OOQ"},{"id":"KOXMRTRQMQ","name":"XTNHUHJKFR","description":null,"custom":null,"created":"2019-08-19T07:31:13.456612Z","updated":"2019-08-19T07:31:13.456612Z","eTag":"Abuug5Dt7JTgUg"},{"id":"MFRFIGQQAJ","name":"UGGZWTLFBQ","description":null,"custom":{"info":"HDWKUOHR","text":"DNXINOZNAK","uncd":"?=!+?++!"},"created":"2019-08-19T07:31:14.108159Z","updated":"2019-08-19T07:31:14.381965Z","eTag":"AeKckovzsp395gE"},{"id":"IHDKDOOYNQ","name":"MUDDCCVNFP","description":null,"custom":null,"created":"2019-08-19T07:31:15.05718Z","updated":"2019-08-19T07:31:15.05718Z","eTag":"AYrZ0O/pl9bv5wE"},{"id":"OMJKOIHNOF","name":"ERALARDBNP","description":"FNKELHRNGV","custom":null,"created":"2019-08-19T07:31:15.502465Z","updated":"2019-08-19T07:31:15.967798Z","eTag":"AdjajZ3D0/TnVg"},{"id":"GAVSRCLHXJ","name":"XOUKCUCHAH","description":"VHUSMXOAPJ","custom":null,"created":"2019-08-19T07:31:54.394383Z","updated":"2019-08-19T07:31:54.394383Z","eTag":"AaDA9/CRhsn5owE"},{"id":"WDGMXBEUDR","name":"SYXFMHYDYM","description":null,"custom":null,"created":"2019-08-19T07:31:54.718181Z","updated":"2019-08-19T07:31:54.718181Z","eTag":"AezvvM2p4P+oag"},{"id":"NPFSQNTOZJ","name":"BNJQBLILYE","description":null,"custom":{"info":"RKORJISZ","text":"OUSILZNYEP","uncd":"=---!?--"},"created":"2019-08-19T07:31:55.045567Z","updated":"2019-08-19T07:31:55.045567Z","eTag":"Af6Sn7uJwZ3L3gE"},{"id":"TPDUHWODEG","name":"SNQEMYPIMK","description":null,"custom":null,"created":"2019-08-19T07:31:55.388578Z","updated":"2019-08-19T07:31:55.388578Z","eTag":"AYe3nfGXw8Tk3AE"},{"id":"YUOHPJWHVU","name":"HQHXLSQQFL","description":null,"custom":{"info":"KLNEOKGN","text":"EHMKAVJYPM","uncd":"!!?!!??="},"created":"2019-08-19T07:31:56.283689Z","updated":"2019-08-19T07:31:56.283689Z","eTag":"Adeels7v6emADA"},{"id":"TFHMWFTZJY","name":"ICNFWWNXGV","description":null,"custom":null,"created":"2019-08-19T07:31:56.621971Z","updated":"2019-08-19T07:31:56.621971Z","eTag":"AZf3mKXl3uLsXw"},{"id":"OAUJCNYDKO","name":"RGIFONVWEI","description":null,"custom":null,"created":"2019-08-19T07:31:58.33158Z","updated":"2019-08-19T07:31:58.33158Z","eTag":"Af7BkLvc2+KKVA"},{"id":"ZIFEDVAIHQ","name":"CUAMBNWUOW","description":null,"custom":null,"created":"2019-08-19T07:31:59.733232Z","updated":"2019-08-19T07:31:59.733232Z","eTag":"AY3XuePmxJapbw"},{"id":"OTWPAMATZA","name":"ACMQLSMXRH","description":null,"custom":null,"created":"2019-08-19T07:32:00.408933Z","updated":"2019-08-19T07:32:00.408933Z","eTag":"Adafx8iGxaTXzgE"},{"id":"XSENSRDACJ","name":"MKIKPZPRLV","description":null,"custom":null,"created":"2019-08-19T07:32:01.609681Z","updated":"2019-08-19T07:32:01.609681Z","eTag":"AZHKrK3Kzq3srAE"},{"id":"EGDTAOXWRB","name":"EUURFAQVSR","description":null,"custom":{"info":"CHLUHHOB","text":"HVKFLQYZXX","uncd":"+=++++=!"},"created":"2019-08-19T07:32:02.333899Z","updated":"2019-08-19T07:32:02.750111Z","eTag":"AbOVtu/K+rHuzwE"},{"id":"CDNVXVGLDY","name":"PYUNFUSEKW","description":null,"custom":null,"created":"2019-08-19T07:32:03.404042Z","updated":"2019-08-19T07:32:03.404042Z","eTag":"AfS188zRn6invQE"},{"id":"RTCWQGJDES","name":"LFJNQVGAPO","description":null,"custom":{"info":"JRNGVUBI","text":"USDJBKWZHC","uncd":"!=!+?++?"},"created":"2019-08-19T07:32:04.141156Z","updated":"2019-08-19T07:32:04.553559Z","eTag":"AZ7Lgre+iJ3b6AE"},{"id":"EUCYGXITOX","name":"HAASUZANIQ","description":null,"custom":null,"created":"2019-08-19T07:32:05.174579Z","updated":"2019-08-19T07:32:05.174579Z","eTag":"AYGc28LE1syj3QE"},{"id":"RMENEQVKRV","name":"BGIXGXFJNB","description":"YIUTNTSOPC","custom":null,"created":"2019-08-19T07:32:05.755729Z","updated":"2019-08-19T07:32:06.054514Z","eTag":"AbOJjM2y19vanAE"},{"id":"HCGOZXCXQL","name":"GMHSZQLDSW","description":"RYRTTKZDBV","custom":null,"created":"2019-08-19T07:32:42.32839Z","updated":"2019-08-19T07:32:42.32839Z","eTag":"AZCqoff89dy/pQE"},{"id":"XSKVACOWBT","name":"QXKJEODSBC","description":null,"custom":null,"created":"2019-08-19T07:32:42.659385Z","updated":"2019-08-19T07:32:42.659385Z","eTag":"AdLundy4qb6NJw"},{"id":"DZYWZNPCWZ","name":"EKXJPZFNKC","description":null,"custom":{"info":"MZXYSYNF","text":"HDLPFUFSOP","uncd":"-?+-!--="},"created":"2019-08-19T07:32:43.072387Z","updated":"2019-08-19T07:32:43.072387Z","eTag":"AdOK4paw+5a0Wg"}],"next":"MTAw"}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Mon, 19 Aug 2019 21:20:52 GMT - !!python/tuple - Content-Type - - application/json - !!python/tuple - - Date - - - Sun, 04 Aug 2019 17:43:40 GMT - - !!python/tuple - - Content-Length - - - '841' + - Transfer-Encoding + - - chunked - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 + - !!python/tuple + - Vary + - - Accept-Encoding + - !!python/tuple + - X-Consumed-Content-Encoding + - - gzip status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=0851146a-88f5-48f3-8762-7e4ce787897f + url: http://ps.pndsn.com/v1/objects/demo/spaces?include=custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=3f147361-5dba-42d3-8cd5-7f99e19e1bc2 version: 1 diff --git a/tests/integrational/fixtures/tornado/space/update_space.yaml b/tests/integrational/fixtures/tornado/space/update_space.yaml index 396e5aca..ae9597e6 100644 --- a/tests/integrational/fixtures/tornado/space/update_space.yaml +++ b/tests/integrational/fixtures/tornado/space/update_space.yaml @@ -1,38 +1,34 @@ interactions: - request: - body: '{"id": "my-channel", "name": "My space", "description": "A space that is - mine"}' + body: '{"description": "desc"}' headers: Accept-Encoding: - utf-8 User-Agent: - PubNub-Python-Tornado/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-channel + uri: http://ps.pndsn.com/v1/objects/demo/spaces/in_space?include=custom response: body: - string: "{\n \"data\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n\ - \ \"description\": \"A space that is mine\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"my-channel\",\n \"name\": \"My space\",\n \"updated\"\ - : \"2019-02-20T23:11:20.893755\"\n },\n \"status\": \"ok\"\n}" + string: '{"status":200,"data":{"id":"in_space","name":"some_name","description":"desc","custom":{"a":3},"created":"2019-08-19T21:20:47.314439Z","updated":"2019-08-19T21:20:56.991607Z","eTag":"Ad/T8bjmyoKQWw"}}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Mon, 19 Aug 2019 21:20:57 GMT - !!python/tuple - Content-Type - - application/json - - !!python/tuple - - Date - - - Sun, 21 Jul 2019 11:57:06 GMT - !!python/tuple - Content-Length - - - '285' + - - '200' - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/my-channel?pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=4301d4ab-e67c-4fa4-b8c8-477114fc3666 + url: http://ps.pndsn.com/v1/objects/demo/spaces/in_space?include=custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=9dd7e485-fa79-4f5b-926f-09f5dbd4bd6c version: 1 diff --git a/tests/integrational/native_sync/test_space.py b/tests/integrational/native_sync/test_space.py index 04c9819e..8880a30c 100644 --- a/tests/integrational/native_sync/test_space.py +++ b/tests/integrational/native_sync/test_space.py @@ -1,4 +1,4 @@ -from tests.helper import pnconf_copy +from tests.helper import pnconf_obj_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.structures import Envelope from pubnub.pubnub import PubNub @@ -10,16 +10,16 @@ @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/space/get_spaces.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_get_spaces(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.get_spaces().sync() + envelope = pn.get_spaces().include('custom').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetSpacesResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert len(data) == 2 + assert len(data) == 100 assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[0]) assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[1]) @@ -27,73 +27,68 @@ def test_get_spaces(): @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/space/create_space.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_create_space(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.create_space().data({'id': 'my-channel', 'name': 'My space', - 'description': 'A space that is mine'}).sync() + envelope = pn.create_space().data({'id': 'in_space', 'name': 'some_name', + 'custom': {'a': 3}}).include('custom').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNCreateSpaceResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert data['id'] == 'my-channel' - assert data['name'] == 'My space' - assert data['description'] == 'A space that is mine' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert data['id'] == 'in_space' + assert data['name'] == 'some_name' + assert data['custom'] == {'a': 3} + assert data['description'] is None @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/space/get_space.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_get_space(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.get_space().space_id('my-chanel').sync() + envelope = pn.get_space().space_id('in_space').include('custom').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetSpaceResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'my-channel' - assert data['name'] == 'My space' - assert data['description'] == 'A space that is mine' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'in_space' + assert data['name'] == 'some_name' + assert data['custom'] == {'a': 3} + assert data['description'] is None @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/space/update_space.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_update_space(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.update_space().space_id('my-channel').data({'name': 'My space', - 'description': 'A space that is mine'}).sync() + envelope = pn.update_space().space_id('in_space').data({'description': 'desc'}).include('custom').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNUpdateSpaceResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'my-channel' - assert data['name'] == 'My space' - assert data['description'] == 'A space that is mine' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'in_space' + assert data['name'] == 'some_name' + assert data['custom'] == {'a': 3} + assert data['description'] == 'desc' @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/space/delete_space.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_delete_space(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.delete_space().space_id('main').sync() + envelope = pn.delete_space().space_id('in_space').sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNDeleteSpaceResult) assert isinstance(envelope.status, PNStatus) - assert envelope.result.data == {} diff --git a/tests/integrational/tornado/test_space.py b/tests/integrational/tornado/test_space.py index 73eb265d..5afae219 100644 --- a/tests/integrational/tornado/test_space.py +++ b/tests/integrational/tornado/test_space.py @@ -1,7 +1,7 @@ import tornado from tornado.testing import AsyncTestCase -from tests.helper import pnconf_copy +from tests.helper import pnconf_obj_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.pubnub_tornado import PubNubTornado, TornadoEnvelope from pubnub.models.consumer.space import (PNGetSpacesResult, PNCreateSpaceResult, PNGetSpaceResult, @@ -12,21 +12,21 @@ class TestSpace(AsyncTestCase): def setUp(self): AsyncTestCase.setUp(self) - config = pnconf_copy() + config = pnconf_obj_copy() self.pn = PubNubTornado(config, custom_ioloop=self.io_loop) @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/space/get_spaces.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_get_spaces(self): - envelope = yield self.pn.get_spaces().future() + envelope = yield self.pn.get_spaces().include('custom').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetSpacesResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert len(data) == 2 + assert len(data) == 100 assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[0]) assert set(['name', 'id', 'description', 'custom', 'created', 'updated', 'eTag']) == set(data[1]) self.pn.stop() @@ -35,70 +35,65 @@ def test_get_spaces(self): filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_create_space(self): - envelope = yield self.pn.create_space().data({'id': 'my-channel', 'name': 'My space', - 'description': 'A space that is mine'}).future() + envelope = yield self.pn.create_space().data({'id': 'in_space', 'name': 'some_name', + 'custom': {'a': 3}}).include('custom').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNCreateSpaceResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert data['id'] == 'my-channel' - assert data['name'] == 'My space' - assert data['description'] == 'A space that is mine' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert data['id'] == 'in_space' + assert data['name'] == 'some_name' + assert data['custom'] == {'a': 3} + assert data['description'] is None self.pn.stop() @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/space/get_space.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_get_space(self): - envelope = yield self.pn.get_space().space_id( - 'my-chanel').future() + envelope = yield self.pn.get_space().space_id('in_space').include('custom').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetSpaceResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'my-channel' - assert data['name'] == 'My space' - assert data['description'] == 'A space that is mine' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'in_space' + assert data['name'] == 'some_name' + assert data['custom'] == {'a': 3} + assert data['description'] is None self.pn.stop() @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/space/update_space.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_update_space(self): - data = {'name': 'My space', 'description': 'A space that is mine'} - envelope = yield self.pn.update_space().space_id('my-channel').data(data).future() + data = {'description': 'desc'} + envelope = yield self.pn.update_space().space_id('in_space').data(data).include('custom').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNUpdateSpaceResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert set(['name', 'id', 'description', 'created', 'updated', 'eTag']) == set(data) - assert data['id'] == 'my-channel' - assert data['name'] == 'My space' - assert data['description'] == 'A space that is mine' - assert data['created'] == '2019-02-20T23:11:20.893755' - assert data['updated'] == '2019-02-20T23:11:20.893755' + assert set(['name', 'id', 'description', 'created', 'updated', 'eTag', 'custom']) == set(data) + assert data['id'] == 'in_space' + assert data['name'] == 'some_name' + assert data['custom'] == {'a': 3} + assert data['description'] == 'desc' self.pn.stop() @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/space/delete_space.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_delete_space(self): - envelope = yield self.pn.delete_space().space_id('main').future() + envelope = yield self.pn.delete_space().space_id('in_space').future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNDeleteSpaceResult) assert isinstance(envelope.status, PNStatus) - assert envelope.result.data == {} self.pn.stop() From a3691a0e03d9cd7e0c383c57c3b5651e1fdfba61 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Tue, 20 Aug 2019 21:04:32 +0200 Subject: [PATCH 23/26] Update membership tests. --- .../functional/membership/test_get_members.py | 2 +- .../membership/test_get_space_memberships.py | 2 +- .../membership/test_update_members.py | 4 +- .../test_update_space_memberships.py | 4 +- .../integrational/asyncio/test_membership.py | 102 +++++++----------- .../fixtures/asyncio/members/get_members.yaml | 38 ++----- .../members/get_space_memberships.yaml | 35 ++---- .../asyncio/members/update_members.yaml | 42 +++----- .../members/update_space_memberships.yaml | 38 ++----- .../native_sync/members/get_members.yaml | 44 +++----- .../members/get_space_memberships.yaml | 41 +++---- .../native_sync/members/update_members.yaml | 49 ++++----- .../members/update_space_memberships.yaml | 44 +++----- .../fixtures/tornado/members/get_members.yaml | 47 +++----- .../members/get_space_memberships.yaml | 44 +++----- .../tornado/members/update_members.yaml | 51 ++++----- .../members/update_space_memberships.yaml | 47 +++----- .../native_sync/test_membership.py | 98 ++++++----------- .../integrational/tornado/test_membership.py | 97 ++++++----------- 19 files changed, 287 insertions(+), 542 deletions(-) diff --git a/tests/functional/membership/test_get_members.py b/tests/functional/membership/test_get_members.py index 5bfaeba6..c5e8b65a 100644 --- a/tests/functional/membership/test_get_members.py +++ b/tests/functional/membership/test_get_members.py @@ -23,7 +23,7 @@ def test_get_members(): assert membership.build_path() == GetMembers.GET_MEMBERS_PATH % (SUB_KEY, 'foo') params = membership.custom_params() - assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' + assert params['include'] == 'a,b' assert params['limit'] == 30 assert params['end'] == 'XXX' assert 'count' not in params diff --git a/tests/functional/membership/test_get_space_memberships.py b/tests/functional/membership/test_get_space_memberships.py index 5e99d8ea..5d899354 100644 --- a/tests/functional/membership/test_get_space_memberships.py +++ b/tests/functional/membership/test_get_space_memberships.py @@ -23,7 +23,7 @@ def test_get_space_memberships(): assert membership.build_path() == GetSpaceMemberships.GET_SPACE_MEMBERSHIPS_PATH % (SUB_KEY, 'foo') params = membership.custom_params() - assert params['include'] == '%5B%22a%22%2C%20%22b%22%5D' + assert params['include'] == 'a,b' assert params['limit'] == 30 assert params['end'] == 'XXX' assert 'count' not in params diff --git a/tests/functional/membership/test_update_members.py b/tests/functional/membership/test_update_members.py index 8a3b868a..2ec55a29 100644 --- a/tests/functional/membership/test_update_members.py +++ b/tests/functional/membership/test_update_members.py @@ -14,7 +14,7 @@ def test_get_members(): config.subscribe_key = SUB_KEY config.auth_key = AUTH membership = PubNub(config).update_members() - membership.include('custom').limit(30).end('XXX') + membership.include(['custom']).limit(30).end('XXX') with pytest.raises(PubNubException): membership.validate_params() @@ -23,7 +23,7 @@ def test_get_members(): assert membership.build_path() == UpdateMembers.UPDATE_MEMBERS_PATH % (SUB_KEY, 'foo') params = membership.custom_params() - assert params['include'] == '%22custom%22' + assert params['include'] == 'custom' assert params['limit'] == 30 assert params['end'] == 'XXX' assert 'count' not in params diff --git a/tests/functional/membership/test_update_space_memberships.py b/tests/functional/membership/test_update_space_memberships.py index 3dbc25b5..c2ee3801 100644 --- a/tests/functional/membership/test_update_space_memberships.py +++ b/tests/functional/membership/test_update_space_memberships.py @@ -14,7 +14,7 @@ def test_get_space_memberships(): config.subscribe_key = SUB_KEY config.auth_key = AUTH membership = PubNub(config).update_space_memberships() - membership.include('custom').limit(30).end('XXX') + membership.include(['custom']).limit(30).end('XXX') with pytest.raises(PubNubException): membership.validate_params() @@ -23,7 +23,7 @@ def test_get_space_memberships(): assert membership.build_path() == UpdateSpaceMemberships.UPDATE_SPACE_MEMBERSHIPS_PATH % (SUB_KEY, 'foo') params = membership.custom_params() - assert params['include'] == '%22custom%22' + assert params['include'] == 'custom' assert params['limit'] == 30 assert params['end'] == 'XXX' assert 'count' not in params diff --git a/tests/integrational/asyncio/test_membership.py b/tests/integrational/asyncio/test_membership.py index e4c3fa58..f5e2af80 100644 --- a/tests/integrational/asyncio/test_membership.py +++ b/tests/integrational/asyncio/test_membership.py @@ -1,6 +1,6 @@ import pytest -from tests.helper import pnconf_copy +from tests.helper import pnconf_obj_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope from pubnub.models.consumer.membership import (PNGetMembersResult, PNGetSpaceMembershipsResult, @@ -12,112 +12,77 @@ filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_get_members(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.get_members().space_id('main').limit(10).count(True).include(['custom', 'user']).future() + envelope = yield from pn.get_members().space_id('value1').include(['custom', 'user', 'user.custom'])\ + .count(True).future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetMembersResult) assert isinstance(envelope.status, PNStatus) + assert envelope.result.total_count == 1 data = envelope.result.data - assert len(data) == 2 + assert len(data) == 1 assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) - assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) - assert data[0]['user']['id'] == 'user-1' - assert data[0]['user']['name'] == 'John Doe' + assert data[0]['user']['id'] == 'mg3' + assert data[0]['user']['name'] == 'MAGNUM3' + assert data[0]['user']['custom'] == {'ZZZ': 'IIII'} @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/members/get_space_memberships.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_get_space_memberships(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.get_space_memberships().user_id('charlie').limit(10).count(True)\ - .include(['custom', 'space']).future() + envelope = yield from pn.get_space_memberships().user_id('mg3').include(['custom', 'space', 'space.custom'])\ + .count(True).future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetSpaceMembershipsResult) assert isinstance(envelope.status, PNStatus) + assert envelope.result.total_count == 1 data = envelope.result.data - assert len(data) == 2 + assert len(data) == 1 assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) - assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) - assert data[0]['space']['id'] == 'my-channel' - assert data[0]['space']['name'] == 'My space' + assert data[0]['space']['id'] == 'value1' + assert data[0]['space']['name'] == 'value2' + assert data[0]['space']['description'] == 'abcd' + assert data[0]['space']['custom'] is None @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/members/update_space_memberships.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_update_space_memberships(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - data = { - "add": [ - { - "id": "my-channel" - } - ], - "update": [ - { - "id": "main", - "custom": { - "starred": True - } - } - ], - "remove": [ - { - "id": "space-0" - } - ] - } - envelope = yield from pn.update_space_memberships().user_id('charlie').limit(10).count(True)\ - .include('custom').data(data).future() + envelope = yield from pn.update_space_memberships().user_id('mg').data( + {'add': [{'id': 'value1'}]}).include(['custom', 'space', 'space.custom']).future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNUpdateSpaceMembershipsResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert len(data) == 2 + assert len(data) == 1 assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) - assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) - assert data[0]['space']['id'] == 'my-channel' - assert data[0]['space']['name'] == 'My space' + assert data[0]['space']['id'] == 'value1' + assert data[0]['space']['name'] == 'value2' + assert data[0]['space']['description'] == 'abcd' + assert data[0]['space']['custom'] is None @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/members/update_members.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio def test_update_members(event_loop): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - data = { - "add": [ - { - "id": "user-1" - } - ], - "update": [ - { - "id": "user-2", - "custom": { - "role": "moderator" - } - } - ], - "remove": [ - { - "id": "user-0" - } - ] - } - envelope = yield from pn.update_members().space_id('main').limit(10).count(True).include('custom')\ - .data(data).future() + envelope = yield from pn.update_members().space_id('value1').data( + {'add': [{'id': 'mg3'}]}).include(['custom', 'user', 'user.custom']).future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() @@ -127,5 +92,10 @@ def test_update_members(event_loop): assert len(data) == 2 assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) - assert data[0]['user']['id'] == 'user-1' - assert data[0]['user']['name'] == 'John Doe' + if data[0]['user']['id'] == 'mg': + user = data[0]['user'] + else: + user = data[1]['user'] + assert user['id'] == 'mg' + assert user['name'] == 'number 3' + assert user['custom'] == {'XXX': 'YYYY'} diff --git a/tests/integrational/fixtures/asyncio/members/get_members.yaml b/tests/integrational/fixtures/asyncio/members/get_members.yaml index 74df0e11..42d82e1d 100644 --- a/tests/integrational/fixtures/asyncio/members/get_members.yaml +++ b/tests/integrational/fixtures/asyncio/members/get_members.yaml @@ -5,36 +5,18 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%5B%22custom%22%2C+%22user%22%5D&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/spaces/value1/users?count=True&include=custom%2Cuser%2Cuser.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ - : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ - : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ - user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ - custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ - ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ - profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ - \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ - eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ - id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ - \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ - \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ - \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ - ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ - \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 37\n}" + string: '{"status":200,"data":[{"id":"mg3","custom":null,"user":{"id":"mg3","name":"MAGNUM3","externalId":null,"profileUrl":null,"email":null,"custom":{"ZZZ":"IIII"},"created":"2019-08-18T12:56:23.449026Z","updated":"2019-08-18T12:56:23.449026Z","eTag":"AfjKyYTB8vSyVA"},"created":"2019-08-20T19:03:19.191814Z","updated":"2019-08-20T19:03:19.191814Z","eTag":"AY39mJKK//C0VA"}],"totalCount":1,"next":"MQ"}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '1455' + Connection: keep-alive + Content-Encoding: gzip Content-Type: application/json - Date: Tue, 30 Jul 2019 17:50:13 GMT + Date: Tue, 20 Aug 2019 20:58:23 GMT + Server: nginx/1.15.6 + Transfer-Encoding: chunked + Vary: Accept-Encoding status: code: 200 message: OK @@ -43,7 +25,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users - - count=True&limit=10&include=%5B%22custom%22%2C%20%22user%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=713958cb-3b66-4a19-a481-7917e100224e + - /v1/objects/demo/spaces/value1/users + - count=True&include=custom,user,user.custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=f032239c-241a-45f7-ac74-02ebfe06a29e - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/members/get_space_memberships.yaml b/tests/integrational/fixtures/asyncio/members/get_space_memberships.yaml index ac61166a..20ab193b 100644 --- a/tests/integrational/fixtures/asyncio/members/get_space_memberships.yaml +++ b/tests/integrational/fixtures/asyncio/members/get_space_memberships.yaml @@ -5,33 +5,18 @@ interactions: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%5B%22custom%22%2C+%22space%22%5D&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg3/spaces?count=True&include=custom%2Cspace%2Cspace.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ - : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ - : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ - RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ - my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ - \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ - \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ - : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ - ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ - ,\n \"public\": true\n },\n \"description\": \"The\ - \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ - updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ - 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 7\n}" + string: '{"status":200,"data":[{"id":"value1","custom":null,"space":{"id":"value1","name":"value2","description":"abcd","custom":null,"created":"2019-08-12T22:57:54.167167Z","updated":"2019-08-12T22:57:54.167167Z","eTag":"AaHahZqsyr6AOg"},"created":"2019-08-20T18:57:59.610446Z","updated":"2019-08-20T18:57:59.610446Z","eTag":"AY39mJKK//C0VA"}],"totalCount":1,"next":"MQ"}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '1378' + Connection: keep-alive + Content-Encoding: gzip Content-Type: application/json - Date: Tue, 30 Jul 2019 17:50:13 GMT + Date: Tue, 20 Aug 2019 18:59:55 GMT + Server: nginx/1.15.6 + Transfer-Encoding: chunked + Vary: Accept-Encoding status: code: 200 message: OK @@ -40,7 +25,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces - - count=True&limit=10&include=%5B%22custom%22%2C%20%22space%22%5D&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=2b8c9d19-2de7-468d-bdac-ce4ed6048f0e + - /v1/objects/demo/users/mg3/spaces + - count=True&include=custom,space,space.custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=8d72a1a1-eec4-4b3f-84d6-53e88c80ded1 - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/members/update_members.yaml b/tests/integrational/fixtures/asyncio/members/update_members.yaml index d4721306..a9333112 100644 --- a/tests/integrational/fixtures/asyncio/members/update_members.yaml +++ b/tests/integrational/fixtures/asyncio/members/update_members.yaml @@ -1,41 +1,23 @@ interactions: - request: - body: '{"add": [{"id": "user-1"}], "update": [{"id": "user-2", "custom": {"role": - "moderator"}}], "remove": [{"id": "user-0"}]}' + body: '{"add": [{"id": "mg3"}]}' headers: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%22custom%22&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/spaces/value1/users?include=custom%2Cuser%2Cuser.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ - : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ - : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ - user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ - custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ - ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ - profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ - \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ - eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ - id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ - \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ - \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ - \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ - ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ - \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 37\n}" + string: '{"status":200,"data":[{"id":"mg","custom":null,"user":{"id":"mg","name":"number + 3","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-08-19T21:04:00.148418Z","updated":"2019-08-19T21:04:59.878283Z","eTag":"Af/+vv+glMjK3gE"},"created":"2019-08-20T19:01:57.736172Z","updated":"2019-08-20T19:01:57.736172Z","eTag":"AY39mJKK//C0VA"},{"id":"mg3","custom":null,"user":{"id":"mg3","name":"MAGNUM3","externalId":null,"profileUrl":null,"email":null,"custom":{"ZZZ":"IIII"},"created":"2019-08-18T12:56:23.449026Z","updated":"2019-08-18T12:56:23.449026Z","eTag":"AfjKyYTB8vSyVA"},"created":"2019-08-20T19:03:19.191814Z","updated":"2019-08-20T19:03:19.191814Z","eTag":"AY39mJKK//C0VA"}],"next":"Mg"}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '1455' + Connection: keep-alive + Content-Encoding: gzip Content-Type: application/json - Date: Sat, 03 Aug 2019 22:37:18 GMT + Date: Tue, 20 Aug 2019 19:03:19 GMT + Server: nginx/1.15.6 + Transfer-Encoding: chunked + Vary: Accept-Encoding status: code: 200 message: OK @@ -44,7 +26,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users - - count=True&limit=10&include=%22custom%22&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=56f4731a-403f-4610-8224-ed8a69b3d512 + - /v1/objects/demo/spaces/value1/users + - include=custom,user,user.custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=8cc8fb7d-6bb8-4109-a6b9-750490d89e7a - '' version: 1 diff --git a/tests/integrational/fixtures/asyncio/members/update_space_memberships.yaml b/tests/integrational/fixtures/asyncio/members/update_space_memberships.yaml index e3d4fdf9..999e2093 100644 --- a/tests/integrational/fixtures/asyncio/members/update_space_memberships.yaml +++ b/tests/integrational/fixtures/asyncio/members/update_space_memberships.yaml @@ -1,38 +1,22 @@ interactions: - request: - body: '{"add": [{"id": "my-channel"}], "update": [{"id": "main", "custom": {"starred": - true}}], "remove": [{"id": "space-0"}]}' + body: '{"add": [{"id": "value1"}]}' headers: User-Agent: - PubNub-Python-Asyncio/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%22custom%22&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg/spaces?include=custom%2Cspace%2Cspace.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ - : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ - : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ - RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ - my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ - \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ - \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ - : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ - ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ - ,\n \"public\": true\n },\n \"description\": \"The\ - \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ - updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ - 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 7\n}" + string: '{"status":200,"data":[{"id":"value1","custom":null,"space":{"id":"value1","name":"value2","description":"abcd","custom":null,"created":"2019-08-12T22:57:54.167167Z","updated":"2019-08-12T22:57:54.167167Z","eTag":"AaHahZqsyr6AOg"},"created":"2019-08-20T19:01:57.736172Z","updated":"2019-08-20T19:01:57.736172Z","eTag":"AY39mJKK//C0VA"}],"next":"MQ"}' headers: - Access-Control-Allow-Origin: '*' - Content-Length: '1378' + Connection: keep-alive + Content-Encoding: gzip Content-Type: application/json - Date: Sat, 03 Aug 2019 22:37:18 GMT + Date: Tue, 20 Aug 2019 19:01:57 GMT + Server: nginx/1.15.6 + Transfer-Encoding: chunked + Vary: Accept-Encoding status: code: 200 message: OK @@ -41,7 +25,7 @@ interactions: - !!python/object/new:urllib.parse.SplitResult - http - ps.pndsn.com - - /v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces - - count=True&limit=10&include=%22custom%22&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=3ca7ed05-0507-4c58-8e1b-92d811ab9cb7 + - /v1/objects/demo/users/mg/spaces + - include=custom,space,space.custom&pnsdk=PubNub-Python-Asyncio%2F4.1.0&uuid=ca41ef07-c7db-4874-be1d-7039c919ef6f - '' version: 1 diff --git a/tests/integrational/fixtures/native_sync/members/get_members.yaml b/tests/integrational/fixtures/native_sync/members/get_members.yaml index 08e13819..c8481a74 100644 --- a/tests/integrational/fixtures/native_sync/members/get_members.yaml +++ b/tests/integrational/fixtures/native_sync/members/get_members.yaml @@ -11,40 +11,28 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%5B%22custom%22%2C+%22user%22%5D&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/spaces/value1/users?count=True&include=custom%2Cuser%2Cuser.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ - : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ - : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ - user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ - custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ - ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ - profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ - \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ - eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ - id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ - \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ - \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ - \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ - ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ - \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 37\n}" + string: !!binary | + H4sIAAAAAAAAA4yQwWrCQBCG32XOUTebmGbnlnoQDQpiLJjSw9KsEtlNZDNbKsF37+aQQimCc5uf + b+aDv4eOJLkOkDMWQCVJAr73UFeAYM4RBPDpOmoNYOO0DsB1ygL+ARpplF822XJ72AyB+iZlG6lX + 1Xh1te2p1upg9ZgoI+vfZVT0UJalf7XyA3efWyVJDSbOQjFh6SRMi5DjPEEeTeNYMJ6UXuiu1VOc + KuTZQ9npkt+OxWv6tb+9ZY9FCUYCYzHl80S8PPb8w0bNMRJmneez2YINmo8AqCWpF61rCDD0zfmm + huZ2cP8BAAD//wMAxcUcvIkBAAA= headers: - Access-Control-Allow-Origin: - - '*' - Content-Length: - - '1455' + Connection: + - keep-alive + Content-Encoding: + - gzip Content-Type: - application/json Date: - - Tue, 30 Jul 2019 17:47:01 GMT + - Tue, 20 Aug 2019 18:40:53 GMT + Server: + - nginx/1.15.6 + Vary: + - Accept-Encoding status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/members/get_space_memberships.yaml b/tests/integrational/fixtures/native_sync/members/get_space_memberships.yaml index 9e9e812a..82bf250b 100644 --- a/tests/integrational/fixtures/native_sync/members/get_space_memberships.yaml +++ b/tests/integrational/fixtures/native_sync/members/get_space_memberships.yaml @@ -11,37 +11,28 @@ interactions: User-Agent: - PubNub-Python/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%5B%22custom%22%2C+%22space%22%5D&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg3/spaces?count=True&include=custom%2Cspace%2Cspace.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ - : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ - : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ - RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ - my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ - \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ - \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ - : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ - ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ - ,\n \"public\": true\n },\n \"description\": \"The\ - \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ - updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ - 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 7\n}" + string: !!binary | + H4sIAAAAAAAAA4yQzWrDMBCE32XOTiIpsRPtzeRSEkopmEJTethIIjX4L5ZUWoLfveohlzaFwh52 + hm9nYC/wgUP0ICVEBsuBQS8X1BaEd26ik8hgog99C+pi02TwAxsH+gl13LqrVklb581YD6Huu2Tz + 0dhfSWZ0HNx3ihJSz8RmJlWlFOVryldzWazTHNJVHOy/OFfxKUEl3/Hb4ew/x6J8OGG6WbSpZEFL + TSs9V3mh/+q5hV1rnpe63e33i8VWPJWYXjOEPnCz7WMXQDK9xH2kBfePmL4AAAD//wMADdpHBmkB + AAA= headers: - Access-Control-Allow-Origin: - - '*' - Content-Length: - - '1378' + Connection: + - keep-alive + Content-Encoding: + - gzip Content-Type: - application/json Date: - - Tue, 30 Jul 2019 17:47:01 GMT + - Tue, 20 Aug 2019 18:40:54 GMT + Server: + - nginx/1.15.6 + Vary: + - Accept-Encoding status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/members/update_members.yaml b/tests/integrational/fixtures/native_sync/members/update_members.yaml index ee17a06b..ef944998 100644 --- a/tests/integrational/fixtures/native_sync/members/update_members.yaml +++ b/tests/integrational/fixtures/native_sync/members/update_members.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{"add": [{"id": "mg3"}]}' headers: Accept: - '*/*' @@ -9,44 +9,33 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '24' User-Agent: - PubNub-Python/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%22custom%22&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/spaces/value1/users?include=custom%2Cuser%2Cuser.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ - : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ - : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ - user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ - custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ - ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ - profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ - \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ - eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ - id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ - \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ - \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ - \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ - ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ - \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 37\n}" + string: !!binary | + H4sIAAAAAAAAA6SQTU+DQBCG/4qZa1u6X8Cyt2qMqaRepKbFeFhlS9oAbYBtbJr+dwcT0BjQg3Pa + nX13nsxzhqrWta1AMULGkOhag3o+wzYBBXkKY3izVb3PQRU2y8ZgK1OC+v5e6NzgubD5qymvOHbM + e23KQmfzpP11KPebbWaWZdZ2TK633aVFnGG1WuGsNRZcsF8aXZuGxAgNJkROaBAxqohQhDhUSEFl + jEB7SIZybuBIXzLJm5yJdIqh2WY6Oh5HabbYhTy97ScxElGpBFOu67icMu73k/pzLWnNg/w+DKfT + G/I0Q1Anjv9lln+pXczuHpaLf5qN4xhHzbEGzMqI4hKeYtwRIiDMGzDbm+vM7sLTOrqWx8fT577D + YoXixPF9T3L+q9gfuQGxLygL5TSyUrh8AAAA//8DALYQqFjVAgAA headers: - Access-Control-Allow-Origin: - - '*' - Content-Length: - - '1455' + Connection: + - keep-alive + Content-Encoding: + - gzip Content-Type: - application/json Date: - - Sat, 03 Aug 2019 22:33:56 GMT + - Tue, 20 Aug 2019 18:44:30 GMT + Server: + - nginx/1.15.6 + Vary: + - Accept-Encoding status: code: 200 message: OK diff --git a/tests/integrational/fixtures/native_sync/members/update_space_memberships.yaml b/tests/integrational/fixtures/native_sync/members/update_space_memberships.yaml index 2dc8f81d..3e4322dd 100644 --- a/tests/integrational/fixtures/native_sync/members/update_space_memberships.yaml +++ b/tests/integrational/fixtures/native_sync/members/update_space_memberships.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{"add": [{"id": "value1"}]}' headers: Accept: - '*/*' @@ -9,41 +9,31 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '27' User-Agent: - PubNub-Python/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%22custom%22&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg/spaces?include=custom%2Cspace%2Cspace.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ - : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ - : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ - RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ - my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ - \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ - \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ - : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ - ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ - ,\n \"public\": true\n },\n \"description\": \"The\ - \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ - updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ - 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 7\n}" + string: !!binary | + H4sIAAAAAAAAA4yQSwvCMBCE/8ueq01SW2tuxYtYRIQiqHhYk1ALfdkkokj/u/HQiw8Q9jK7387A + PEAbNFYDZ4R4INEg8MMDCgkcrlhaRcEDYbVpKuC1LUsPdItCAX+HaqzUoJnTUmnRFa0pmtqt8STk + h5PoFBr1cmGEzkYkHlGWMcbDKQ8nYxpN3ezdl23lX5zKMHdQggs87y/63kXJOof+WxAjGY35xHmE + 4zCgLPgR9J0bgnbBrFqmqe/PyTaB/uhaUDfjLqsN9E8AAAD//wMA4a243FwBAAA= headers: - Access-Control-Allow-Origin: - - '*' - Content-Length: - - '1378' + Connection: + - keep-alive + Content-Encoding: + - gzip Content-Type: - application/json Date: - - Sat, 03 Aug 2019 22:33:56 GMT + - Tue, 20 Aug 2019 18:42:55 GMT + Server: + - nginx/1.15.6 + Vary: + - Accept-Encoding status: code: 200 message: OK diff --git a/tests/integrational/fixtures/tornado/members/get_members.yaml b/tests/integrational/fixtures/tornado/members/get_members.yaml index deb1f180..22c5bf55 100644 --- a/tests/integrational/fixtures/tornado/members/get_members.yaml +++ b/tests/integrational/fixtures/tornado/members/get_members.yaml @@ -7,49 +7,34 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%5B%22custom%22%2C+%22user%22%5D&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/spaces/value1/users?count=True&include=custom%2Cuser%2Cuser.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ - : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ - : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ - user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ - custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ - ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ - profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ - \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ - eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ - id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ - \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ - \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ - \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ - ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ - \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 37\n}" + string: '{"status":200,"data":[{"id":"mg3","custom":null,"user":{"id":"mg3","name":"MAGNUM3","externalId":null,"profileUrl":null,"email":null,"custom":{"ZZZ":"IIII"},"created":"2019-08-18T12:56:23.449026Z","updated":"2019-08-18T12:56:23.449026Z","eTag":"AfjKyYTB8vSyVA"},"created":"2019-08-20T18:44:30.776833Z","updated":"2019-08-20T18:44:30.776833Z","eTag":"AY39mJKK//C0VA"}],"totalCount":1,"next":"MQ"}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Tue, 20 Aug 2019 18:53:16 GMT - !!python/tuple - Content-Type - - application/json - !!python/tuple - - Date - - - Tue, 30 Jul 2019 17:57:24 GMT - - !!python/tuple - - Content-Length - - - '1455' + - Transfer-Encoding + - - chunked - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 + - !!python/tuple + - Vary + - - Accept-Encoding + - !!python/tuple + - X-Consumed-Content-Encoding + - - gzip status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&limit=10&include=%5B%22custom%22%2C%20%22user%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=fad8dc01-8290-4739-888d-97526afbefb2 + url: http://ps.pndsn.com/v1/objects/demo/spaces/value1/users?count=True&include=custom,user,user.custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=eaf633c6-898f-48f6-8a71-b639320f814f version: 1 diff --git a/tests/integrational/fixtures/tornado/members/get_space_memberships.yaml b/tests/integrational/fixtures/tornado/members/get_space_memberships.yaml index 9377b788..bd02692c 100644 --- a/tests/integrational/fixtures/tornado/members/get_space_memberships.yaml +++ b/tests/integrational/fixtures/tornado/members/get_space_memberships.yaml @@ -7,46 +7,34 @@ interactions: User-Agent: - PubNub-Python-Tornado/4.1.0 method: GET - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%5B%22custom%22%2C+%22space%22%5D&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg3/spaces?count=True&include=custom%2Cspace%2Cspace.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ - : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ - : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ - RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ - my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ - \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ - \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ - : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ - ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ - ,\n \"public\": true\n },\n \"description\": \"The\ - \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ - updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ - 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 7\n}" + string: '{"status":200,"data":[{"id":"value1","custom":null,"space":{"id":"value1","name":"value2","description":"abcd","custom":null,"created":"2019-08-12T22:57:54.167167Z","updated":"2019-08-12T22:57:54.167167Z","eTag":"AaHahZqsyr6AOg"},"created":"2019-08-20T18:44:30.776833Z","updated":"2019-08-20T18:44:30.776833Z","eTag":"AY39mJKK//C0VA"}],"totalCount":1,"next":"MQ"}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Tue, 20 Aug 2019 18:53:15 GMT - !!python/tuple - Content-Type - - application/json - !!python/tuple - - Date - - - Tue, 30 Jul 2019 17:57:24 GMT - - !!python/tuple - - Content-Length - - - '1378' + - Transfer-Encoding + - - chunked - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 + - !!python/tuple + - Vary + - - Accept-Encoding + - !!python/tuple + - X-Consumed-Content-Encoding + - - gzip status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&limit=10&include=%5B%22custom%22%2C%20%22space%22%5D&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=d7e7d41e-ba3d-4e4d-895b-8de8e4dbeb1a + url: http://ps.pndsn.com/v1/objects/demo/users/mg3/spaces?count=True&include=custom,space,space.custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=62d2895d-d784-42d9-a182-aa0e44e74874 version: 1 diff --git a/tests/integrational/fixtures/tornado/members/update_members.yaml b/tests/integrational/fixtures/tornado/members/update_members.yaml index 5345c3bb..f556744a 100644 --- a/tests/integrational/fixtures/tornado/members/update_members.yaml +++ b/tests/integrational/fixtures/tornado/members/update_members.yaml @@ -1,56 +1,41 @@ interactions: - request: - body: '{"add": [{"id": "user-1"}], "update": [{"id": "user-2", "custom": {"role": - "moderator"}}], "remove": [{"id": "user-0"}]}' + body: '{"add": [{"id": "mg3"}]}' headers: Accept-Encoding: - utf-8 User-Agent: - PubNub-Python-Tornado/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&include=%22custom%22&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/spaces/value1/users?include=custom%2Cuser%2Cuser.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"admin\"\n },\n \"eTag\"\ - : \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"id\"\ - : \"user-1\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \"\ - user\": {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"\ - custom\": null,\n \"eTag\": \"MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg==\"\ - ,\n \"email\": \"jack@twitter.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-1\",\n \"name\": \"John Doe\",\n \"\ - profileUrl\": null,\n \"updated\": \"2019-02-20T23:11:20.893755\"\n\ - \ }\n },\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"role\": \"moderator\"\n },\n \"\ - eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\",\n \"\ - id\": \"user-2\",\n \"updated\": \"2019-02-20T23:11:20.893755\",\n \ - \ \"user\": {\n \"created\": \"2019-02-19T13:10:20.893755\",\n \ - \ \"custom\": {\n \"phone\": \"999-999-9999\"\n },\n\ - \ \"eTag\": \"QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg==\"\ - ,\n \"email\": \"bobc@example.com\",\n \"externalId\": null,\n\ - \ \"id\": \"user-2\",\n \"name\": \"Bob Cat\",\n \"profileUrl\"\ - : null,\n \"updated\": \"2019-02-21T03:29:00.173452\"\n }\n \ - \ }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 37\n}" + string: '{"status":200,"data":[{"id":"mg","custom":null,"user":{"id":"mg","name":"number + 3","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-08-19T21:04:00.148418Z","updated":"2019-08-19T21:04:59.878283Z","eTag":"Af/+vv+glMjK3gE"},"created":"2019-08-20T18:56:06.814728Z","updated":"2019-08-20T18:56:06.814728Z","eTag":"AY39mJKK//C0VA"},{"id":"mg3","custom":null,"user":{"id":"mg3","name":"MAGNUM3","externalId":null,"profileUrl":null,"email":null,"custom":{"ZZZ":"IIII"},"created":"2019-08-18T12:56:23.449026Z","updated":"2019-08-18T12:56:23.449026Z","eTag":"AfjKyYTB8vSyVA"},"created":"2019-08-20T18:57:59.610446Z","updated":"2019-08-20T18:57:59.610446Z","eTag":"AY39mJKK//C0VA"}],"next":"Mg"}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Tue, 20 Aug 2019 18:57:59 GMT - !!python/tuple - Content-Type - - application/json - !!python/tuple - - Date - - - Sat, 03 Aug 2019 22:40:12 GMT - - !!python/tuple - - Content-Length - - - '1455' + - Transfer-Encoding + - - chunked - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 + - !!python/tuple + - Vary + - - Accept-Encoding + - !!python/tuple + - X-Consumed-Content-Encoding + - - gzip status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/spaces/main/users?count=True&limit=10&include=%22custom%22&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=0dc26bd2-433d-466c-a839-32f0e7330420 + url: http://ps.pndsn.com/v1/objects/demo/spaces/value1/users?include=custom,user,user.custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=418f4ab8-a5ea-4316-91b4-e831c138d71c version: 1 diff --git a/tests/integrational/fixtures/tornado/members/update_space_memberships.yaml b/tests/integrational/fixtures/tornado/members/update_space_memberships.yaml index 4c66ffc9..47aeecdf 100644 --- a/tests/integrational/fixtures/tornado/members/update_space_memberships.yaml +++ b/tests/integrational/fixtures/tornado/members/update_space_memberships.yaml @@ -1,53 +1,40 @@ interactions: - request: - body: '{"add": [{"id": "my-channel"}], "update": [{"id": "main", "custom": {"starred": - true}}], "remove": [{"id": "space-0"}]}' + body: '{"add": [{"id": "value1"}]}' headers: Accept-Encoding: - utf-8 User-Agent: - PubNub-Python-Tornado/4.1.0 method: PATCH - uri: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&include=%22custom%22&limit=10 + uri: http://ps.pndsn.com/v1/objects/demo/users/mg/spaces?include=custom%2Cspace%2Cspace.custom response: body: - string: "{\n \"data\": [\n {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"starred\": false\n },\n \"eTag\"\ - : \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\",\n \"id\"\ - : \"my-channel\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"description\": \"A space that is mine\",\n \"eTag\": \"\ - RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\",\n \"id\": \"\ - my-channel\",\n \"name\": \"My space\",\n \"updated\": \"2019-02-20T23:11:20.893755\"\ - \n },\n \"updated\": \"2019-02-20T23:11:20.893755\"\n },\n \ - \ {\n \"created\": \"2019-02-20T23:11:20.893755\",\n \"custom\"\ - : {\n \"starred\": true\n },\n \"eTag\": \"RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg==\"\ - ,\n \"id\": \"main\",\n \"space\": {\n \"created\": \"2019-02-20T23:11:20.893755\"\ - ,\n \"custom\": {\n \"motd\": \"Always check your spelling!\"\ - ,\n \"public\": true\n },\n \"description\": \"The\ - \ main space\",\n \"eTag\": \"RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg==\"\ - ,\n \"id\": \"main\",\n \"name\": \"Main space\",\n \"\ - updated\": \"2019-02-20T23:11:20.893755\"\n },\n \"updated\": \"\ - 2019-02-20T23:11:20.893755\"\n }\n ],\n \"next\": \"RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==\"\ - ,\n \"prev\": \"MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg==\",\n\ - \ \"status\": 200,\n \"totalCount\": 7\n}" + string: '{"status":200,"data":[{"id":"value1","custom":null,"space":{"id":"value1","name":"value2","description":"abcd","custom":null,"created":"2019-08-12T22:57:54.167167Z","updated":"2019-08-12T22:57:54.167167Z","eTag":"AaHahZqsyr6AOg"},"created":"2019-08-20T18:56:06.814728Z","updated":"2019-08-20T18:56:06.814728Z","eTag":"AY39mJKK//C0VA"}],"next":"MQ"}' headers: - !!python/tuple - - Access-Control-Allow-Origin - - - '*' + - Date + - - Tue, 20 Aug 2019 18:56:06 GMT - !!python/tuple - Content-Type - - application/json - !!python/tuple - - Date - - - Sat, 03 Aug 2019 22:40:12 GMT - - !!python/tuple - - Content-Length - - - '1378' + - Transfer-Encoding + - - chunked - !!python/tuple - Connection - - close + - !!python/tuple + - Server + - - nginx/1.15.6 + - !!python/tuple + - Vary + - - Accept-Encoding + - !!python/tuple + - X-Consumed-Content-Encoding + - - gzip status: code: 200 message: OK - url: http://ps.pndsn.com/v1/objects/sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe/users/charlie/spaces?count=True&limit=10&include=%22custom%22&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=07c69db6-bf20-4017-aa6e-bd51f96bfb22 + url: http://ps.pndsn.com/v1/objects/demo/users/mg/spaces?include=custom,space,space.custom&pnsdk=PubNub-Python-Tornado%2F4.1.0&uuid=76153731-6cfe-45ca-8507-83592e46d3db version: 1 diff --git a/tests/integrational/native_sync/test_membership.py b/tests/integrational/native_sync/test_membership.py index e56af284..aa8c7d57 100644 --- a/tests/integrational/native_sync/test_membership.py +++ b/tests/integrational/native_sync/test_membership.py @@ -1,4 +1,4 @@ -from tests.helper import pnconf_copy +from tests.helper import pnconf_obj_copy from tests.integrational.vcr_helper import pn_vcr from pubnub.structures import Envelope from pubnub.pubnub import PubNub @@ -10,107 +10,72 @@ @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/members/get_members.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_get_members(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.get_members().space_id('main').limit(10).count(True).include(['custom', 'user']).sync() + envelope = pn.get_members().space_id('value1').include(['custom', 'user', 'user.custom']).count(True).sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetMembersResult) assert isinstance(envelope.status, PNStatus) + assert envelope.result.total_count == 1 data = envelope.result.data - assert len(data) == 2 + assert len(data) == 1 assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) - assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) - assert data[0]['user']['id'] == 'user-1' - assert data[0]['user']['name'] == 'John Doe' + assert data[0]['user']['id'] == 'mg3' + assert data[0]['user']['name'] == 'MAGNUM3' + assert data[0]['user']['custom'] == {'ZZZ': 'IIII'} @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/members/get_space_memberships.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_get_space_memberships(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.get_space_memberships().user_id('charlie').limit(10).count(True).include(['custom', 'space']).sync() + envelope = pn.get_space_memberships().user_id('mg3').include(['custom', 'space', 'space.custom']).count(True).sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetSpaceMembershipsResult) assert isinstance(envelope.status, PNStatus) + assert envelope.result.total_count == 1 data = envelope.result.data - assert len(data) == 2 + assert len(data) == 1 assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) - assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) - assert data[0]['space']['id'] == 'my-channel' - assert data[0]['space']['name'] == 'My space' + assert data[0]['space']['id'] == 'value1' + assert data[0]['space']['name'] == 'value2' + assert data[0]['space']['description'] == 'abcd' + assert data[0]['space']['custom'] is None @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/members/update_space_memberships.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_update_space_memberships(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - data = { - "add": [ - { - "id": "my-channel" - } - ], - "update": [ - { - "id": "main", - "custom": { - "starred": True - } - } - ], - "remove": [ - { - "id": "space-0" - } - ] - } - envelope = pn.update_space_memberships().user_id('charlie').limit(10).count(True)\ - .include('custom').data(data).sync() + envelope = pn.update_space_memberships().user_id('mg').data( + {'add': [{'id': 'value1'}]}).include(['custom', 'space', 'space.custom']).sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNUpdateSpaceMembershipsResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert len(data) == 2 + assert len(data) == 1 assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) - assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) - assert data[0]['space']['id'] == 'my-channel' - assert data[0]['space']['name'] == 'My space' + assert data[0]['space']['id'] == 'value1' + assert data[0]['space']['name'] == 'value2' + assert data[0]['space']['description'] == 'abcd' + assert data[0]['space']['custom'] is None @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/members/update_members.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) def test_update_members(): - config = pnconf_copy() + config = pnconf_obj_copy() pn = PubNub(config) - data = { - "add": [ - { - "id": "user-1" - } - ], - "update": [ - { - "id": "user-2", - "custom": { - "role": "moderator" - } - } - ], - "remove": [ - { - "id": "user-0" - } - ] - } - envelope = pn.update_members().space_id('main').limit(10).count(True).include('custom').data(data).sync() + envelope = pn.update_members().space_id('value1').data( + {'add': [{'id': 'mg3'}]}).include(['custom', 'user', 'user.custom']).sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() @@ -120,5 +85,10 @@ def test_update_members(): assert len(data) == 2 assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) - assert data[0]['user']['id'] == 'user-1' - assert data[0]['user']['name'] == 'John Doe' + if data[0]['user']['id'] == 'mg': + user = data[0]['user'] + else: + user = data[1]['user'] + assert user['id'] == 'mg' + assert user['name'] == 'number 3' + assert user['custom'] == {'XXX': 'YYYY'} diff --git a/tests/integrational/tornado/test_membership.py b/tests/integrational/tornado/test_membership.py index c63b3a4e..7528b2b0 100644 --- a/tests/integrational/tornado/test_membership.py +++ b/tests/integrational/tornado/test_membership.py @@ -5,119 +5,83 @@ from pubnub.models.consumer.membership import (PNGetMembersResult, PNGetSpaceMembershipsResult, PNUpdateSpaceMembershipsResult, PNUpdateMembersResult) from pubnub.models.consumer.common import PNStatus -from tests.helper import pnconf_copy +from tests.helper import pnconf_obj_copy from tests.integrational.vcr_helper import pn_vcr class TestUser(AsyncTestCase): def setUp(self): AsyncTestCase.setUp(self) - config = pnconf_copy() + config = pnconf_obj_copy() self.pn = PubNubTornado(config, custom_ioloop=self.io_loop) @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/members/get_members.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_get_members(self): - envelope = yield self.pn.get_members().space_id('main').limit(10).count(True)\ - .include(['custom', 'user']).future() + envelope = yield self.pn.get_members().space_id('value1').include(['custom', 'user', 'user.custom'])\ + .count(True).future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetMembersResult) assert isinstance(envelope.status, PNStatus) + assert envelope.result.total_count == 1 data = envelope.result.data - assert len(data) == 2 + assert len(data) == 1 assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) - assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) - assert data[0]['user']['id'] == 'user-1' - assert data[0]['user']['name'] == 'John Doe' + assert data[0]['user']['id'] == 'mg3' + assert data[0]['user']['name'] == 'MAGNUM3' + assert data[0]['user']['custom'] == {'ZZZ': 'IIII'} self.pn.stop() @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/members/get_space_memberships.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_get_space_memberships(self): - envelope = yield self.pn.get_space_memberships().user_id('charlie').limit(10).count(True)\ - .include(['custom', 'space']).future() + envelope = yield self.pn.get_space_memberships().user_id('mg3').include(['custom', 'space', 'space.custom'])\ + .count(True).future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNGetSpaceMembershipsResult) assert isinstance(envelope.status, PNStatus) + assert envelope.result.total_count == 1 data = envelope.result.data - assert len(data) == 2 + assert len(data) == 1 assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) - assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) - assert data[0]['space']['id'] == 'my-channel' - assert data[0]['space']['name'] == 'My space' + assert data[0]['space']['id'] == 'value1' + assert data[0]['space']['name'] == 'value2' + assert data[0]['space']['description'] == 'abcd' + assert data[0]['space']['custom'] is None self.pn.stop() @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/members/update_space_memberships.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_update_space_memberships(self): - data = { - "add": [ - { - "id": "my-channel" - } - ], - "update": [ - { - "id": "main", - "custom": { - "starred": True - } - } - ], - "remove": [ - { - "id": "space-0" - } - ] - } - envelope = yield self.pn.update_space_memberships().user_id('charlie').limit(10).count(True)\ - .include('custom').data(data).future() + envelope = yield self.pn.update_space_memberships().user_id('mg').data( + {'add': [{'id': 'value1'}]}).include(['custom', 'space', 'space.custom']).future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() assert isinstance(envelope.result, PNUpdateSpaceMembershipsResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data - assert len(data) == 2 + assert len(data) == 1 assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[0]) - assert set(['id', 'space', 'created', 'updated', 'eTag', 'custom']) == set(data[1]) - assert data[0]['space']['id'] == 'my-channel' - assert data[0]['space']['name'] == 'My space' + assert data[0]['space']['id'] == 'value1' + assert data[0]['space']['name'] == 'value2' + assert data[0]['space']['description'] == 'abcd' + assert data[0]['space']['custom'] is None self.pn.stop() @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/members/update_members.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test def test_update_members(self): - data = { - "add": [ - { - "id": "user-1" - } - ], - "update": [ - { - "id": "user-2", - "custom": { - "role": "moderator" - } - } - ], - "remove": [ - { - "id": "user-0" - } - ] - } - envelope = yield self.pn.update_members().space_id('main').limit(10).count(True).include('custom')\ - .data(data).future() + envelope = yield self.pn.update_members().space_id('value1').data( + {'add': [{'id': 'mg3'}]}).include(['custom', 'user', 'user.custom']).future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() @@ -127,6 +91,11 @@ def test_update_members(self): assert len(data) == 2 assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[0]) assert set(['user', 'custom', 'id', 'created', 'updated', 'eTag']) == set(data[1]) - assert data[0]['user']['id'] == 'user-1' - assert data[0]['user']['name'] == 'John Doe' + if data[0]['user']['id'] == 'mg': + user = data[0]['user'] + else: + user = data[1]['user'] + assert user['id'] == 'mg' + assert user['name'] == 'number 3' + assert user['custom'] == {'XXX': 'YYYY'} self.pn.stop() From f381aeb253ebb911e2db4588ac3666ff70ab63fe Mon Sep 17 00:00:00 2001 From: QSD_z Date: Fri, 23 Aug 2019 22:22:05 +0200 Subject: [PATCH 24/26] Use proper argument name. --- pubnub/workers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pubnub/workers.py b/pubnub/workers.py index a046ec30..ced17061 100644 --- a/pubnub/workers.py +++ b/pubnub/workers.py @@ -72,19 +72,19 @@ def _process_incoming_payload(self, message): elif message.is_object: if message.payload['type'] == 'user': user_result = PNUserResult( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter - type=message.payload['event'], + event=message.payload['event'], data=message.payload['data'] ) self._listener_manager.announce_user(user_result) elif message.payload['type'] == 'space': space_result = PNSpaceResult( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter - type=message.payload['event'], + event=message.payload['event'], data=message.payload['data'] ) self._listener_manager.announce_space(space_result) else: membership_result = PNMembershipResult( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter - type=message.payload['event'], + event=message.payload['event'], data=message.payload['data'] ) self._listener_manager.announce_membership(membership_result) From e762b5099fd8eb9851d6bdc9cafe1daba647e702 Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sat, 24 Aug 2019 14:37:24 +0200 Subject: [PATCH 25/26] Rename update_members -> manage_members, update_space_memberships -> manage_memberships. --- .../{update_members.py => manage_members.py} | 16 ++++++++-------- ...pace_memberships.py => manage_memberships.py} | 16 ++++++++-------- pubnub/enums.py | 4 ++-- pubnub/managers.py | 4 ++-- pubnub/models/consumer/membership.py | 16 ++++++++-------- pubnub/pubnub_core.py | 12 ++++++------ ..._update_members.py => test_manage_members.py} | 8 ++++---- ...memberships.py => test_manage_memberships.py} | 8 ++++---- tests/integrational/asyncio/test_membership.py | 14 +++++++------- .../integrational/native_sync/test_membership.py | 14 +++++++------- tests/integrational/tornado/test_membership.py | 14 +++++++------- 11 files changed, 63 insertions(+), 63 deletions(-) rename pubnub/endpoints/membership/{update_members.py => manage_members.py} (86%) rename pubnub/endpoints/membership/{update_space_memberships.py => manage_memberships.py} (82%) rename tests/functional/membership/{test_update_members.py => test_manage_members.py} (83%) rename tests/functional/membership/{test_update_space_memberships.py => test_manage_memberships.py} (77%) diff --git a/pubnub/endpoints/membership/update_members.py b/pubnub/endpoints/membership/manage_members.py similarity index 86% rename from pubnub/endpoints/membership/update_members.py rename to pubnub/endpoints/membership/manage_members.py index 5c8f4d0c..e5cad199 100644 --- a/pubnub/endpoints/membership/update_members.py +++ b/pubnub/endpoints/membership/manage_members.py @@ -2,20 +2,20 @@ from pubnub import utils from pubnub.endpoints.endpoint import Endpoint -from pubnub.models.consumer.membership import PNUpdateMembersResult +from pubnub.models.consumer.membership import PNManageMembersResult from pubnub.enums import HttpMethod, PNOperationType from pubnub.exceptions import PubNubException -class UpdateMembers(Endpoint): - UPDATE_MEMBERS_PATH = '/v1/objects/%s/spaces/%s/users' +class ManageMembers(Endpoint): + MANAGE_MEMBERS_PATH = '/v1/objects/%s/spaces/%s/users' MAX_LIMIT = 100 def __init__(self, pubnub): Endpoint.__init__(self, pubnub) self._start = None self._end = None - self._limit = UpdateMembers.MAX_LIMIT + self._limit = ManageMembers.MAX_LIMIT self._count = False self._include = None self._space_id = None @@ -70,7 +70,7 @@ def custom_params(self): if self._count is True: params['count'] = True - if self._limit != UpdateMembers.MAX_LIMIT: + if self._limit != ManageMembers.MAX_LIMIT: params['limit'] = self._limit if self._include: @@ -81,7 +81,7 @@ def custom_params(self): def build_path(self): if self._space_id is None: raise PubNubException('Provide space_id.') - return UpdateMembers.UPDATE_MEMBERS_PATH % (self.pubnub.config.subscribe_key, self._space_id) + return ManageMembers.MANAGE_MEMBERS_PATH % (self.pubnub.config.subscribe_key, self._space_id) def http_method(self): return HttpMethod.PATCH @@ -95,7 +95,7 @@ def validate_params(self): raise PubNubException('Provide space_id.') def create_response(self, envelope): # pylint: disable=W0221 - return PNUpdateMembersResult(envelope) + return PNManageMembersResult(envelope) def request_timeout(self): return self.pubnub.config.non_subscribe_request_timeout @@ -104,7 +104,7 @@ def connect_timeout(self): return self.pubnub.config.connect_timeout def operation_type(self): - return PNOperationType.PNUpdateMembersOperation + return PNOperationType.PNManageMembersOperation def name(self): return 'Update members' diff --git a/pubnub/endpoints/membership/update_space_memberships.py b/pubnub/endpoints/membership/manage_memberships.py similarity index 82% rename from pubnub/endpoints/membership/update_space_memberships.py rename to pubnub/endpoints/membership/manage_memberships.py index 6162163f..66a28cd1 100644 --- a/pubnub/endpoints/membership/update_space_memberships.py +++ b/pubnub/endpoints/membership/manage_memberships.py @@ -2,20 +2,20 @@ from pubnub import utils from pubnub.endpoints.endpoint import Endpoint -from pubnub.models.consumer.membership import PNUpdateSpaceMembershipsResult +from pubnub.models.consumer.membership import PNManageMembershipsResult from pubnub.enums import HttpMethod, PNOperationType from pubnub.exceptions import PubNubException -class UpdateSpaceMemberships(Endpoint): - UPDATE_SPACE_MEMBERSHIPS_PATH = '/v1/objects/%s/users/%s/spaces' +class ManageMemberships(Endpoint): + MANAGE_MEMBERSHIPS_PATH = '/v1/objects/%s/users/%s/spaces' MAX_LIMIT = 100 def __init__(self, pubnub): Endpoint.__init__(self, pubnub) self._start = None self._end = None - self._limit = UpdateSpaceMemberships.MAX_LIMIT + self._limit = ManageMemberships.MAX_LIMIT self._count = False self._include = None self._user_id = None @@ -70,7 +70,7 @@ def custom_params(self): if self._count is True: params['count'] = True - if self._limit != UpdateSpaceMemberships.MAX_LIMIT: + if self._limit != ManageMemberships.MAX_LIMIT: params['limit'] = self._limit if self._include: @@ -81,7 +81,7 @@ def custom_params(self): def build_path(self): if self._user_id is None: raise PubNubException('Provide user_id.') - return UpdateSpaceMemberships.UPDATE_SPACE_MEMBERSHIPS_PATH % (self.pubnub.config.subscribe_key, self._user_id) + return ManageMemberships.MANAGE_MEMBERSHIPS_PATH % (self.pubnub.config.subscribe_key, self._user_id) def http_method(self): return HttpMethod.PATCH @@ -95,7 +95,7 @@ def validate_params(self): raise PubNubException('Provide user_id.') def create_response(self, envelope): # pylint: disable=W0221 - return PNUpdateSpaceMembershipsResult(envelope) + return PNManageMembershipsResult(envelope) def request_timeout(self): return self.pubnub.config.non_subscribe_request_timeout @@ -104,7 +104,7 @@ def connect_timeout(self): return self.pubnub.config.connect_timeout def operation_type(self): - return PNOperationType.PNUpdateSpaceMembershipsOperation + return PNOperationType.PNManageMembershipsOperation def name(self): return 'Update space memberships' diff --git a/pubnub/enums.py b/pubnub/enums.py index dd874c3e..570754eb 100644 --- a/pubnub/enums.py +++ b/pubnub/enums.py @@ -77,8 +77,8 @@ class PNOperationType(object): PNDeleteSpaceOperation = 36 PNGetMembersOperation = 37 PNGetSpaceMembershipsOperation = 38 - PNUpdateMembersOperation = 39 - PNUpdateSpaceMembershipsOperation = 40 + PNManageMembersOperation = 39 + PNManageMembershipsOperation = 40 class PNHeartbeatNotificationOptions(object): diff --git a/pubnub/managers.py b/pubnub/managers.py index 59f821be..88e40810 100644 --- a/pubnub/managers.py +++ b/pubnub/managers.py @@ -476,8 +476,8 @@ def endpoint_name_for_operation(operation_type): PNOperationType.PNDeleteSpaceOperation: 'obj', PNOperationType.PNGetMembersOperation: 'obj', PNOperationType.PNGetSpaceMembershipsOperation: 'obj', - PNOperationType.PNUpdateMembersOperation: 'obj', - PNOperationType.PNUpdateSpaceMembershipsOperation: 'obj', + PNOperationType.PNManageMembersOperation: 'obj', + PNOperationType.PNManageMembershipsOperation: 'obj', }[operation_type] return endpoint diff --git a/pubnub/models/consumer/membership.py b/pubnub/models/consumer/membership.py index 249025fb..3df6fa9c 100644 --- a/pubnub/models/consumer/membership.py +++ b/pubnub/models/consumer/membership.py @@ -15,12 +15,12 @@ def __str__(self): return "Get space memberships success with data: %s" % self.space -class PNUpdateSpaceMembershipsResult(object): +class PNManageMembershipsResult(object): def __init__(self, result): """ - Representation of update space memeberships response + Representation of manage memeberships response - :param result: result of update space memeberships operation + :param result: result of manage memeberships operation """ self.data = result['data'] self.status = result['status'] @@ -29,7 +29,7 @@ def __init__(self, result): self.prev = result.get('prev', None) def __str__(self): - return "Update space memebership success with data: %s" % self.data + return "Manage memeberships success with data: %s" % self.data class PNGetMembersResult(object): @@ -49,12 +49,12 @@ def __str__(self): return "Get members success with data: %s" % self.data -class PNUpdateMembersResult(object): +class PNManageMembersResult(object): def __init__(self, result): """ - Representation of update members server response + Representation of manage members server response - :param result: result of update members operation + :param result: result of manage members operation """ self.data = result['data'] self.status = result['status'] @@ -63,7 +63,7 @@ def __init__(self, result): self.prev = result.get('prev', None) def __str__(self): - return "Update update members success with data: %s" % self.data + return "Manage members success with data: %s" % self.data class PNMembershipResult(object): diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index cd0883bb..13afdd38 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -37,8 +37,8 @@ from .endpoints.space.create_space import CreateSpace from .endpoints.membership.get_space_memberships import GetSpaceMemberships from .endpoints.membership.get_members import GetMembers -from .endpoints.membership.update_members import UpdateMembers -from .endpoints.membership.update_space_memberships import UpdateSpaceMemberships +from .endpoints.membership.manage_members import ManageMembers +from .endpoints.membership.manage_memberships import ManageMemberships from .endpoints.push.add_channels_to_push import AddChannelsToPush from .endpoints.push.remove_channels_from_push import RemoveChannelsFromPush @@ -219,11 +219,11 @@ def get_space_memberships(self): def get_members(self): return GetMembers(self) - def update_members(self): - return UpdateMembers(self) + def manage_members(self): + return ManageMembers(self) - def update_space_memberships(self): - return UpdateSpaceMemberships(self) + def manage_memberships(self): + return ManageMemberships(self) def time(self): return Time(self) diff --git a/tests/functional/membership/test_update_members.py b/tests/functional/membership/test_manage_members.py similarity index 83% rename from tests/functional/membership/test_update_members.py rename to tests/functional/membership/test_manage_members.py index 2ec55a29..09242880 100644 --- a/tests/functional/membership/test_update_members.py +++ b/tests/functional/membership/test_manage_members.py @@ -1,7 +1,7 @@ import pytest from pubnub.pubnub import PubNub from pubnub.pnconfiguration import PNConfiguration -from pubnub.endpoints.membership.update_members import UpdateMembers +from pubnub.endpoints.membership.manage_members import ManageMembers from pubnub.exceptions import PubNubException @@ -9,18 +9,18 @@ AUTH = 'auth' -def test_get_members(): +def test_manage_members(): config = PNConfiguration() config.subscribe_key = SUB_KEY config.auth_key = AUTH - membership = PubNub(config).update_members() + membership = PubNub(config).manage_members() membership.include(['custom']).limit(30).end('XXX') with pytest.raises(PubNubException): membership.validate_params() membership.space_id('foo') - assert membership.build_path() == UpdateMembers.UPDATE_MEMBERS_PATH % (SUB_KEY, 'foo') + assert membership.build_path() == ManageMembers.MANAGE_MEMBERS_PATH % (SUB_KEY, 'foo') params = membership.custom_params() assert params['include'] == 'custom' diff --git a/tests/functional/membership/test_update_space_memberships.py b/tests/functional/membership/test_manage_memberships.py similarity index 77% rename from tests/functional/membership/test_update_space_memberships.py rename to tests/functional/membership/test_manage_memberships.py index c2ee3801..ca8e7c50 100644 --- a/tests/functional/membership/test_update_space_memberships.py +++ b/tests/functional/membership/test_manage_memberships.py @@ -1,7 +1,7 @@ import pytest from pubnub.pubnub import PubNub from pubnub.pnconfiguration import PNConfiguration -from pubnub.endpoints.membership.update_space_memberships import UpdateSpaceMemberships +from pubnub.endpoints.membership.manage_memberships import ManageMemberships from pubnub.exceptions import PubNubException @@ -9,18 +9,18 @@ AUTH = 'auth' -def test_get_space_memberships(): +def test_manage_memberships(): config = PNConfiguration() config.subscribe_key = SUB_KEY config.auth_key = AUTH - membership = PubNub(config).update_space_memberships() + membership = PubNub(config).manage_memberships() membership.include(['custom']).limit(30).end('XXX') with pytest.raises(PubNubException): membership.validate_params() membership.user_id('foo') - assert membership.build_path() == UpdateSpaceMemberships.UPDATE_SPACE_MEMBERSHIPS_PATH % (SUB_KEY, 'foo') + assert membership.build_path() == ManageMemberships.MANAGE_MEMBERSHIPS_PATH % (SUB_KEY, 'foo') params = membership.custom_params() assert params['include'] == 'custom' diff --git a/tests/integrational/asyncio/test_membership.py b/tests/integrational/asyncio/test_membership.py index f5e2af80..f6b6b033 100644 --- a/tests/integrational/asyncio/test_membership.py +++ b/tests/integrational/asyncio/test_membership.py @@ -4,7 +4,7 @@ from tests.integrational.vcr_helper import pn_vcr from pubnub.pubnub_asyncio import PubNubAsyncio, AsyncioEnvelope from pubnub.models.consumer.membership import (PNGetMembersResult, PNGetSpaceMembershipsResult, - PNUpdateMembersResult, PNUpdateSpaceMembershipsResult) + PNManageMembersResult, PNManageMembershipsResult) from pubnub.models.consumer.common import PNStatus @@ -56,15 +56,15 @@ def test_get_space_memberships(event_loop): @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/members/update_space_memberships.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio -def test_update_space_memberships(event_loop): +def test_manage_memberships(event_loop): config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.update_space_memberships().user_id('mg').data( + envelope = yield from pn.manage_memberships().user_id('mg').data( {'add': [{'id': 'value1'}]}).include(['custom', 'space', 'space.custom']).future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() - assert isinstance(envelope.result, PNUpdateSpaceMembershipsResult) + assert isinstance(envelope.result, PNManageMembershipsResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert len(data) == 1 @@ -78,15 +78,15 @@ def test_update_space_memberships(event_loop): @pn_vcr.use_cassette('tests/integrational/fixtures/asyncio/members/update_members.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @pytest.mark.asyncio -def test_update_members(event_loop): +def test_manage_members(event_loop): config = pnconf_obj_copy() pn = PubNubAsyncio(config, custom_event_loop=event_loop) - envelope = yield from pn.update_members().space_id('value1').data( + envelope = yield from pn.manage_members().space_id('value1').data( {'add': [{'id': 'mg3'}]}).include(['custom', 'user', 'user.custom']).future() assert(isinstance(envelope, AsyncioEnvelope)) assert not envelope.status.is_error() - assert isinstance(envelope.result, PNUpdateMembersResult) + assert isinstance(envelope.result, PNManageMembersResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert len(data) == 2 diff --git a/tests/integrational/native_sync/test_membership.py b/tests/integrational/native_sync/test_membership.py index aa8c7d57..72ee4d22 100644 --- a/tests/integrational/native_sync/test_membership.py +++ b/tests/integrational/native_sync/test_membership.py @@ -3,7 +3,7 @@ from pubnub.structures import Envelope from pubnub.pubnub import PubNub from pubnub.models.consumer.membership import (PNGetMembersResult, PNGetSpaceMembershipsResult, - PNUpdateSpaceMembershipsResult, PNUpdateMembersResult) + PNManageMembershipsResult, PNManageMembersResult) from pubnub.models.consumer.common import PNStatus @@ -50,15 +50,15 @@ def test_get_space_memberships(): @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/members/update_space_memberships.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) -def test_update_space_memberships(): +def test_manage_memberships(): config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.update_space_memberships().user_id('mg').data( + envelope = pn.manage_memberships().user_id('mg').data( {'add': [{'id': 'value1'}]}).include(['custom', 'space', 'space.custom']).sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() - assert isinstance(envelope.result, PNUpdateSpaceMembershipsResult) + assert isinstance(envelope.result, PNManageMembershipsResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert len(data) == 1 @@ -71,15 +71,15 @@ def test_update_space_memberships(): @pn_vcr.use_cassette('tests/integrational/fixtures/native_sync/members/update_members.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) -def test_update_members(): +def test_manage_members(): config = pnconf_obj_copy() pn = PubNub(config) - envelope = pn.update_members().space_id('value1').data( + envelope = pn.manage_members().space_id('value1').data( {'add': [{'id': 'mg3'}]}).include(['custom', 'user', 'user.custom']).sync() assert(isinstance(envelope, Envelope)) assert not envelope.status.is_error() - assert isinstance(envelope.result, PNUpdateMembersResult) + assert isinstance(envelope.result, PNManageMembersResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert len(data) == 2 diff --git a/tests/integrational/tornado/test_membership.py b/tests/integrational/tornado/test_membership.py index 7528b2b0..19c81e17 100644 --- a/tests/integrational/tornado/test_membership.py +++ b/tests/integrational/tornado/test_membership.py @@ -3,7 +3,7 @@ from pubnub.pubnub_tornado import PubNubTornado, TornadoEnvelope from pubnub.models.consumer.membership import (PNGetMembersResult, PNGetSpaceMembershipsResult, - PNUpdateSpaceMembershipsResult, PNUpdateMembersResult) + PNManageMembershipsResult, PNManageMembersResult) from pubnub.models.consumer.common import PNStatus from tests.helper import pnconf_obj_copy from tests.integrational.vcr_helper import pn_vcr @@ -59,13 +59,13 @@ def test_get_space_memberships(self): @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/members/update_space_memberships.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test - def test_update_space_memberships(self): - envelope = yield self.pn.update_space_memberships().user_id('mg').data( + def test_manage_memberships(self): + envelope = yield self.pn.manage_memberships().user_id('mg').data( {'add': [{'id': 'value1'}]}).include(['custom', 'space', 'space.custom']).future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() - assert isinstance(envelope.result, PNUpdateSpaceMembershipsResult) + assert isinstance(envelope.result, PNManageMembershipsResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert len(data) == 1 @@ -79,13 +79,13 @@ def test_update_space_memberships(self): @pn_vcr.use_cassette('tests/integrational/fixtures/tornado/members/update_members.yaml', filter_query_parameters=['uuid', 'seqn', 'pnsdk']) @tornado.testing.gen_test - def test_update_members(self): - envelope = yield self.pn.update_members().space_id('value1').data( + def test_manage_members(self): + envelope = yield self.pn.manage_members().space_id('value1').data( {'add': [{'id': 'mg3'}]}).include(['custom', 'user', 'user.custom']).future() assert(isinstance(envelope, TornadoEnvelope)) assert not envelope.status.is_error() - assert isinstance(envelope.result, PNUpdateMembersResult) + assert isinstance(envelope.result, PNManageMembersResult) assert isinstance(envelope.status, PNStatus) data = envelope.result.data assert len(data) == 2 From bf024cc10b406c7b583e9b66765ec4d8827a29df Mon Sep 17 00:00:00 2001 From: QSD_z Date: Sat, 24 Aug 2019 15:31:48 +0200 Subject: [PATCH 26/26] Prepare for release 4.1.6. --- .pubnub.yml | 29 ++++++++++++++++++++++++++++- CHANGELOG.md | 6 ++++++ setup.py | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index cc3e2ad7..9309f0db 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,8 +1,13 @@ name: python -version: 4.1.5 +version: 4.1.6 schema: 1 scm: github.com/pubnub/python changelog: + - version: v4.1.6 + date: Aug 24, 2019 + changes: + - type: improvement + text: implement Objects API - version: v4.1.5 date: Aug 9, 2019 changes: @@ -168,8 +173,30 @@ features: - SUBSCRIBE-WILDCARD - SUBSCRIBE-PUBLISHER-UUID - SUBSCRIBE-SIGNAL-LISTENER + - SUBSCRIBE-USER-LISTENER + - SUBSCRIBE-SPACE-LISTENER + - SUBSCRIBE-MEMBERSHIP-LISTENER signal: - SIGNAL-SEND + objects: + - OBJECTS-GET-USER + - OBJECTS-GET-USERS + - OBJECTS-CREATE-USER + - OBJECTS-UPDATE-USER + - OBJECTS-DELETE-USER + - OBJECTS-GET-SPACE + - OBJECTS-GET-SPACES + - OBJECTS-CREATE-SPACE + - OBJECTS-UPDATE-SPACE + - OBJECTS-DELETE-SPACE + - OBJECTS-GET-MEMBERSHIPS + - OBJECTS-JOIN-SPACES + - OBJECTS-UPDATE-MEMBERSHIPS + - OBJECTS-LEAVE-SPACES + - OBJECTS-GET-MEMBERS + - OBJECTS-ADD-MEMBERS + - OBJECTS-UPDATE-MEMBERS + - OBJECTS-REMOVE-MEMBERS supported-platforms: - diff --git a/CHANGELOG.md b/CHANGELOG.md index ed1d451e..e84ef71b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [4.1.6](https://github.com/pubnub/python/tree/v4.1.6) + + [Full Changelog](https://github.com/pubnub/python/compare/v4.1.5...v4.1.6) + +- 🐛implement Objects API + ## [4.1.5](https://github.com/pubnub/python/tree/v4.1.5) [Full Changelog](https://github.com/pubnub/python/compare/v4.1.4...v4.1.5) diff --git a/setup.py b/setup.py index c0abc11a..c652f193 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='pubnub', - version='4.1.5', + version='4.1.6', description='PubNub Real-time push service in the cloud', author='PubNub', author_email='support@pubnub.com',