Exemplo n.º 1
0
    def setUp(self):
        super().setUp()

        self.server = server.StepmaniaServer()

        self.connection = ConnectionFactory()
        self.token = self.connection.token
Exemplo n.º 2
0
    def setUp(self):
        super().setUp()

        self.server = server.StepmaniaServer()
        self.conn = smconn.StepmaniaConn(self.server, "8.8.8.8", 42)
        self.connection = ConnectionFactory(token=self.conn.token)

        self.controller = StepmaniaController(self.server, self.conn, None,
                                              self.session)
Exemplo n.º 3
0
    def setUp(self):
        super().setUp()

        self.server = server.StepmaniaServer()

        self.connection = ConnectionFactory()
        self.token = self.connection.token

        self.resource = ChatResource(self.server, self.token, self.session)
Exemplo n.º 4
0
    def test_route(self, handle_controller1, handle_controller2):
        """ Test routing packet """

        test_router = router.Router()

        serv = server.StepmaniaServer()
        conn = smconn.StepmaniaConn(server, "8.8.8.8", 42)
        connection = ConnectionFactory(token=conn.token)

        command = smcommand.SMClientCommand.NSCAttack
        packet = smpacket.SMPacket.new(command)

        # No route
        test_router.route(serv, conn, packet)
        handle_controller1.assert_not_called()
        handle_controller2.assert_not_called()

        # Route only controller 1
        test_router.add_route(command, Controller1)
        test_router.route(serv, conn, packet, session=self.session)
        handle_controller1.assert_called_with()
        handle_controller1.reset_mock()
        handle_controller2.assert_not_called()

        # Route with require login
        test_router.add_route(command, Controller2)
        test_router.route(serv, conn, packet, session=self.session)
        handle_controller1.assert_called_with()
        handle_controller1.reset_mock()
        handle_controller2.assert_not_called()

        # Test with login user
        UserFactory(connection_token=connection.token, online=True)

        test_router.route(serv, conn, packet, session=self.session)
        handle_controller1.assert_called_with()
        handle_controller2.assert_called_with()
        handle_controller1.reset_mock()
        handle_controller2.reset_mock()

        # With exceptions, no crash
        handle_controller1.side_effect = Exception()
        test_router.route(serv, conn, packet, session=self.session)
        handle_controller1.assert_called_with()
        handle_controller2.assert_called_with()
        handle_controller1.reset_mock()
        handle_controller2.reset_mock()
Exemplo n.º 5
0
    def setUp(self):
        super().setUp()

        self.server = server.StepmaniaServer()
        self.conn = smconn.StepmaniaConn(self.server, "8.8.8.8", 42)
        self.listener = app.Listener(self.server)
Exemplo n.º 6
0
    def setUp(self):
        super().setUp()

        self.server = server.StepmaniaServer()
        self.worker = chat.ChatWorker(self.server)