Beispiel #1
0
    def setUp(self):
        # Summary: 6 users + 1 admin, 2 chats
        # User #7 is Sigma admin
        # User #1 is creator of chat #1, User #3 is member of chat #1, User #4 is admin of chat #1, User #5 has been banned from chat #1, User#6 has left chat #1
        # User #2 is creator of chat #2

        super(ChatMemberTests, self).setUpTestData()
        self.users = UserFactory.create_batch(7) + [AdminUserFactory()]
        self.chats = ChatFactory.create_batch(2)
        self.chatmembers = [
            ChatMemberFactory(is_creator=True, is_admin=True, chat=self.chats[0], user=self.users[0]),
            ChatMemberFactory(is_creator=True, is_admin=True, chat=self.chats[1], user=self.users[1]),
            ChatMemberFactory(is_creator=False, is_admin=False, chat=self.chats[0], user=self.users[2]),
            ChatMemberFactory(is_creator=False, is_admin=True, chat=self.chats[0], user=self.users[3]),
            ChatMemberFactory(is_creator=False, is_admin=False, is_member=False, is_banned=True, chat=self.chats[0], user=self.users[4]),
            ChatMemberFactory(is_creator=False, is_admin=False, is_member=False, chat=self.chats[0], user=self.users[5])
        ]

        self.chatmembers_url = "/chatmember/"
        self.chatmember_url = self.chatmembers_url + "%d/"
        self.create_chatmember_url = "/chat/{0}/add_member/"
        self.change_role_chatmember_url = "/chat/{0}/change_role/"

        self.new_chatmember_data = {"user": self.users[0].id, "chat": self.chats[1].id, "is_creator": False, "is_admin": False}
        self.new_chatmember_data_right_way = {"user_id": self.users[0].id}

        self.new_chatmember_data = {"user": self.users[0].id, "chat": self.chats[1].id, "is_creator": False, "is_admin": False}
        self.new_chatmember_data_right_way = {"user_id": self.users[0].id}
Beispiel #2
0
    def setUp(self):
        # Summary: 4 users + 1 admin, 2 chats
        # User #5 is Sigma admin
        # User #1 is creator of and sent 1 message to chat #1, User #3 is member of, and sent 1 message to chat#1
        # User #2 is creator of, and sent 1 message to chat #2, User #1 is member of, and sent 1 message to chat #2

        super(MessageTests, self).setUp()
        self.users = UserFactory.create_batch(4) + [AdminUserFactory()]
        self.chats = ChatFactory.create_batch(2)
        self.chatmembers = [
            ChatMemberFactory(is_creator=True, is_admin=True, chat=self.chats[0], user=self.users[0]),
            ChatMemberFactory(is_creator=False, is_admin=False, chat=self.chats[1], user=self.users[0]),
            ChatMemberFactory(is_creator=True, is_admin=True, chat=self.chats[1], user=self.users[1]),
            ChatMemberFactory(is_creator=False, is_admin=False, chat=self.chats[0], user=self.users[2]),
        ]
        self.messages = [
            MessageFactory(chat_id=self.chats[0], chatmember_id=self.chatmembers[0]),
            MessageFactory(chat_id=self.chats[1], chatmember_id=self.chatmembers[1]),
            MessageFactory(chat_id=self.chats[1], chatmember_id=self.chatmembers[2]),
            MessageFactory(chat_id=self.chats[0], chatmember_id=self.chatmembers[3]),
        ]

        self.messages_url = "/message/"
        self.message_url = self.messages_url + "%d/"
        self.create_message_url = "/chatmember/{0}/send_message/"

        f = SimpleUploadedFile("file.txt", b"file_content")
        self.new_message_data = {
            "chatmember_id": self.chatmembers[0].id,
            "chat_id": self.chats[0].id,
            "text": "text",
            "attachment": f,
        }
        self.new_message_data_right_way = {"text": "text", "attachment": f}
Beispiel #3
0
    def setUpTestData(self):
        # Summary: 4 users + 1 admin, 1 chat
        # User #5 is Sigma admin
        # User #1 is in chat

        super(ChatTests, self).setUpTestData()
        self.users = UserFactory.create_batch(3) + [AdminUserFactory()]
        self.chats = ChatFactory.create_batch(1)
        self.chatmember = ChatMemberFactory(is_creator=True, is_admin=True, chat=self.chats[0], user=self.users[0])

        self.chats_url = "/chat/"
        self.chat_url = self.chats_url + "%d/"

        self.new_chat_data = {"name": "New chat"}
        self.add_member_data = {"user_id": self.users[0].id}