1212from intercom .client import Client
1313from intercom .user import User
1414from intercom import MultipleMatchingUsersError
15- from intercom .utils import create_class_instance
15+ from intercom .utils import define_lightweight_class
1616from mock import patch
1717from nose .tools import assert_raises
1818from nose .tools import eq_
@@ -69,17 +69,17 @@ def it_presents_a_complete_user_record_correctly(self):
6969 eq_ (1393613864 , calendar .timegm (user .remote_created_at .utctimetuple ()))
7070 eq_ (1401970114 , calendar .timegm (user .updated_at .utctimetuple ()))
7171
72- Avatar = create_class_instance ( 'Avatar' ) # noqa
73- Company = create_class_instance ( 'Company' ) # noqa
74- SocialProfile = create_class_instance ( 'SocialProfile' ) # noqa
75- LocationData = create_class_instance ( 'LocationData' ) # noqa
76- self .assertIsInstance (user .avatar , Avatar .__class__ )
72+ Avatar = define_lightweight_class ( 'avatar' , 'Avatar' ) # noqa
73+ Company = define_lightweight_class ( 'company' , 'Company' ) # noqa
74+ SocialProfile = define_lightweight_class ( 'social_profile' , 'SocialProfile' ) # noqa
75+ LocationData = define_lightweight_class ( 'locaion_data' , 'LocationData' ) # noqa
76+ self .assertIsInstance (user .avatar . __class__ , Avatar .__class__ )
7777 img_url = 'https://graph.facebook.com/1/picture?width=24&height=24'
7878 eq_ (img_url , user .avatar .image_url )
7979
8080 self .assertIsInstance (user .companies , list )
8181 eq_ (1 , len (user .companies ))
82- self .assertIsInstance (user .companies [0 ], Company .__class__ )
82+ self .assertIsInstance (user .companies [0 ]. __class__ , Company .__class__ )
8383 eq_ ('123' , user .companies [0 ].company_id )
8484 eq_ ('bbbbbbbbbbbbbbbbbbbbbbbb' , user .companies [0 ].id )
8585 eq_ ('the-app-id' , user .companies [0 ].app_id )
@@ -103,12 +103,12 @@ def it_presents_a_complete_user_record_correctly(self):
103103
104104 eq_ (4 , len (user .social_profiles ))
105105 twitter_account = user .social_profiles [0 ]
106- self .assertIsInstance (twitter_account , SocialProfile .__class__ )
106+ self .assertIsInstance (twitter_account . __class__ , SocialProfile .__class__ )
107107 eq_ ('twitter' , twitter_account .name )
108108 eq_ ('abc' , twitter_account .username )
109109 eq_ ('http://twitter.com/abc' , twitter_account .url )
110110
111- self .assertIsInstance (user .location_data , LocationData .__class__ )
111+ self .assertIsInstance (user .location_data . __class__ , LocationData .__class__ )
112112 eq_ ('Dublin' , user .location_data .city_name )
113113 eq_ ('EU' , user .location_data .continent_code )
114114 eq_ ('Ireland' , user .location_data .country_name )
@@ -182,7 +182,7 @@ def it_fetches_a_user(self):
182182
183183 @istest
184184 def it_gets_users_by_tag (self ):
185- with patch .object (Client , 'get' , return_value = page_of_users (False )) as mock_method :
185+ with patch .object (Client , 'get' , return_value = page_of_users (False )):
186186 users = self .client .users .by_tag (124 )
187187 for user in users :
188188 ok_ (hasattr (user , 'avatar' ))
0 commit comments