Exemplo n.º 1
0
class TestBravoProtocol(TestCase):

    def setUp(self):
        self.bcp = BravoConfigParser()
        self.p = BravoProtocol(self.bcp, "unittest")

    def tearDown(self):
        self.p.setTimeout(None)

    def test_trivial(self):
        pass

    def test_entities_near_unloaded_chunk(self):
        """
        entities_near() shouldn't raise a fatal KeyError when a nearby chunk
        isn't loaded.

        Reported by brachiel on IRC.
        """

        list(self.p.entities_near(2))

    def test_disable_chunk_invalid(self):
        """
        If invalid data is sent to disable_chunk(), no error should happen.
        """

        self.p.disable_chunk(0, 0)
Exemplo n.º 2
0
class TestBravoProtocol(TestCase):
    def setUp(self):
        self.bcp = BravoConfigParser()
        self.p = BravoProtocol(self.bcp, "unittest")

    def tearDown(self):
        self.p.setTimeout(None)

    def test_trivial(self):
        pass

    def test_entities_near_unloaded_chunk(self):
        """
        entities_near() shouldn't raise a fatal KeyError when a nearby chunk
        isn't loaded.

        Reported by brachiel on IRC.
        """

        list(self.p.entities_near(2))

    def test_disable_chunk_invalid(self):
        """
        If invalid data is sent to disable_chunk(), no error should happen.
        """

        self.p.disable_chunk(0, 0)
Exemplo n.º 3
0
class TestBravoProtocolChunks(TestCase):

    def setUp(self):
        self.bcp = BravoConfigParser()
        self.p = BravoProtocol(self.bcp, "unittest")
        self.p.setTimeout(None)

        self.p.state = STATE_LOCATED

    def test_trivial(self):
        pass

    def test_ascend_zero(self):
        """
        ``ascend()`` can take a count of zero to ensure that the client is
        standing on solid ground.
        """

        self.p.location.pos = self.p.location.pos._replace(y=16)
        c = Chunk(0, 0)
        c.set_block((0, 0, 0), 1)
        self.p.chunks[0, 0] = c
        self.p.ascend(0)
        self.assertEqual(self.p.location.pos.y, 16)

    def test_ascend_zero_up(self):
        """
        Even with a zero count, ``ascend()`` will move the player to the
        correct elevation.
        """

        self.p.location.pos = self.p.location.pos._replace(y=16)
        c = Chunk(0, 0)
        c.set_block((0, 0, 0), 1)
        c.set_block((0, 1, 0), 1)
        self.p.chunks[0, 0] = c
        self.p.ascend(0)
        self.assertEqual(self.p.location.pos.y, 32)

    def test_ascend_one_up(self):
        """
        ``ascend()`` moves players upwards.
        """

        self.p.location.pos = self.p.location.pos._replace(y=16)
        c = Chunk(0, 0)
        c.set_block((0, 0, 0), 1)
        c.set_block((0, 1, 0), 1)
        self.p.chunks[0, 0] = c
        self.p.ascend(1)
        self.assertEqual(self.p.location.pos.y, 32)
Exemplo n.º 4
0
class TestBravoProtocolChunks(TestCase):
    def setUp(self):
        self.bcp = BravoConfigParser()
        self.p = BravoProtocol(self.bcp, "unittest")
        self.p.setTimeout(None)

        self.p.state = STATE_LOCATED

    def test_trivial(self):
        pass

    def test_ascend_zero(self):
        """
        ``ascend()`` can take a count of zero to ensure that the client is
        standing on solid ground.
        """

        self.p.location.pos = self.p.location.pos._replace(y=16)
        c = Chunk(0, 0)
        c.set_block((0, 0, 0), 1)
        self.p.chunks[0, 0] = c
        self.p.ascend(0)
        self.assertEqual(self.p.location.pos.y, 16)

    def test_ascend_zero_up(self):
        """
        Even with a zero count, ``ascend()`` will move the player to the
        correct elevation.
        """

        self.p.location.pos = self.p.location.pos._replace(y=16)
        c = Chunk(0, 0)
        c.set_block((0, 0, 0), 1)
        c.set_block((0, 1, 0), 1)
        self.p.chunks[0, 0] = c
        self.p.ascend(0)
        self.assertEqual(self.p.location.pos.y, 32)

    def test_ascend_one_up(self):
        """
        ``ascend()`` moves players upwards.
        """

        self.p.location.pos = self.p.location.pos._replace(y=16)
        c = Chunk(0, 0)
        c.set_block((0, 0, 0), 1)
        c.set_block((0, 1, 0), 1)
        self.p.chunks[0, 0] = c
        self.p.ascend(1)
        self.assertEqual(self.p.location.pos.y, 32)