Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/integrational/asyncio/test_channel_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pubnub.models.consumer.channel_group import PNChannelGroupsAddChannelResult, PNChannelGroupsListResult, \
PNChannelGroupsRemoveChannelResult, PNChannelGroupsRemoveGroupResult
from pubnub.pubnub_asyncio import PubNubAsyncio
from tests.helper import pnconf, pnconf_copy, pnconf_pam_copy
from tests.helper import pnconf, pnconf_copy, pnconf_pam_env_copy
from tests.integrational.vcr_asyncio_sleeper import get_sleeper
from tests.integrational.vcr_helper import pn_vcr

Expand Down Expand Up @@ -137,7 +137,7 @@ async def test_add_channel_remove_group(event_loop, sleeper=asyncio.sleep):

@pytest.mark.asyncio
async def test_super_call(event_loop):
pubnub = PubNubAsyncio(pnconf_pam_copy(), custom_event_loop=event_loop)
pubnub = PubNubAsyncio(pnconf_pam_env_copy(), custom_event_loop=event_loop)

ch = "channel-groups-torna|do-ch"
gr = "channel-groups-torna|do-cg"
Expand Down
8 changes: 5 additions & 3 deletions tests/integrational/asyncio/test_heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
import pubnub as pn
from pubnub.pubnub_asyncio import PubNubAsyncio, SubscribeListener
from tests import helper
from tests.helper import pnconf_sub_copy
from tests.helper import pnconf_env_copy

pn.set_stream_logger('pubnub', logging.DEBUG)


messenger_config = pnconf_sub_copy()
messenger_config = pnconf_env_copy()
messenger_config.set_presence_timeout(8)
messenger_config.enable_subscribe = True
messenger_config.uuid = helper.gen_channel("messenger")

listener_config = pnconf_sub_copy()
listener_config = pnconf_env_copy()
listener_config.enable_subscribe = True
listener_config.uuid = helper.gen_channel("listener")


Expand Down
4 changes: 2 additions & 2 deletions tests/integrational/asyncio/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from pubnub.models.consumer.presence import PNSetStateResult, PNGetStateResult
from pubnub.pubnub_asyncio import PubNubAsyncio
from tests.helper import pnconf, pnconf_copy, pnconf_sub_copy, pnconf_pam_copy
from tests.helper import pnconf, pnconf_copy, pnconf_sub_copy, pnconf_pam_env_copy
from tests.integrational.vcr_asyncio_sleeper import get_sleeper, VCR599Listener
from tests.integrational.vcr_helper import pn_vcr

Expand Down Expand Up @@ -118,7 +118,7 @@ async def test_multiple_channels(event_loop):

@pytest.mark.asyncio
async def test_state_super_admin_call(event_loop):
pnconf = pnconf_pam_copy()
pnconf = pnconf_pam_env_copy()
pubnub = PubNubAsyncio(pnconf, custom_event_loop=event_loop)
ch1 = 'test-state-asyncio-ch1'
ch2 = 'test-state-asyncio-ch2'
Expand Down
8 changes: 4 additions & 4 deletions tests/integrational/native_sync/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pubnub.models.consumer.history import PNHistoryResult
from pubnub.models.consumer.pubsub import PNPublishResult
from pubnub.pubnub import PubNub
from tests.helper import pnconf_copy, pnconf_enc_copy, pnconf_pam_copy
from tests.helper import pnconf_copy, pnconf_enc_copy, pnconf_pam_env_copy
from tests.integrational.vcr_helper import use_cassette_and_stub_time_sleep_native

pubnub.set_stream_logger('pubnub', logging.DEBUG)
Expand Down Expand Up @@ -79,15 +79,15 @@ def test_encrypted(self, crypto_mock):
filter_query_parameters=['uuid', 'pnsdk'])
def test_not_permitted(self):
ch = "history-native-sync-ch"
pubnub = PubNub(pnconf_pam_copy())
pubnub = PubNub(pnconf_pam_env_copy())
pubnub.config.uuid = "history-native-sync-uuid"

with pytest.raises(PubNubException):
pubnub.history().channel(ch).count(5).sync()

def test_super_call_with_channel_only(self):
ch = "history-native-sync-ch"
pubnub = PubNub(pnconf_pam_copy())
pubnub = PubNub(pnconf_pam_env_copy())
pubnub.config.uuid = "history-native-sync-uuid"

envelope = pubnub.history().channel(ch).sync()
Expand All @@ -97,7 +97,7 @@ def test_super_call_with_channel_only(self):

def test_super_call_with_all_params(self):
ch = "history-native-sync-ch"
pubnub = PubNub(pnconf_pam_copy())
pubnub = PubNub(pnconf_pam_env_copy())
pubnub.config.uuid = "history-native-sync-uuid"

envelope = pubnub.history().channel(ch).count(2).include_timetoken(True).reverse(True).start(1).end(2).sync()
Expand Down
6 changes: 3 additions & 3 deletions tests/integrational/native_sync/test_history_delete.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import unittest

from pubnub.exceptions import PubNubException
from tests.helper import pnconf
from tests.helper import pnconf_env_copy
from pubnub.pubnub import PubNub


class TestPubNubHistoryDelete(unittest.TestCase): # pylint: disable=W0612
def test_success(self):
try:
env = PubNub(pnconf).delete_messages() \
env = PubNub(pnconf_env_copy()).delete_messages() \
.channel("my-ch") \
.start(123) \
.end(456) \
Expand All @@ -22,7 +22,7 @@ def test_success(self):

def test_super_call(self):
try:
env = PubNub(pnconf).delete_messages() \
env = PubNub(pnconf_env_copy()).delete_messages() \
.channel("my-ch- |.* $") \
.start(123) \
.end(456) \
Expand Down
4 changes: 2 additions & 2 deletions tests/integrational/native_sync/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pubnub
from pubnub.models.consumer.presence import PNSetStateResult, PNGetStateResult
from pubnub.pubnub import PubNub
from tests.helper import pnconf_copy, pnconf_pam_copy
from tests.helper import pnconf_copy, pnconf_pam_env_copy
from tests.integrational.vcr_helper import pn_vcr

pubnub.set_stream_logger('pubnub', logging.DEBUG)
Expand Down Expand Up @@ -57,7 +57,7 @@ def test_multiple_channels(self):
def test_super_call(self):
ch1 = "state-tornado-ch1"
ch2 = "state-tornado-ch2"
pnconf = pnconf_pam_copy()
pnconf = pnconf_pam_env_copy()
pubnub = PubNub(pnconf)
pubnub.config.uuid = 'test-state-native-uuid-|.*$'
state = {"name": "Alex", "count": 5}
Expand Down
8 changes: 5 additions & 3 deletions tests/integrational/native_threads/test_heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@

from pubnub.pubnub import PubNub, SubscribeListener
from tests import helper
from tests.helper import pnconf_sub_copy
from tests.helper import pnconf_env_copy

pn.set_stream_logger('pubnub', logging.DEBUG)


# TODO: add a success heartbeat test

messenger_config = pnconf_sub_copy()
messenger_config = pnconf_env_copy()
messenger_config.set_presence_timeout(8)
messenger_config.enable_subscribe = True
messenger_config.uuid = helper.gen_channel("messenger")

listener_config = pnconf_sub_copy()
listener_config = pnconf_env_copy()
listener_config.enable_subscribe = True
listener_config.uuid = helper.gen_channel("listener")


Expand Down
6 changes: 3 additions & 3 deletions tests/integrational/native_threads/test_history_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import threading

from pubnub.pubnub import PubNub
from tests.helper import pnconf
from tests.helper import pnconf_env_copy


class TestPubNubSuccessHistoryDelete(unittest.TestCase): # pylint: disable=W0612
Expand All @@ -23,7 +23,7 @@ def assert_success(self):
self.status = None

def test_success(self):
PubNub(pnconf).delete_messages() \
PubNub(pnconf_env_copy()).delete_messages() \
.channel("my-ch") \
.start(123) \
.end(456) \
Expand All @@ -32,7 +32,7 @@ def test_success(self):
self.assert_success()

def test_super_call(self):
PubNub(pnconf).delete_messages() \
PubNub(pnconf_env_copy()).delete_messages() \
.channel("my-ch- |.* $") \
.start(123) \
.end(456) \
Expand Down
28 changes: 14 additions & 14 deletions tests/integrational/native_threads/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from pubnub.models.consumer.pubsub import PNPublishResult
from pubnub.pubnub import PubNub
from tests.helper import pnconf, pnconf_enc, pnconf_pam_copy, pnconf_copy
from tests.helper import pnconf_enc_env_copy, pnconf_pam_env_copy, pnconf_env_copy

pubnub.set_stream_logger('pubnub', logging.DEBUG)

Expand All @@ -31,15 +31,15 @@ def assert_success(self):
self.status = None

def assert_success_publish_get(self, msg):
PubNub(pnconf).publish() \
PubNub(pnconf_env_copy()).publish() \
.channel("ch1") \
.message(msg) \
.pn_async(self.callback)

self.assert_success()

def assert_success_publish_post(self, msg):
PubNub(pnconf).publish() \
PubNub(pnconf_env_copy()).publish() \
.channel("ch1") \
.message(msg) \
.use_post(True) \
Expand All @@ -62,7 +62,7 @@ def test_publish_post(self):
self.assert_success_publish_post({"name": "Alex", "online": True})

def test_publish_encrypted_list_get(self):
pubnub = PubNub(pnconf_enc)
pubnub = PubNub(pnconf_enc_env_copy())

pubnub.publish() \
.channel("ch1") \
Expand All @@ -72,15 +72,15 @@ def test_publish_encrypted_list_get(self):
self.assert_success()

def test_publish_encrypted_string_get(self):
PubNub(pnconf_enc).publish() \
PubNub(pnconf_enc_env_copy()).publish() \
.channel("ch1") \
.message("encrypted string") \
.pn_async(self.callback)

self.assert_success()

def test_publish_encrypted_list_post(self):
PubNub(pnconf_enc).publish() \
PubNub(pnconf_enc_env_copy()).publish() \
.channel("ch1") \
.message(["encrypted", "list"]) \
.use_post(True) \
Expand All @@ -89,7 +89,7 @@ def test_publish_encrypted_list_post(self):
self.assert_success()

def test_publish_encrypted_string_post(self):
PubNub(pnconf_enc).publish() \
PubNub(pnconf_enc_env_copy()).publish() \
.channel("ch1") \
.message("encrypted string") \
.use_post(True) \
Expand All @@ -100,7 +100,7 @@ def test_publish_encrypted_string_post(self):
def test_publish_with_meta(self):
meta = {'a': 2, 'b': 'qwer'}

PubNub(pnconf_enc).publish() \
PubNub(pnconf_enc_env_copy()).publish() \
.channel("ch1") \
.message("hey") \
.meta(meta) \
Expand All @@ -109,7 +109,7 @@ def test_publish_with_meta(self):
self.assert_success()

def test_publish_do_not_store(self):
PubNub(pnconf_enc).publish() \
PubNub(pnconf_enc_env_copy()).publish() \
.channel("ch1") \
.message("hey") \
.should_store(False) \
Expand All @@ -129,7 +129,7 @@ def callback(self, response, status):

def test_invalid_key(self):
self.invalid_key_message = ""
pn_fake_key_config = pnconf_copy()
pn_fake_key_config = pnconf_env_copy()
pn_fake_key_config.publish_key = "fake"

PubNub(pn_fake_key_config).publish() \
Expand All @@ -147,7 +147,7 @@ def test_invalid_key(self):
assert "Invalid Key" in str(self.status.error_data.exception)

def test_missing_message(self):
PubNub(pnconf).publish() \
PubNub(pnconf_env_copy()).publish() \
.channel("ch1") \
.message(None) \
.pn_async(self.callback)
Expand All @@ -159,7 +159,7 @@ def test_missing_message(self):
assert "Message missing" in str(self.status.error_data.exception)

def test_missing_chanel(self):
PubNub(pnconf).publish() \
PubNub(pnconf_env_copy()).publish() \
.channel("") \
.message("hey") \
.pn_async(self.callback)
Expand All @@ -172,7 +172,7 @@ def test_non_serializable(self):
def method():
pass

PubNub(pnconf).publish() \
PubNub(pnconf_env_copy()).publish() \
.channel("ch1") \
.message(method) \
.pn_async(self.callback)
Expand All @@ -184,7 +184,7 @@ def method():
assert "not JSON serializable" in str(self.status.error_data.exception)

def test_not_permitted(self):
pnconf = pnconf_pam_copy()
pnconf = pnconf_pam_env_copy()
pnconf.secret_key = None

PubNub(pnconf).publish()\
Expand Down
13 changes: 8 additions & 5 deletions tests/integrational/native_threads/test_subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pubnub.models.consumer.pubsub import PNPublishResult, PNMessageResult
from pubnub.pubnub import PubNub, SubscribeListener, NonSubscribeListener
from tests import helper
from tests.helper import pnconf_sub_copy
from tests.helper import pnconf_sub_copy, pnconf_env_copy
from tests.integrational.vcr_helper import pn_vcr


Expand Down Expand Up @@ -50,8 +50,10 @@ def test_subscribe_unsubscribe(self):
pubnub.stop()

def test_subscribe_pub_unsubscribe(self):
conf = pnconf_env_copy()
conf.enable_subscribe = True
ch = helper.gen_channel("test-subscribe-sub-pub-unsub")
pubnub = PubNub(pnconf_sub_copy())
pubnub = PubNub(conf)
subscribe_listener = SubscribeListener()
publish_operation = NonSubscribeListener()
message = "hey"
Expand Down Expand Up @@ -87,9 +89,10 @@ def test_subscribe_pub_unsubscribe(self):

def test_join_leave(self):
ch = helper.gen_channel("test-subscribe-join-leave")

pubnub = PubNub(pnconf_sub_copy())
pubnub_listener = PubNub(pnconf_sub_copy())
conf = pnconf_env_copy()
conf.enable_subscribe = True
pubnub = PubNub(conf)
pubnub_listener = PubNub(conf)
callback_messages = SubscribeListener()
callback_presence = SubscribeListener()

Expand Down