users: Improve testing for user_ids_to_users.

This commit is contained in:
Tim Abbott
2018-04-04 16:31:30 -07:00
parent 4d2082ab14
commit c06565d909
2 changed files with 4 additions and 2 deletions

View File

@@ -109,7 +109,7 @@ def user_ids_to_users(user_ids: List[int], realm: Realm) -> List[UserProfile]:
# users should be included.
def fetch_users_by_id(user_ids: List[int]) -> List[UserProfile]:
if not user_ids:
if len(user_ids) == 0:
return []
return list(UserProfile.objects.filter(id__in=user_ids).select_related())

View File

@@ -286,7 +286,9 @@ class UserProfileTest(ZulipTestCase):
self.example_user('cordelia').id,
]
user_ids_to_users(real_user_ids, get_realm("zulip"))
self.assertEqual(user_ids_to_users([], get_realm("zulip")), [])
self.assertEqual(set([user_profile.id for user_profile in user_ids_to_users(real_user_ids, get_realm("zulip"))]),
set(real_user_ids))
with self.assertRaises(JsonableError):
user_ids_to_users([1234], get_realm("zephyr"))
with self.assertRaises(JsonableError):