old_contents: from django.test import TestCase
  from corehq.apps.users.models import WebUser, CommCareUser
  from corehq.apps.users.dbaccessors.all_commcare_users import get_all_commcare_users_by_domain
  from corehq.apps.domain.models import Domain
  
  
  class AllCommCareUsersTest(TestCase):
      def setUpClass(cls):
          cls.ccdomain = Domain(name='cc_user_domain')
          cls.ccdomain.save()
          cls.other_domain = Domain(name='other_domain')
          cls.other_domain.save()
  
          cls.ccuser_1 = CommCareUser.create(
              domain=cls.ccdomain.name,
              username='ccuser_1',
              password='secret',
              email='email@example.com',
          )
          cls.ccuser_2 = CommCareUser.create(
              domain=cls.ccdomain.name,
              username='ccuser_2',
              password='secret',
              email='email1@example.com',
          )
          cls.web_user = WebUser.create(
              domain=cls.ccdomain.name,
              username='webuser',
              password='secret',
              email='webuser@example.com',
          )
          cls.ccuser_other_domain = CommCareUser.create(
              domain=cls.other_domain.name,
              username='cc_user_other_domain',
              password='secret',
              email='email_other_domain@example.com',
          )
  
      def tearDownClass(cls):
          cls.ccdomain.delete()
          cls.other_domain.delete()
          cls.web_user.delete()
  
      def test_get_all_commcare_users_by_domain(self):
          expected_users = [self.ccuser_2, self.ccuser_1]
          expected_usernames = [user.username for user in expected_users]
          actual_usernames = [user.username for user in get_all_commcare_users_by_domain(self.ccdomain.name)]
          self.assertItemsEqual(actual_usernames, expected_usernames)
  
new_contents: from django.test import TestCase
  from corehq.apps.users.models import WebUser, CommCareUser
  from corehq.apps.users.dbaccessors.all_commcare_users import (
      get_all_commcare_users_by_domain,
      get_user_docs_by_username
  )
  from corehq.apps.domain.models import Domain
  
  
  class AllCommCareUsersTest(TestCase):
      def setUpClass(cls):
          cls.ccdomain = Domain(name='cc_user_domain')
          cls.ccdomain.save()
          cls.other_domain = Domain(name='other_domain')
          cls.other_domain.save()
  
          cls.ccuser_1 = CommCareUser.create(
              domain=cls.ccdomain.name,
              username='ccuser_1',
              password='secret',
              email='email@example.com',
          )
          cls.ccuser_2 = CommCareUser.create(
              domain=cls.ccdomain.name,
              username='ccuser_2',
              password='secret',
              email='email1@example.com',
          )
          cls.web_user = WebUser.create(
              domain=cls.ccdomain.name,
              username='webuser',
              password='secret',
              email='webuser@example.com',
          )
          cls.ccuser_other_domain = CommCareUser.create(
              domain=cls.other_domain.name,
              username='cc_user_other_domain',
              password='secret',
              email='email_other_domain@example.com',
          )
  
      def tearDownClass(cls):
          cls.ccdomain.delete()
          cls.other_domain.delete()
          cls.web_user.delete()
  
      def test_get_all_commcare_users_by_domain(self):
          expected_users = [self.ccuser_2, self.ccuser_1]
          expected_usernames = [user.username for user in expected_users]
          actual_usernames = [user.username for user in get_all_commcare_users_by_domain(self.ccdomain.name)]
          self.assertItemsEqual(actual_usernames, expected_usernames)
  
      def test_get_user_docs_by_username(self):
          users = [self.ccuser_1, self.web_user, self.ccuser_other_domain]
          usernames = [u.username for u in users] + ['nonexistant@username.com']
          self.assertItemsEqual(
              get_user_docs_by_username(usernames),
              [u.to_json() for u in users]
          )
  
subject: Add test for get_user_docs_by_username