1919from intercom import Impression
2020from intercom import Note
2121from nose .tools import nottest
22- from sure import expect
22+ from nose .tools import eq_
23+ from nose .tools import ok_
24+ from nose .tools import raises
2325
2426Intercom .app_id = 'dummy-app-id'
2527Intercom .api_key = 'dummy-secret-key'
@@ -37,47 +39,56 @@ def fixture(fixture):
3739@httpretty .activate
3840def test_users ():
3941 httpretty .register_uri (get , r (r"/v1/users" ), body = fixture ('v1-users' ))
40- expect (len (User .all ())). should . be . greater_than ( 0 )
42+ ok_ (len (User .all ()) > 0 )
4143
4244@httpretty .activate
4345def test_user ():
4446 httpretty .register_uri (get , r (r"/v1/users\?email=" ), body = fixture ('v1-user' ), match_querystring = True )
4547 user = User .find (email = 'somebody@example.com' )
46- expect (user .name ). to . equal ( 'Somebody' )
48+ eq_ (user .name , 'Somebody' )
4749
4850 httpretty .register_uri (get , r (r"/v1/users\?user_id=" ), body = fixture ('v1-user' ), match_querystring = True )
4951 user = User .find_by_user_id ('123' )
50- expect (user .name ). to . equal ( 'Somebody' )
52+ eq_ (user .name , 'Somebody' )
5153
5254@httpretty .activate
55+ @raises (ResourceNotFound )
5356def test_not_found ():
5457 httpretty .register_uri (get , r (r"/v1/users\?email=not-found" ), status = 404 , match_querystring = True )
55- User .find . when . called_with (email = 'not-found@example.com' ). should . throw ( ResourceNotFound )
58+ User .find (email = 'not-found@example.com' )
5659
60+ @httpretty .activate
61+ @raises (ResourceNotFound )
62+ def test_not_found_qs ():
5763 httpretty .register_uri (get , r (r"/v1/users\?email=not-found" ), body = fixture ('v1-user_not_found' ), status = 404 , match_querystring = True )
58- User .find . when . called_with (email = 'not-found@example.com' ). should . throw ( ResourceNotFound )
64+ User .find (email = 'not-found@example.com' )
5965
6066@httpretty .activate
67+ @raises (ServerError )
6168def test_server_error ():
6269 httpretty .register_uri (get , r (r"/v1/users\?email=server-error" ), status = 500 , match_querystring = True )
63- User .find . when . called_with (email = 'server-error@example.com' ). should . throw ( ServerError )
70+ User .find (email = 'server-error@example.com' )
6471
72+ @httpretty .activate
73+ @raises (ServerError )
74+ def test_server_error_qs ():
6575 httpretty .register_uri (get , r (r"/v1/users\?email=server-error" ), body = fixture ('v1-user_server_error' ), status = 500 , match_querystring = True )
66- User .find . when . called_with (email = 'server-error@example.com' ). should . throw ( ServerError )
76+ User .find (email = 'server-error@example.com' )
6777
6878@httpretty .activate
79+ @raises (AuthenticationError )
6980def test_bad_api_key ():
7081 httpretty .register_uri (get , r (r"/v1/users\?email=authentication-error" ), status = 401 , match_querystring = True )
7182 Intercom .app_id = 'bad-app-id'
7283 Intercom .api_key = 'bad-secret-key'
73- User .find . when . called_with (email = 'authentication-error@example.com' ). should . throw ( AuthenticationError )
84+ User .find (email = 'authentication-error@example.com' )
7485
7586@httpretty .activate
7687def test_message_threads ():
7788 httpretty .register_uri (get , r (r"/v1/users/message_threads\?email=somebody" ), body = fixture ('v1-users-message_threads' ), match_querystring = True )
7889 thread = MessageThread .find_all (email = 'somebody@example.com' )[0 ]
7990 for attr in ['thread_id' , 'read' , 'messages' , 'created_at' , 'updated_at' ]:
80- expect (getattr (thread , attr )). should . be . ok
91+ ok_ (getattr (thread , attr ))
8192
8293@nottest
8394@httpretty .activate
@@ -91,15 +102,15 @@ def test_message_thread():
91102def test_impression ():
92103 httpretty .register_uri (post , r (r"/v1/users/impressions" ), body = fixture ('v1-users-impressions' ))
93104 impression = Impression .create (email = 'somebody@example.com' )
94- expect (impression .unread_messages ). should . be . greater_than ( 0 )
95- # expect (impression.email).to.equal( 'somebody@example.com')
105+ ok_ (impression .unread_messages > 0 )
106+ # eq_ (impression.email, 'somebody@example.com')
96107
97108@httpretty .activate
98109def test_note ():
99110 httpretty .register_uri (post , r (r"/v1/users/notes" ), body = fixture ('v1-users-note' ))
100111 note = Note .create (body = "This is a note" , email = 'somebody@example.com' )
101- expect (note .html ). to . equal ( "<p>This is a note</p>" )
102- expect (note .user .email ). to . equal ( "somebody@example.com" )
112+ eq_ (note .html , "<p>This is a note</p>" )
113+ eq_ (note .user .email , "somebody@example.com" )
103114
104115@nottest
105116@httpretty .activate
@@ -108,7 +119,7 @@ def test_endpoints():
108119 httpretty .register_uri (get , r (r"/v1/users\?email=" ), body = fixture ('v1-user' ), match_querystring = True )
109120 Intercom .endpoints = ("http://127.0.0.7" , "https://api.intercom.io" )
110121 user = User .find (email = 'somebody@example.com' )
111- expect (user .name ). to . equal ( 'Somebody' )
122+ eq_ (user .name , 'Somebody' )
112123
113124@nottest
114125@httpretty .activate
@@ -170,19 +181,19 @@ def request_callback(method, uri, headers):
170181 httpretty .register_uri (post , r (r"/v1/users/impressions" ), body = fixture ('v1-users-impressions' ))
171182
172183 (failure_count , test_count ) = doctest .testfile ("../../intercom/user.py" )
173- expect (failure_count ). to . equal ( 0 )
184+ eq_ (failure_count , 0 )
174185
175186 (failure_count , test_count ) = doctest .testfile ("../../intercom/tag.py" )
176- expect (failure_count ). to . equal ( 0 )
187+ eq_ (failure_count , 0 )
177188
178189 (failure_count , test_count ) = doctest .testfile ("../../intercom/note.py" )
179- expect (failure_count ). to . equal ( 0 )
190+ eq_ (failure_count , 0 )
180191
181192 (failure_count , test_count ) = doctest .testfile ("../../intercom/message_thread.py" )
182- expect (failure_count ). to . equal ( 0 )
193+ eq_ (failure_count , 0 )
183194
184195 (failure_count , test_count ) = doctest .testfile ("../../intercom/impression.py" )
185- expect (failure_count ). to . equal ( 0 )
196+ eq_ (failure_count , 0 )
186197
187198 (failure_count , test_count ) = doctest .testfile ("../../intercom/intercom.py" )
188- expect (failure_count ). to . equal ( 0 )
199+ eq_ (failure_count , 0 )
0 commit comments