diff options
| author | Devendra | 2013-09-25 13:51:19 +0530 |
|---|---|---|
| committer | Devendra | 2013-09-25 13:51:19 +0530 |
| commit | 09d6ea1fa20f87dc648740ffb2a70f67e7e4efa9 (patch) | |
| tree | b1121f01efe49709a85a33f956f1ea572fda4eea /common | |
| parent | 2c77bdb1d0725d7203ce7ce94ec675de750974b0 (diff) | |
| download | pubnub-python-09d6ea1fa20f87dc648740ffb2a70f67e7e4efa9.tar.bz2 | |
combining into Pubnub.py, added common async unit test methodCL-9603
Diffstat (limited to 'common')
| -rw-r--r-- | common/LICENSE_HEADER | 10 | ||||
| -rw-r--r-- | common/PubnubBase.py | 12 | ||||
| -rw-r--r-- | common/PubnubCore.py | 20 | ||||
| -rw-r--r-- | common/PubnubCoreAsync.py | 18 | ||||
| -rw-r--r-- | common/PubnubCrypto.py | 12 | ||||
| -rw-r--r-- | common/PubnubUnitTest.py | 36 |
6 files changed, 46 insertions, 62 deletions
diff --git a/common/LICENSE_HEADER b/common/LICENSE_HEADER new file mode 100644 index 0000000..a83793d --- /dev/null +++ b/common/LICENSE_HEADER @@ -0,0 +1,10 @@ +## 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.3.4 Real-time Push Cloud API +## ----------------------------------- diff --git a/common/PubnubBase.py b/common/PubnubBase.py index 0c4efef..64d43ed 100644 --- a/common/PubnubBase.py +++ b/common/PubnubBase.py @@ -1,14 +1,3 @@ -## 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.3.4 Real-time Push Cloud API -## ----------------------------------- - try: import json except ImportError: import simplejson as json @@ -16,7 +5,6 @@ import time import hashlib import urllib2 import uuid -from PubnubCrypto import PubnubCrypto class PubnubBase(object): def __init__( diff --git a/common/PubnubCore.py b/common/PubnubCore.py index 5965740..9f79dc8 100644 --- a/common/PubnubCore.py +++ b/common/PubnubCore.py @@ -1,23 +1,3 @@ -## 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.3.4 Real-time Push Cloud API -## ----------------------------------- - -try: import json -except ImportError: import simplejson as json - -import time -import hashlib -import urllib2 -import uuid -from PubnubBase import PubnubBase - class PubnubCore(PubnubBase): def __init__( self, diff --git a/common/PubnubCoreAsync.py b/common/PubnubCoreAsync.py index 8150bde..e844b96 100644 --- a/common/PubnubCoreAsync.py +++ b/common/PubnubCoreAsync.py @@ -1,19 +1,3 @@ -## 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.3.4 Real-time Push Cloud API -## ----------------------------------- -import sys -import json -import time -import hashlib -import urllib2 -import uuid try: from hashlib import sha256 digestmod = sha256 @@ -21,8 +5,6 @@ except ImportError: import Crypto.Hash.SHA256 as digestmod sha256 = digestmod.new import hmac -from PubnubCrypto import PubnubCrypto -from PubnubBase import PubnubBase class PubnubCoreAsync(PubnubBase): diff --git a/common/PubnubCrypto.py b/common/PubnubCrypto.py index b91e2d9..df7cb8d 100644 --- a/common/PubnubCrypto.py +++ b/common/PubnubCrypto.py @@ -1,14 +1,3 @@ -## 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.3.4 Real-time Push Cloud API -## ----------------------------------- - from Crypto.Cipher import AES from Crypto.Hash import MD5 from base64 import encodestring, decodestring @@ -90,4 +79,3 @@ class PubnubCrypto() : Initial16bytes='0123456789012345' cipher = AES.new(secret[0:32],AES.MODE_CBC,Initial16bytes) return self.depad((cipher.decrypt(decodestring(msg)))) - diff --git a/common/PubnubUnitTest.py b/common/PubnubUnitTest.py new file mode 100644 index 0000000..2f9d28c --- /dev/null +++ b/common/PubnubUnitTest.py @@ -0,0 +1,36 @@ + +import time + +class Suite(): + def __init__(self, pubnub, expected): + self.pubnub = pubnub + self.total = expected + self.passed = 0 + self.failed = 0 + self.started = False + + def test(self, condition , name, message = None, response = None): + + if condition: + self.passed += 1 + msg = "PASS : " + name + if message: + msg += ", " + message + if response: + msg += ", " + response + print msg + else: + self.failed += 1 + msg = "FAIL : " + name + if message: + msg += ", " + message + if response: + msg += ", " + response + print msg + + if self.total == self.failed + self.passed: + print "\n======== RESULT ========" + print "Total\t:\t", self.total + print "Passed\t:\t", self.passed + print "Failed\t:\t", self.failed + self.pubnub.stop() |
