def test_endpoints(self) -> None:
    hamlet = self.example_user('hamlet')
    realm_id = hamlet.realm_id
    self.login_user(hamlet)
    payload: Dict[(str, Any)] = dict()
    result = self.client_post('/json/users/me/status', payload)
    self.assert_json_error(result, 'Client did not pass any new values.')
    long_text = ('x' * 61)
    payload = dict(status_text=long_text)
    result = self.client_post('/json/users/me/status', payload)
    self.assert_json_error(result, 'status_text is too long (limit: 60 characters)')
    payload = dict(away=orjson.dumps(True).decode(), status_text='on vacation')
    event_info = EventInfo()
    with capture_event(event_info):
        result = self.client_post('/json/users/me/status', payload)
    self.assert_json_success(result)
    self.assertEqual(event_info.payload, dict(type='user_status', user_id=hamlet.id, away=True, status_text='on vacation'))
    self.assertEqual(user_info(hamlet), dict(away=True, status_text='on vacation'))
    payload = dict(away=orjson.dumps(False).decode())
    event_info = EventInfo()
    with capture_event(event_info):
        result = self.client_post('/json/users/me/status', payload)
    self.assert_json_success(result)
    self.assertEqual(event_info.payload, dict(type='user_status', user_id=hamlet.id, away=False))
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, set())
    payload = dict(status_text='   in office  ')
    event_info = EventInfo()
    with capture_event(event_info):
        result = self.client_post('/json/users/me/status', payload)
    self.assert_json_success(result)
    self.assertEqual(event_info.payload, dict(type='user_status', user_id=hamlet.id, status_text='in office'))
    self.assertEqual(user_info(hamlet), dict(status_text='in office'))
    payload = dict(status_text='')
    event_info = EventInfo()
    with capture_event(event_info):
        result = self.client_post('/json/users/me/status', payload)
    self.assert_json_success(result)
    self.assertEqual(event_info.payload, dict(type='user_status', user_id=hamlet.id, status_text=''))
    self.assertEqual(get_user_info_dict(realm_id=realm_id), {})
def test_endpoints(self) -> None:
    hamlet = self.example_user('hamlet')
    realm_id = hamlet.realm_id
    self.login_user(hamlet)
    payload: Dict[(str, Any)] = dict()
    result = self.client_post('/json/users/me/status', payload)
    self.assert_json_error(result, 'Client did not pass any new values.')
    long_text = ('x' * 61)
    payload = dict(status_text=long_text)
    result = self.client_post('/json/users/me/status', payload)
    self.assert_json_error(result, 'status_text is too long (limit: 60 characters)')
    payload = dict(away=orjson.dumps(True).decode(), status_text='on vacation')
    event_info = EventInfo()
    with capture_event(event_info):
        result = self.client_post('/json/users/me/status', payload)
    self.assert_json_success(result)
    self.assertEqual(event_info.payload, dict(type='user_status', user_id=hamlet.id, away=True, status_text='on vacation'))
    self.assertEqual(user_info(hamlet), dict(away=True, status_text='on vacation'))
    payload = dict(away=orjson.dumps(False).decode())
    event_info = EventInfo()
    with capture_event(event_info):
        result = self.client_post('/json/users/me/status', payload)
    self.assert_json_success(result)
    self.assertEqual(event_info.payload, dict(type='user_status', user_id=hamlet.id, away=False))
    away_user_ids = get_away_user_ids(realm_id=realm_id)
    self.assertEqual(away_user_ids, set())
    payload = dict(status_text='   in office  ')
    event_info = EventInfo()
    with capture_event(event_info):
        result = self.client_post('/json/users/me/status', payload)
    self.assert_json_success(result)
    self.assertEqual(event_info.payload, dict(type='user_status', user_id=hamlet.id, status_text='in office'))
    self.assertEqual(user_info(hamlet), dict(status_text='in office'))
    payload = dict(status_text=)
    event_info = EventInfo()
    with capture_event(event_info):
        result = self.client_post('/json/users/me/status', payload)
    self.assert_json_success(result)
    self.assertEqual(event_info.payload, dict(type='user_status', user_id=hamlet.id, status_text=))
    self.assertEqual(get_user_info_dict(realm_id=realm_id), {})