예제 #1
0
    def test_meta(self):

        """Test several client interactions."""

        channels = self.rdb.pubsub(ignore_subscribe_messages=True)

        def _server_booted(msg):
            # We have to unsubscribe from the server-boot-complete event
            # so reloading doesn't loop forever.
            channels.unsubscribe("server-boot-complete")
            # Connect to the server.
            self.client.open(settings.BIND_ADDRESS, settings.BIND_PORT)
            # Create a new account.
            self.client.write(b"c\[email protected]\[email protected]\n")
            self.client.write(b"testaccount\nyes\n")
            self.client.write(b"testpassword\ntestpassword\nno\nyes\n")
            # Create a new character and log into it.
            self.client.write(b"c\ntestchar\nyes\n1\n")
            # Do some stuff.
            self.client.write(b"look\n")
            # Shutdown.
            self.client.write(b"shutdown now\n")

        channels.subscribe(**{"server-boot-complete": _server_booted})
        worker = channels.run_in_thread()
        nanny.start_nanny()
        worker.stop()
        reload(nanny)
예제 #2
0
    def test_main(self):
        """Test that the nanny process runs properly."""

        channels = self.rdb.pubsub(ignore_subscribe_messages=True)

        def _server_booted(msg):
            pid = int(msg["data"])
            self.rdb.publish("server-shutdown", pid)

        channels.subscribe(**{"server-boot-complete": _server_booted})
        worker = channels.run_in_thread()
        nanny.start_nanny()
        worker.stop()
        reload(nanny)
예제 #3
0
    def test_main(self):

        """Test that the nanny process runs properly."""

        channels = self.rdb.pubsub(ignore_subscribe_messages=True)

        def _server_booted(msg):
            pid = int(msg["data"])
            self.rdb.publish("server-shutdown", pid)

        channels.subscribe(**{"server-boot-complete": _server_booted})
        worker = channels.run_in_thread()
        nanny.start_nanny()
        worker.stop()
        reload(nanny)
예제 #4
0
    def test_main_reload(self):
        """Test that the nanny process can handle a reload request."""

        channels = self.rdb.pubsub(ignore_subscribe_messages=True)
        did_reload = False

        def _server_booted(msg):
            nonlocal did_reload
            pid = int(msg["data"])
            if did_reload:
                self.rdb.publish("server-shutdown", pid)
            else:
                did_reload = True
                self.rdb.publish("server-reload-request", pid)

        channels.subscribe(**{"server-boot-complete": _server_booted})
        worker = channels.run_in_thread()
        nanny.start_nanny()
        worker.stop()
        reload(nanny)
예제 #5
0
    def test_main_reload(self):

        """Test that the nanny process can handle a reload request."""

        channels = self.rdb.pubsub(ignore_subscribe_messages=True)
        did_reload = False

        def _server_booted(msg):
            nonlocal did_reload
            pid = int(msg["data"])
            if did_reload:
                self.rdb.publish("server-shutdown", pid)
            else:
                did_reload = True
                self.rdb.publish("server-reload-request", pid)

        channels.subscribe(**{"server-boot-complete": _server_booted})
        worker = channels.run_in_thread()
        nanny.start_nanny()
        worker.stop()
        reload(nanny)