From 80edcffbfe140a6d19c65deca24e1ba1c0f49b99 Mon Sep 17 00:00:00 2001 From: Devendra Date: Mon, 24 Mar 2014 19:17:48 +0530 Subject: support for python3 --- python/tests/unit-test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'python/tests/unit-test.py') diff --git a/python/tests/unit-test.py b/python/tests/unit-test.py index 1737ace..762959e 100755 --- a/python/tests/unit-test.py +++ b/python/tests/unit-test.py @@ -53,8 +53,9 @@ history = pubnub.history({ 'channel' : crazy, 'limit' : 1 }) + test( - history[0].encode('utf-8') == crazy, + history[0] == crazy, 'History Message: ' + history[0] ) test( len(history) == 1, 'History Message Count' ) -- cgit v1.2.3 From 09cd0c015ae276aa849297a6a976065b2b3f247b Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 23 Apr 2014 14:03:13 +0530 Subject: modifying code for pep 8 compliance --- python/tests/unit-test.py | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'python/tests/unit-test.py') diff --git a/python/tests/unit-test.py b/python/tests/unit-test.py index 762959e..fd1bb97 100755 --- a/python/tests/unit-test.py +++ b/python/tests/unit-test.py @@ -1,4 +1,4 @@ -## www.pubnub.com - PubNub Real-time push service in the cloud. +## www.pubnub.com - PubNub Real-time push service in the cloud. # coding=utf8 ## PubNub Real-time Push APIs and Notifications Framework @@ -15,53 +15,55 @@ sys.path.append('..') sys.path.append('../common') from Pubnub import Pubnub -publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo' +publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo' subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'demo' -secret_key = len(sys.argv) > 3 and sys.argv[3] or None -ssl_on = len(sys.argv) > 4 and bool(sys.argv[4]) or False +secret_key = len(sys.argv) > 3 and sys.argv[3] or None +ssl_on = len(sys.argv) > 4 and bool(sys.argv[4]) or False ## ----------------------------------------------------------------------- ## Initiat Class ## ----------------------------------------------------------------------- -pubnub = Pubnub( publish_key, subscribe_key, secret_key, ssl_on ) -crazy = 'demo' +pubnub = Pubnub(publish_key, subscribe_key, secret_key, ssl_on) +crazy = 'demo' ## --------------------------------------------------------------------------- ## Unit Test Function ## --------------------------------------------------------------------------- -def test( trial, name ) : - if trial : - print( 'PASS: ' + name ) - else : - print( 'FAIL: ' + name ) + + +def test(trial, name): + if trial: + print('PASS: ' + name) + else: + print('FAIL: ' + name) ## ----------------------------------------------------------------------- ## Publish Example ## ----------------------------------------------------------------------- publish_success = pubnub.publish({ - 'channel' : crazy, - 'message' : crazy + 'channel': crazy, + 'message': crazy }) -test( publish_success[0] == 1, 'Publish First Message Success' ) +test(publish_success[0] == 1, 'Publish First Message Success') ## ----------------------------------------------------------------------- ## History Example ## ----------------------------------------------------------------------- history = pubnub.history({ - 'channel' : crazy, - 'limit' : 1 + 'channel': crazy, + 'limit': 1 }) test( history[0] == crazy, 'History Message: ' + history[0] ) -test( len(history) == 1, 'History Message Count' ) +test(len(history) == 1, 'History Message Count') ## ----------------------------------------------------------------------- ## PubNub Server Time Example ## ----------------------------------------------------------------------- timestamp = pubnub.time() -test( timestamp > 0, 'PubNub Server Time: ' + str(timestamp) ) +test(timestamp > 0, 'PubNub Server Time: ' + str(timestamp)) -- cgit v1.2.3 From 93379625e26c98a8cfab72c106ae40819843f956 Mon Sep 17 00:00:00 2001 From: Devendra Date: Thu, 24 Apr 2014 00:35:10 +0530 Subject: remove relative imports --- python/tests/unit-test.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'python/tests/unit-test.py') diff --git a/python/tests/unit-test.py b/python/tests/unit-test.py index fd1bb97..a9a462c 100755 --- a/python/tests/unit-test.py +++ b/python/tests/unit-test.py @@ -10,9 +10,6 @@ ## ----------------------------------- import sys -sys.path.append('.') -sys.path.append('..') -sys.path.append('../common') from Pubnub import Pubnub publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo' -- cgit v1.2.3 From c98286f500b77dcf426367df0b688f536b77ea9b Mon Sep 17 00:00:00 2001 From: Devendra Date: Thu, 24 Apr 2014 01:33:45 +0530 Subject: fixing imports --- python/tests/unit-test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python/tests/unit-test.py') diff --git a/python/tests/unit-test.py b/python/tests/unit-test.py index a9a462c..a48cbd3 100755 --- a/python/tests/unit-test.py +++ b/python/tests/unit-test.py @@ -10,7 +10,7 @@ ## ----------------------------------- import sys -from Pubnub import Pubnub +from Pubnub import PubnubAsync as Pubnub publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo' subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'demo' -- cgit v1.2.3 From 32492b68b66a46bdbf6736e1ddd16a34dca12b9b Mon Sep 17 00:00:00 2001 From: Devendra Date: Thu, 15 May 2014 19:48:06 +0530 Subject: adding more unit tests --- python/tests/unit-test.py | 66 ----------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100755 python/tests/unit-test.py (limited to 'python/tests/unit-test.py') diff --git a/python/tests/unit-test.py b/python/tests/unit-test.py deleted file mode 100755 index a48cbd3..0000000 --- a/python/tests/unit-test.py +++ /dev/null @@ -1,66 +0,0 @@ -## www.pubnub.com - PubNub Real-time push service in the cloud. -# coding=utf8 - -## PubNub Real-time Push APIs and Notifications Framework -## Copyright (c) 2010 Stephen Blum -## http://www.pubnub.com/ - -## ----------------------------------- -## PubNub 3.0 Real-time Push Cloud API -## ----------------------------------- - -import sys -from Pubnub import PubnubAsync as Pubnub - -publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo' -subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'demo' -secret_key = len(sys.argv) > 3 and sys.argv[3] or None -ssl_on = len(sys.argv) > 4 and bool(sys.argv[4]) or False - - -## ----------------------------------------------------------------------- -## Initiat Class -## ----------------------------------------------------------------------- - -pubnub = Pubnub(publish_key, subscribe_key, secret_key, ssl_on) -crazy = 'demo' - -## --------------------------------------------------------------------------- -## Unit Test Function -## --------------------------------------------------------------------------- - - -def test(trial, name): - if trial: - print('PASS: ' + name) - else: - print('FAIL: ' + name) - -## ----------------------------------------------------------------------- -## Publish Example -## ----------------------------------------------------------------------- -publish_success = pubnub.publish({ - 'channel': crazy, - 'message': crazy -}) -test(publish_success[0] == 1, 'Publish First Message Success') - -## ----------------------------------------------------------------------- -## History Example -## ----------------------------------------------------------------------- -history = pubnub.history({ - 'channel': crazy, - 'limit': 1 -}) - -test( - history[0] == crazy, - 'History Message: ' + history[0] -) -test(len(history) == 1, 'History Message Count') - -## ----------------------------------------------------------------------- -## PubNub Server Time Example -## ----------------------------------------------------------------------- -timestamp = pubnub.time() -test(timestamp > 0, 'PubNub Server Time: ' + str(timestamp)) -- cgit v1.2.3