Ejemplo n.º 1
0
    def test_pm(self):
        room = Chatroom("../config/test_config/chat.yaml")
        sender = Mwsc()
        reciever = Mwsc()
        bystander = Mwsc()

        test_helper.sync(room.handle_connection(sender, "sender"))
        test_helper.sync(room.handle_connection(reciever, "reciever"))
        test_helper.sync(room.handle_connection(bystander, "bystander"))

        test_helper.sync(
            room.command_handler.handle_command("!pm reciever MESSAGE BODY", room.connected[sender], room)
        )

        expected_reciver = room.get_outgoing_pm("MESSAGE BODY", "sender")
        expected_sender = room.get_pm_receipt("MESSAGE BODY", "reciever")

        self.assertIn(expected_reciver, reciever.incoming[-1])
        self.assertIn("PRIVATE", reciever.incoming[-1])

        self.assertIn(expected_sender, sender.incoming[-1])
        self.assertIn("PRIVATE", sender.incoming[-1])

        self.assertNotIn(expected_sender, bystander.incoming[-1])
        self.assertNotIn("PRIVATE", bystander.incoming[-1])
Ejemplo n.º 2
0
    def test_bad_pm(self):

        room = Chatroom("../config/test_config/chat.yaml")
        sender = Mwsc()
        reciever = Mwsc()

        test_helper.sync(room.handle_connection(sender, "sender"))
        test_helper.sync(room.handle_connection(reciever, "reciever"))

        test_helper.sync(
            room.command_handler.handle_command("!pm", room.connected[sender], room)
        )

        test_helper.sync(
            room.command_handler.handle_command("!pm test", room.connected[sender], room)
        )

        test_helper.sync(
            room.command_handler.handle_command("!pm test ", room.connected[sender], room)
        )