Esempio n. 1
0
            (5, 5),
            (7, 3),
        ]

        positions = [Position(*coords) for coords in flowers]
        env = Environment(flowers=positions)

        expect(env.is_flower(positions[0])).to(be_true)
        expect(env.is_flower(Position(0, 0))).to(be_false)


with describe(Bee) as self:
    with describe("movement"):
        with it("moves if no known environment"):
            bee = Bee("#1")
            result = bee.move("x", 5)
            expect(result).to(be_true)

        with it("updates postiion when moving"):
            bee = Bee("#2")
            result = bee.move("x", 5)
            expect(bee.position).to(equal(Position(5, 0)))

        with it("refuses to move outside known environment"):
            bee = Bee("#3", Environment(5, 5))
            result = bee.move("x", 10)
            expect(result).to(be_false)
            expect(bee.position).to(equal(Position()))

        with it("refuses to move in an unknown axis"):
            bee = Bee("#y", Environment(5, 5))