Ejemplo n.º 1
0
    def test_show_inventory(self):
        class Ctx(object):
            class Config(object):
                pass

            config = Config()

        class MoneyDriverDummy(object):
            pass

        ctx = Ctx()
        ctx.config.money_type = "modern"
        ctx.driver = MoneyDriverDummy()
        ctx.driver.moneyfmt = MoneyFormatter(ctx.config.money_type)
        julie = Living("julie", "f", race="human")
        tap = julie.get_wiretap()
        collector = PubsubCollector()
        tap.subscribe(collector)
        item1 = Item("key")
        julie.init_inventory([item1])
        julie.money = 9.23
        julie.show_inventory(julie, ctx)
        pubsub.sync()
        text = " ".join(msg.strip() for msg in collector.messages)
        self.assertEqual(
            "Julie is carrying: key Money in possession: 9 dollars and 23 cents.",
            text)
        ctx.config.money_type = None
        ctx.driver.moneyfmt = None
        collector.clear()
        julie.show_inventory(julie, ctx)
        pubsub.sync()
        text = " ".join(msg.strip() for msg in collector.messages)
        self.assertEqual("Julie is carrying: key", text)
Ejemplo n.º 2
0
 def test_show_inventory(self):
     class Ctx(object):
         class Config(object):
             pass
         config = Config()
     class MoneyDriverDummy(object):
         pass
     ctx=Ctx()
     ctx.config.money_type = "modern"
     ctx.driver = MoneyDriverDummy()
     ctx.driver.moneyfmt = MoneyFormatter(ctx.config.money_type)
     julie = Living("julie", "f", race="human")
     tap = julie.get_wiretap()
     collector = PubsubCollector()
     tap.subscribe(collector)
     item1 = Item("key")
     julie.init_inventory([item1])
     julie.money = 9.23
     julie.show_inventory(julie, ctx)
     text = " ".join(msg.strip() for msg in collector.messages)
     self.assertEqual("Julie is carrying: key Money in possession: 9 dollar and 23 cent.", text)
     ctx.config.money_type = None
     ctx.driver.moneyfmt = None
     collector.clear()
     julie.show_inventory(julie, ctx)
     text = " ".join(msg.strip() for msg in collector.messages)
     self.assertEqual("Julie is carrying: key", text)
Ejemplo n.º 3
0
 def test_tell(self):
     julie = Living("julie", "f", race="human")
     tap = julie.get_wiretap()
     collector = PubsubCollector()
     tap.subscribe(collector)
     julie.tell("msg1", "msg2")
     julie.tell("msg3", "msg4", ignored_arg=42)
     self.assertEqual(["msg1", "msg2", "msg3", "msg4"], collector.messages)
Ejemplo n.º 4
0
 def test_tell(self):
     julie = Living("julie", "f", race="human")
     tap = julie.get_wiretap()
     collector = PubsubCollector()
     tap.subscribe(collector)
     julie.tell("msg1", "msg2")
     julie.tell("msg3", "msg4", ignored_arg=42)
     pubsub.sync()
     self.assertEqual(["msg1 msg2", "msg3 msg4"], collector.messages)
Ejemplo n.º 5
0
 def __init__(self, target: base.Living) -> None:
     self.msgs = []  # type: List[Any]
     self.senders = []   # type: List[Any]
     tap = target.get_wiretap()
     tap.subscribe(self)
Ejemplo n.º 6
0
 def __init__(self, target: base.Living) -> None:
     self.msgs = []  # type: List[Any]
     self.senders = []  # type: List[Any]
     tap = target.get_wiretap()
     tap.subscribe(self)