Skip to content

Commit 67a857e

Browse files
committed
Checking for Company before dict in setter (as Company is a dict subclass).
1 parent a498f97 commit 67a857e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

intercom/user.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@ def company(self, company):
317317
>>> user.company = {'id':6, 'name': 'Intercom', 'created_at': 103201}
318318
319319
"""
320-
if isinstance(company, dict):
321-
self['companies'] = [Company(**company)]
322-
elif isinstance(company, Company):
320+
if isinstance(company, Company):
323321
self['companies'] = [company]
322+
elif isinstance(company, dict):
323+
self['companies'] = [Company(**company)]
324324
else:
325325
raise ValueError("company must be set as a dict or Company object")
326326

tests/unit/test_user.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ def test_company_properties():
162162
@raises(ValueError)
163163
def test_user_company():
164164
user = User()
165+
# use a Company object
166+
user.company = Company({
167+
'id': 1,
168+
'name': 'Intercom',
169+
'created_at': datetime.fromtimestamp(1331764344)
170+
})
171+
165172
# use a dict object
166173
user.company = {
167174
'id': 1,

0 commit comments

Comments
 (0)