Exemplo n.º 1
0
 def test_channel_authentication_data_with_authentication_header_works_properly(
         self):
     input_request = Request(headers=authentication_headers)
     client_request = ClientRequest(input_request)
     self.assertIsInstance(
         client_request.channel_authentication_data(mock, mock),
         ChannelAuthenticationDTO)
Exemplo n.º 2
0
 def test_delete_forbidden_word_data_with_authentication_header_works_properly(
         self):
     input_request = Request(headers=authentication_headers)
     client_request = ClientRequest(input_request)
     self.assertIsInstance(
         client_request.delete_forbidden_word_data(mock, mock),
         DeleteForbiddenWordDTO)
Exemplo n.º 3
0
 def test_delete_user_channel_data_with_authentication_header_works_properly(
         self):
     input_request = Request(headers=authentication_headers)
     client_request = ClientRequest(input_request)
     self.assertIsInstance(
         client_request.delete_user_channel_data(mock, mock, mock),
         DeleteUserChannelDTO)
Exemplo n.º 4
0
def team_user_profile(team_id, user_id):
    logger.info(
        f"Attempting to get user {user_id} profile, from team #{team_id}.")
    req = ClientRequest(request)
    users = TeamService.team_user_profile(
        req.team_user_profile_data(team_id, user_id))
    return jsonify(users.json()), users.status_code()
Exemplo n.º 5
0
 def test_search_users_by_username_with_authentication_header_works_properly(
         self):
     input_request = Request(headers=authentication_headers)
     client_request = ClientRequest(input_request)
     self.assertIsInstance(
         client_request.search_users_by_username_data(mock, mock),
         SearchUsersDTO)
Exemplo n.º 6
0
def delete_channel(team_id, channel_id):
    logger.info(
        f"Attempting to delete channel #{channel_id} from team #{team_id}")
    req = ClientRequest(request)
    old_channel = ChannelService.delete_channel(
        req.channel_authentication_data(team_id, channel_id))
    return jsonify(old_channel.json()), old_channel.status_code()
Exemplo n.º 7
0
 def test_update_channel_data_with_authentication_header_works_properly(
         self):
     body_json = {}
     input_request = Request(body=body_json, headers=authentication_headers)
     client_request = ClientRequest(input_request)
     self.assertIsInstance(client_request.channel_update_data(mock, mock),
                           ChannelUpdateDTO)
Exemplo n.º 8
0
def delete_forbidden_word(team_id, word_id):
    logger.info(
        f"Attempting to delete forbidden word #{word_id} from team #{team_id}."
    )
    req = ClientRequest(request)
    response = TeamService.delete_forbidden_word(
        req.delete_forbidden_word_data(team_id, word_id))
    return jsonify(response.json()), response.status_code()
Exemplo n.º 9
0
def get_preview_messages(team_id):
    logger.info(
        f"Attempting to get all preview messages for user from team #{team_id}."
    )
    req = ClientRequest(request)
    messages = MessageService.get_preview_messages(
        req.team_authentication_data(team_id))
    return jsonify(messages.json()), messages.status_code()
Exemplo n.º 10
0
def get_messages_from_direct_chat(team_id, chat_id):
    logger.info(
        f"Attempting to get all messages from specific chat from user in team #{team_id}."
    )
    req = ClientRequest(request)
    messages = MessageService.get_messages_from_chat(
        req.chat_data(team_id, chat_id))
    return jsonify(messages.json()), messages.status_code()
Exemplo n.º 11
0
def channel_members(team_id, channel_id):
    logger.info(
        f"Attempting to get members from team #{team_id}'s channel #{channel_id}."
    )
    req = ClientRequest(request)
    new_member = ChannelService.channel_members(
        req.channel_authentication_data(team_id, channel_id))
    return jsonify(new_member.json()), new_member.status_code()
Exemplo n.º 12
0
def update_channel_information(team_id, channel_id):
    logger.info(
        f"Attempting to update channel #{channel_id} information from team #{team_id}"
    )
    req = ClientRequest(request)
    updated_channel = ChannelService.update_information(
        req.channel_update_data(team_id, channel_id))
    return jsonify(updated_channel.json()), updated_channel.status_code()
Exemplo n.º 13
0
def remove_member(team_id, channel_id, user_id):
    logger.info(
        f"Attempting to remove member #{user_id} from team #{team_id}'s channel #{channel_id}."
    )
    req = ClientRequest(request)
    new_member = ChannelService.remove_member(
        req.delete_user_channel_data(team_id, channel_id, user_id))
    return jsonify(new_member.json()), new_member.status_code()
Exemplo n.º 14
0
 def test_new_user_data_with_full_data_works_properly(self):
     body_json = {
         "username": "******",
         "password": "******",
         "email": "*****@*****.**"
     }
     input_request = Request(body=body_json)
     client_request = ClientRequest(input_request)
     self.assertIsInstance(client_request.new_user_data(), NewUserDTO)
Exemplo n.º 15
0
 def test_inbox_data_with_full_data_works_properly(self):
     body_json = {
         "team_id": 0,
         "chat_id": 0,
         "content": "test",
         "message_type": "TEXT"
     }
     input_request = Request(body=body_json, headers=authentication_headers)
     client_request = ClientRequest(input_request)
     self.assertIsInstance(client_request.inbox_data(), InboxDTO)
Exemplo n.º 16
0
 def test_regenerate_password_data_without_recovery_token_throws_exception(
         self):
     body_json = {"recover_token": "test"}
     input_request = Request(body=body_json)
     client_request = ClientRequest(input_request)
     self.assertRaises(MissingRequestParameterError,
                       client_request.regenerate_password_data)
Exemplo n.º 17
0
 def test_channel_registration_data_without_channel_id_throws_exception(
         self):
     body_json = {"team_id": 0}
     input_request = Request(body=body_json, headers=authentication_headers)
     client_request = ClientRequest(input_request)
     self.assertRaises(MissingRequestParameterError,
                       client_request.channel_registration_data)
Exemplo n.º 18
0
 def test_inbox_data_without_chat_id_throws_exception(self):
     body_json = {
         "team_id": 0,
         "content": "test",
         "message_type": "UNKNOWN"
     }
     input_request = Request(body=body_json, headers=authentication_headers)
     client_request = ClientRequest(input_request)
     self.assertRaises(MissingRequestParameterError,
                       client_request.inbox_data)
Exemplo n.º 19
0
 def test_inbox_data_with_unknown_message_type_throws_exception(self):
     body_json = {
         "team_id": 0,
         "chat_id": 0,
         "content": "test",
         "message_type": "UNKNOWN"
     }
     input_request = Request(body=body_json, headers=authentication_headers)
     client_request = ClientRequest(input_request)
     self.assertRaises(MessageTypeNotAvailableError,
                       client_request.inbox_data)
Exemplo n.º 20
0
 def test_secure_actions_without_authentication_token_throws_exception(
         self):
     input_request = Request(EMPTY_DICTIONARY)
     client_request = ClientRequest(input_request)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.user_update_data)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.search_users_by_username_data, None,
                       None)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.team_user_profile_data, None, None)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.authentication_data)
     self.assertRaises(MissingRequestHeaderError, client_request.inbox_data)
     self.assertRaises(MissingRequestHeaderError, client_request.chat_data,
                       None, None)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.new_team_data)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.add_user_team_data)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.team_invite_data)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.accept_team_invite_data)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.change_role_data, None)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.team_authentication_data, None)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.delete_user_team_data, None, None)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.team_update_data, None)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.new_channel_data)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.channel_invitation_data)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.channel_registration_data)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.delete_user_channel_data, None, None,
                       None)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.channel_authentication_data, None,
                       None)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.channel_update_data, None, None)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.add_forbidden_word_data)
     self.assertRaises(MissingRequestHeaderError,
                       client_request.delete_forbidden_word_data, None,
                       None)
Exemplo n.º 21
0
 def test_login_data_with_full_data_works_properly(self):
     body_json_app = {"email": "*****@*****.**", "password": "******"}
     body_json_face = {"facebook_token": "token-test"}
     input_request_app = Request(body=body_json_app)
     input_request_face = Request(body=body_json_face)
     client_request_app = ClientRequest(input_request_app)
     client_request_face = ClientRequest(input_request_face)
     self.assertIsInstance(client_request_app.login_data(), LoginDTO)
     self.assertIsInstance(client_request_face.login_data(), LoginDTO)
Exemplo n.º 22
0
def team_messages():
    logger.info(f"Attempting to get messages stats.")
    req = ClientRequest(request)
    stats = MessageService.messages_stats(req.authentication_data())
    return jsonify(stats.json()), stats.status_code()
Exemplo n.º 23
0
def leave_channel(team_id, channel_id):
    logger.info(f"Attempting to leave channel #{channel_id}")
    req = ClientRequest(request)
    old_member = ChannelService.leave_channel(
        req.channel_authentication_data(team_id, channel_id))
    return jsonify(old_member.json()), old_member.status_code()
Exemplo n.º 24
0
def get_team_bots(team_id):
    logger.info(f"Attempting to get team #{team_id}'s bots.")
    req = ClientRequest(request)
    response = BotService.team_bots(req.team_authentication_data(team_id))
    return jsonify(response.json()), response.status_code()
Exemplo n.º 25
0
def join_channel():
    logger.info(f"Attempting to join team channel.")
    req = ClientRequest(request)
    new_member = ChannelService.join_channel(req.channel_registration_data())
    return jsonify(new_member.json()), new_member.status_code()
Exemplo n.º 26
0
def add_member():
    logger.info(f"Attempting to add new member to team channel.")
    req = ClientRequest(request)
    new_member = ChannelService.add_member(req.channel_invitation_data())
    return jsonify(new_member.json()), new_member.status_code()
Exemplo n.º 27
0
def register_channel():
    logger.info(f"Attempting to register new channel in team.")
    req = ClientRequest(request)
    new_channel = ChannelService.create_channel(req.new_channel_data())
    return jsonify(new_channel.json()), new_channel.status_code()
Exemplo n.º 28
0
def get_all_users():
    logger.info("Attempting to get users stats")
    req = ClientRequest(request)
    response = UserService.get_all_users(req.authentication_data())
    return jsonify(response.json()), response.status_code()
Exemplo n.º 29
0
def send_direct_message():
    logger.info(f"Attempting to send message in team.")
    req = ClientRequest(request)
    response = MessageService.send_message(req.inbox_data())
    return jsonify(response.json()), response.status_code()
Exemplo n.º 30
0
def register_bot():
    logger.info(f"Attempting to register new bot in team.")
    req = ClientRequest(request)
    response = BotService.create_bot(req.new_bot_data())
    return jsonify(response.json()), response.status_code()