def test_validate_item_switchable_incomplete_list_templates(self):
        button_list_templates = {
            ListTemplateType.LOCATION, "{0} (currently {1})"
        }
        button_switching_info = SwitchInfo(Item.ATTRIBUTE_GIVES_LIGHT, "up",
                                           "down")
        self.items_by_id[1044] = SwitchableItem(
            1044, 0x8,
            Labels("button", "a button", "a red button",
                   [". It is dark", ". It is glowing"]), 2, None,
            button_list_templates, button_switching_info)

        validation = self.validator.validate(self.data_collection)

        self.assertEqual(1, len(validation))
        validation_line = validation[0]
        self.assertEqual(
            "Missing or incomplete list templates found for switchable item {0} \"{1}\". While not mandatory, this will lead to incomplete descriptions of this item when listed. Switchable items should specify either \"default\" or both \"location\" and \"carrying\" list templates.",
            validation_line.template)
        self.assertEqual(Severity.WARN, validation_line.severity)
        self.assertEqual((1044, "button"), validation_line.args)
 def setup_items(self):
     self.book = Item(1105, 0x2,
                      Labels("book", "a book", "a book of fairytales"), 2,
                      "The Pied Piper", {}, None)
     lamp_list_templates = {ListTemplateType.DEFAULT, "{0} (currently {1})"}
     lamp_switching_info = SwitchInfo(Item.ATTRIBUTE_GIVES_LIGHT, "off",
                                      "on")
     self.lamp = SwitchableItem(1043, 0x100A,
                                Labels("lamp", "a lamp",
                                       "a small lamp"), 3, None,
                                lamp_list_templates, lamp_switching_info)
     suit_list_templates = {ListTemplateType.USING, "(wearing) {0}"}
     self.suit = UsableItem(1046, 0x402,
                            Labels("suit", "a suit",
                                   "a space-suit"), 2, None,
                            suit_list_templates, Item.ATTRIBUTE_GIVES_AIR)
     self.basket = ContainerItem(
         1107, 0x3, Labels("basket", "a basket", "a large basket"), 8, None,
         {})
     self.desk = Item(1000, 0x20000,
                      Labels("desk", "a desk", "a large mahogany desk"), 6,
                      None, {})
     self.desk.add_container(self.lighthouse_location)
     self.wolf = Item(1080, 0x80006,
                      Labels("wolf", "a wolf", "a vicious wolf"), 4, None,
                      {}, None)
     self.wolf.add_container(self.lighthouse_location)
     self.items_by_id = {
         1105: self.book,
         1043: self.lamp,
         1046: self.suit,
         1107: self.basket,
         1000: self.desk,
         1080: self.wolf,
     }
     self.item_collection = ItemCollection({}, self.items_by_id)
Example #3
0
    def setUp(self):
        self.book = Item(1105, 0x2,
                         Labels("book", "a book", "a book of fairytales"), 2,
                         "The Pied Piper", {})
        self.desk = Item(1106, 0x20000,
                         Labels("desk", "a desk", "a large mahogany desk"), 6,
                         None, {})

        rope_list_templates = {
            ListTemplateType.LOCATION: "{0} (coiled neatly)",
            ListTemplateType.CARRYING: "{0} (tied safely)"
        }
        self.rope = Item(1123, 0x2,
                         Labels("rope", "some rope", "a small length of rope"),
                         2, None, rope_list_templates)

        basket_list_templates = {ListTemplateType.DEFAULT: "{0} (upright)"}
        self.basket = ContainerItem(
            1107, 0x3, Labels("basket", "a basket", "a large basket"), 6, None,
            basket_list_templates)
        box_list_templates = {ListTemplateType.DEFAULT: "{0} (open)"}
        self.box = ContainerItem(1108, 0x3,
                                 Labels("box", "a box", "a small box"), 3,
                                 None, box_list_templates)

        lamp_list_templates = {ListTemplateType.DEFAULT: "{0} ({1})"}
        lamp_switching_info = SwitchInfo(Item.ATTRIBUTE_GIVES_LIGHT, "off",
                                         "on")
        self.lamp = SwitchableItem(1043, 0x100A,
                                   Labels("lamp", "a lamp",
                                          "a small lamp"), 2, None,
                                   lamp_list_templates, lamp_switching_info)

        button_list_templates = {ListTemplateType.DEFAULT: "{0} ({1})"}
        button_switching_info = SwitchInfo(Item.ATTRIBUTE_GIVES_LIGHT, "up",
                                           "down")
        self.button = SwitchableItem(
            1044, 0x8,
            Labels("button", "a button", "a red button",
                   [". It is dark", ". It is glowing"]), 2, None,
            button_list_templates, button_switching_info)

        lever_list_templates = {ListTemplateType.DEFAULT: "{0} ({1})"}
        lever_switching_info = SwitchInfo(Location.ATTRIBUTE_GIVES_LIGHT,
                                          "down", "up")
        self.lever = SwitchableItem(
            1045, 0x8, Labels("lever", "a lever", "a mysterious lever"), 2,
            None, lever_list_templates, lever_switching_info)

        suit_list_templates = {ListTemplateType.USING: "{0} (being worn)"}
        self.suit = UsableItem(1046, 0x402,
                               Labels("suit", "a suit",
                                      "a space-suit"), 2, None,
                               suit_list_templates, Item.ATTRIBUTE_GIVES_AIR)

        self.cat = SentientItem(1047, 0x80002,
                                Labels("cat", "a cat", "a black cat"), 3, None,
                                {})
        self.water = Item(
            1109, 0x22902,
            Labels("water", "some water", "some water",
                   [". It is cold", ". It is hot"]), 1, None, {})
        self.mine_location = Location(
            11, 0x0,
            Labels("Mines", "in the mines",
                   ". There are dark passages everywhere."))
        self.inventory = Inventory(
            0, 0x1,
            Labels("Main Inventory", "in the main inventory",
                   ", where items live usually."), 100)

        self.steam = Item(1117, 0x2,
                          Labels("steam", "some steam", "some hot steam"), 1,
                          None, {})
        self.water.transformations[98] = self.steam