Skip to content

Commit 142b382

Browse files
committed
added testing on exception mapping, missing field isnt working well
1 parent cb00212 commit 142b382

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎stream/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def connect(api_key, api_secret):
2525
2626
- pk_gt and pk_gte seems to have the same output (pk_gt doesnt always work)
2727
- follow sometimes breaks
28+
- missing field exceptions are raised in an inconsistent way to other errors
2829
2930
- test coverage
3031
- read the docs

‎stream/exceptions.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __unicode__(self):
1616
return '%s (%s)' % (self.__class__.__name__, self.detail)
1717

1818

19-
class KeyException(StreamApiException):
19+
class ApiKeyException(StreamApiException):
2020

2121
'''
2222
Raised when there is an issue with your Access Key

‎stream/tests.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from unittest2.case import TestCase
22
import stream
33
import time
4+
from stream.exceptions import ApiKeyException
45

56

67
class ClientTest(TestCase):
@@ -90,3 +91,19 @@ def test_get(self):
9091
# try pk_lt based
9192
self.user1.get(limit=2, pk_lt=activity_id_two)['results']
9293
self.assertEqual(activities[0]['id'], activity_id)
94+
95+
def test_api_key_exception(self):
96+
self.c = stream.connect(
97+
'5crf3bhfzesnMISSING',
98+
'tfq2sdqpj9g446sbv653x3aqmgn33hsn8uzdc9jpskaw8mj6vsnhzswuwptuj9su'
99+
)
100+
self.user1 = self.c.feed('user:1')
101+
activity_data = {'actor': 1, 'verb': 'tweet', 'object': 1, 'debug_example_undefined': 'test'}
102+
self.assertRaises(ApiKeyException, lambda: self.user1.add_activity(activity_data))
103+
104+
105+
def test_missing_field_exception(self):
106+
activity_data = {'actor': 1, 'verb': 'tweet', 'object': 1, 'debug_example_undefined': 'test'}
107+
response = self.user1.add_activity(activity_data)
108+
print response
109+
print 'hi'

0 commit comments

Comments
 (0)