forked from zendesk/connect_python_sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
41 lines (33 loc) · 1.5 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import unittest
import outbound
api_key = "testapikey"
first_run = True
class AnalyticsBasicTests(unittest.TestCase):
def setUp(self):
global first_run
if first_run:
first_run = False
def on_error(code, err):
self.assertEqual(outbound.ERROR_INIT, code, "Expected init() error.")
outbound.identify(1, on_error=on_error)
outbound.init(api_key)
def test_identify(self):
def on_error(code, err):
self.assertEqual(outbound.ERROR_USER_ID, code, "Expected user ID error.")
outbound.identify(None, on_error=on_error)
def test_track(self):
def user_id_on_error(code, err):
self.assertEqual(outbound.ERROR_USER_ID, code, "Expected user ID error.")
def event_on_error(code, err):
self.assertEqual(outbound.ERROR_EVENT_NAME, code, "Expected event name error.")
outbound.track(None, "event", on_error=user_id_on_error)
outbound.track(1, None, on_error=event_on_error)
def test_register_token(self):
def user_id_on_error(code, err):
self.assertEqual(outbound.ERROR_USER_ID, code, "Expected user ID error.")
def token_on_error(code, err):
self.assertEqual(outbound.ERROR_TOKEN, code, "Expected token error.")
outbound.register_token(outbound.APNS, [1,2], "token", on_error=user_id_on_error)
outbound.register_token(outbound.APNS, 1, None, on_error=token_on_error)
if __name__ == '__main__':
unittest.main()