Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions imaginary/test/test_concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@

from epsilon import structlike

from axiom import item, attributes

from imaginary import language, unc, text as T, iimaginary
from imaginary.test import commandutils
from imaginary import objects

class FakeThing(object):
def __init__(self, **kw):
Expand Down Expand Up @@ -221,6 +224,62 @@ def test_components(self):
b.original
)

@implementer(iimaginary.IDescriptionContributor)
class beforeDescription(item.Item):
desc = u"before"
comesBefore = attributes.inmemory()
comesAfter = attributes.inmemory()
myattr = attributes.integer(default=0)
powerupInterfaces = [iimaginary.IDescriptionContributor]
def contributeDescriptionFrom(self, paths):
return language.ExpressString(self.desc)

@implementer(iimaginary.IDescriptionContributor)
class afterDescription(item.Item):
desc = u"after"
comesBefore = attributes.inmemory()
comesAfter = attributes.inmemory()
myattr = attributes.integer(default=0)
powerupInterfaces = [iimaginary.IDescriptionContributor]
def contributeDescriptionFrom(self, paths):
return language.ExpressString(self.desc)

class VisualizationTest(commandutils.CommandTestCaseMixin, unittest.TestCase):

def test_twoComponentOrdering(self):
viewedThing = objects.Thing(
store=self.store,
location=self.player.location,
name=u"viewed")

bd = beforeDescription(store=self.store)
ad = afterDescription(store=self.store)

bd.comesAfter = []
ad.comesAfter = [beforeDescription]

# Apply with wrong priorities!
viewedThing.powerUp(
bd,
priority=item.POWERUP_AFTER)
viewedThing.powerUp(
ad,
priority=item.POWERUP_BEFORE)

self.assertCommandOutput(
"look at viewed",
[commandutils.E(u"[ viewed ]"),
bd.desc,
ad.desc])

ad.comesAfter = []
bd.comesAfter = [afterDescription]

self.assertCommandOutput(
"look at viewed",
[commandutils.E(u"[ viewed ]"),
ad.desc,
bd.desc])

@implementer(iimaginary.IExit)
class StubExit(structlike.record("name")):
Expand Down