def test_basics(self) -> None:
    cordelia = self.example_user('cordelia')
    hamlet = self.example_user('hamlet')
    king_lear = self.lear_user('king')
    realm_id = hamlet.realm_id
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, set())
    client1 = get_client('web')
    client2 = get_client('ZT')
    update_user_status(user_profile_id=hamlet.id, status=UserStatus.AWAY, status_text=None, client_id=client1.id)
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, {hamlet.id})
    update_user_status(user_profile_id=hamlet.id, status=UserStatus.AWAY, status_text='out to lunch', client_id=client2.id)
    self.assertEqual(user_info(hamlet), dict(away=True, status_text='out to lunch'))
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, {hamlet.id})
    rec_count = UserStatus.objects.filter(user_profile_id=hamlet.id).count()
    self.assertEqual(rec_count, 1)
    update_user_status(user_profile_id=hamlet.id, status=UserStatus.NORMAL, status_text=None, client_id=client2.id)
    self.assertEqual(user_info(hamlet), dict(status_text='out to lunch'))
    update_user_status(user_profile_id=hamlet.id, status=None, status_text='', client_id=client2.id)
    self.assertEqual(user_info(hamlet), dict())
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, set())
    update_user_status(user_profile_id=hamlet.id, status=UserStatus.AWAY, status_text=None, client_id=client1.id)
    update_user_status(user_profile_id=cordelia.id, status=UserStatus.AWAY, status_text=None, client_id=client2.id)
    update_user_status(user_profile_id=king_lear.id, status=UserStatus.AWAY, status_text=None, client_id=client2.id)
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, {cordelia.id, hamlet.id})
    away_user_ids = get_away_user_ids(realm_id=king_lear.realm.id)
    self.assertEqual(away_user_ids, {king_lear.id})
    update_user_status(user_profile_id=hamlet.id, status=UserStatus.NORMAL, status_text='in a meeting', client_id=client2.id)
    self.assertEqual(user_info(hamlet), dict(status_text='in a meeting'))
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, {cordelia.id})
def test_basics(self) -> None:
    cordelia = self.example_user('cordelia')
    hamlet = self.example_user('hamlet')
    king_lear = self.lear_user('king')
    realm_id = hamlet.realm_id
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, set())
    client1 = get_client('web')
    client2 = get_client('ZT')
    update_user_status(user_profile_id=hamlet.id, status=UserStatus.AWAY, status_text=None, client_id=client1.id)
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, {hamlet.id})
    update_user_status(user_profile_id=hamlet.id, status=UserStatus.AWAY, status_text='out to lunch', client_id=client2.id)
    self.assertEqual(user_info(hamlet), dict(away=True, status_text='out to lunch'))
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, {hamlet.id})
    rec_count = UserStatus.objects.filter(user_profile_id=hamlet.id).count()
    self.assertEqual(rec_count, 1)
    update_user_status(user_profile_id=hamlet.id, status=UserStatus.NORMAL, status_text=None, client_id=client2.id)
    self.assertEqual(user_info(hamlet), dict(status_text='out to lunch'))
    update_user_status(user_profile_id=hamlet.id, status=None, status_text=, client_id=client2.id)
    self.assertEqual(user_info(hamlet), dict())
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, set())
    update_user_status(user_profile_id=hamlet.id, status=UserStatus.AWAY, status_text=None, client_id=client1.id)
    update_user_status(user_profile_id=cordelia.id, status=UserStatus.AWAY, status_text=None, client_id=client2.id)
    update_user_status(user_profile_id=king_lear.id, status=UserStatus.AWAY, status_text=None, client_id=client2.id)
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, {cordelia.id, hamlet.id})
    away_user_ids = get_away_user_ids(realm_id=king_lear.realm.id)
    self.assertEqual(away_user_ids, {king_lear.id})
    update_user_status(user_profile_id=hamlet.id, status=UserStatus.NORMAL, status_text='in a meeting', client_id=client2.id)
    self.assertEqual(user_info(hamlet), dict(status_text='in a meeting'))
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, {cordelia.id})