Ejemplo n.º 1
0
 def test_destroyFor(self):
     """
     L{Enhancement.destroyFor} powers down the L{Enhancement} from its
     L{Thing}, and removes it from its store.
     """
     StubEnhancement.createFor(self.thing)
     otherThing = Thing(store=self.store, name=u'test other thing')
     stub2 = StubEnhancement.createFor(otherThing)
     StubEnhancement.destroyFor(self.thing)
     self.assertIdentical(IStubSimulation(self.thing, None), None)
     self.assertEquals([stub2], list(self.store.query(StubEnhancement)))
Ejemplo n.º 2
0
 def test_allTiedUp(self):
     """
     If you're tied to a chair, you can't leave.
     """
     chairThing = Thing(store=self.store, name=u'chair')
     chairThing.moveTo(self.location)
     chair = Chair.createFor(chairThing)
     self.assertCommandOutput("sit chair", ["You sit in the chair."],
                              ["Test Player sits in the chair."])
     Tether.createFor(self.player, to=chairThing)
     self.assertCommandOutput("stand up",
                              ["You can't move, you're tied to a chair."],
                              ["Test Player struggles."])
Ejemplo n.º 3
0
    def test_squeakyContainer(self):
        """
        If a container is squeaky, that shouldn't interfere with its function
        as a container.  (i.e. let's make sure that links keep working even
        though we're using an annotator here.)
        """
        cont = Container.createFor(self.squeaker)

        mcguffin = Thing(store=self.store, name=u"mcguffin")
        mcguffin.moveTo(cont)

        self.assertCommandOutput(
            "take mcguffin from squeaker",
            ["You take a mcguffin from the squeaker."],
            ["Test Player takes a mcguffin from the squeaker."])
Ejemplo n.º 4
0
def world(store):
    def room(name):
        it = Thing(store=store, name=name)
        Container.createFor(it, capacity=1000)
        return it

    world = ImaginaryWorld(store=store, origin=room("The Beginning"))
    protagonist = world.create("An Example Player")
    shirt = createShirt(store=store, name="shirt", location=world.origin)
    pants = createPants(store=store, name="pants", location=world.origin)
    middle = room("The Middle")
    wearer = IClothingWearer(protagonist)
    wearer.putOn(IClothing(shirt))
    wearer.putOn(IClothing(pants))
    Exit.link(world.origin, middle, "north")

    squeakerThing = Thing(name="squeaker", location=middle, store=store)
    Squeaker.createFor(squeakerThing)
    return world
Ejemplo n.º 5
0
 def setUp(self):
     self.thing = Thing(name=u"alice", gender=Gender.FEMALE)
Ejemplo n.º 6
0
 def setUp(self):
     """
     Create a store with a thing in it.
     """
     self.store = Store()
     self.thing = Thing(store=self.store, name=u'test object')
Ejemplo n.º 7
0
 def room(name):
     it = Thing(store=store, name=name)
     Container.createFor(it, capacity=1000)
     return it