コード例 #1
0
ファイル: test_inventory.py プロジェクト: soniloi/vindironta
    def setUp(self):

        self.inventory = Inventory(
            0, 0x1,
            Labels("Main Inventory", "in the main inventory",
                   ", where items live usually."), 3)
        self.book = Item(1105, 0x2,
                         Labels("book", "a book", "a book of fairytales"), 2,
                         "The Pied Piper", {})
        self.lamp = Item(1043, 0x10101A,
                         Labels("lamp", "a lamp", "a small lamp"), 2, None, {})
        self.coin = Item(1000, 0x2, Labels("coin", "a coin", "a silver coin"),
                         1, None, {})
        self.medal = Item(1001, 0x2, Labels("medal", "a medal",
                                            "a gold medal"), 1, None, {})
        self.suit = UsableItem(1046, 0x402,
                               Labels("suit", "a suit", "a space-suit"), 2,
                               None, {}, Item.ATTRIBUTE_GIVES_AIR)
        self.water = Item(1109, 0x22902,
                          Labels("water", "some water", "some water"), 1, None,
                          {})
        self.basket = ContainerItem(
            1107, 0x3, Labels("basket", "a basket", "a large basket"), 6, None,
            {})
        self.non_essential_drop_location = Location(
            12, 0x1, Labels("Lighthouse", "at a lighthouse", " by the sea."))
        self.essential_drop_location = Location(
            9, 0x0, Labels("Cave", "in a cave", ". It is dark"))
コード例 #2
0
	def setup_inventories(self):
		default_labels = Labels("Main Inventory", "in the main inventory", ", where items live usually.")
		self.default_inventory_template = Inventory(0, 0x1, default_labels, 13)
		non_default_labels = Labels("Special Inventory", "in the special inventory", ", where items live sometimes.")
		self.non_default_inventory_template = Inventory(1, 0x0, non_default_labels, 8, [37, 38, 39])

		self.data.get_inventory_template.side_effect = lambda x: {
			0 : self.default_inventory_template,
			1 : self.non_default_inventory_template,
		}.get(x)

		self.data.get_inventory_templates.return_value = [self.default_inventory_template, self.non_default_inventory_template]
コード例 #3
0
 def setup_inventories(self):
     self.inventories_by_id = {}
     self.inventories_by_id[0] = Inventory(
         0, 0x1,
         Labels("Main Inventory", "in the main inventory",
                ", where items live usually."), 3)
     self.inventory_collection = InventoryCollection(self.inventories_by_id)
コード例 #4
0
    def test_validate_inventory_non_default_shared_location(self):
        self.inventories_by_id[1] = Inventory(
            1, 0x0,
            Labels("Special Inventory", "in the special inventory",
                   ", where items live sometimes."), 3, [12])
        self.inventories_by_id[2] = Inventory(
            2, 0x0,
            Labels("Occasional Inventory", "in the occasional inventory",
                   ", where items live occasionally."), 3, [12])

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

        self.assertEqual(3, len(self.inventories_by_id))
        self.assertEqual(1, len(validation))
        validation_line = validation[0]
        self.assertEqual(
            "Non-default inventory {0} \"{1}\" references location with id {2}, but this location is referenced by at least one other inventory.",
            validation_line.template)
        self.assertEqual(Severity.ERROR, validation_line.severity)
        self.assertEqual((2, "Occasional Inventory", 12), validation_line.args)
コード例 #5
0
ファイル: test_player.py プロジェクト: soniloi/vindironta
 def setUp(self):
     self.lighthouse_location = Location(
         12, 0x603, Labels("Lighthouse", "at a lighthouse", " by the sea."))
     self.beach_location = Location(
         13, 0x603, Labels("Beach", "on a beach", " of black sand"))
     self.cave_location = Location(
         9, 0x402, Labels("Cave", "in a cave", ". It is dark"))
     self.inventory = Inventory(
         0, 0x1,
         Labels("Main Inventory", "in the main inventory",
                ", where items live usually."), 13)
     self.player = Player(1, 0x3, self.lighthouse_location,
                          self.cave_location, self.beach_location,
                          self.cave_location, self.inventory)
コード例 #6
0
    def parse_inventory(self, inventory_input):
        inventory_id = inventory_input["data_id"]
        attributes = int(inventory_input["attributes"], 16)
        labels = self.parse_labels(inventory_input["labels"])
        capacity = inventory_input["capacity"]
        location_ids = self.parse_location_ids(
            inventory_input.get("locations"))

        return Inventory(
            inventory_id=inventory_id,
            attributes=attributes,
            labels=labels,
            capacity=capacity,
            location_ids=location_ids,
        )
コード例 #7
0
    def test_validate_inventory_non_default_duplicate_location(self):
        self.inventories_by_id[1] = Inventory(
            1, 0x0,
            Labels("Special Inventory", "in the special inventory",
                   ", where items live sometimes."), 3, [12, 12])

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

        self.assertEqual(2, len(self.inventories_by_id))
        self.assertEqual(1, len(validation))
        validation_line = validation[0]
        self.assertEqual(
            "Non-default inventory {0} \"{1}\" references location with id {2} multiple times.",
            validation_line.template)
        self.assertEqual(Severity.WARN, validation_line.severity)
        self.assertEqual((1, "Special Inventory", 12), validation_line.args)
コード例 #8
0
    def test_validate_inventory_non_default_unknown_location(self):
        self.inventories_by_id[1] = Inventory(
            1, 0x0,
            Labels("Special Inventory", "in the special inventory",
                   ", where items live sometimes."), 3, [888])

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

        self.assertEqual(2, len(self.inventories_by_id))
        self.assertEqual(1, len(validation))
        validation_line = validation[0]
        self.assertEqual(
            "Non-default inventory {0} \"{1}\" references location with id {2}, but this does not reference a valid location.",
            validation_line.template)
        self.assertEqual(Severity.ERROR, validation_line.severity)
        self.assertEqual((1, "Special Inventory", 888), validation_line.args)
コード例 #9
0
    def test_validate_inventory_non_default_no_locations(self):
        self.inventories_by_id[1] = Inventory(
            1, 0x0,
            Labels("Special Inventory", "in the special inventory",
                   ", where items live sometimes."), 3)

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

        self.assertEqual(2, len(self.inventories_by_id))
        self.assertEqual(1, len(validation))
        validation_line = validation[0]
        self.assertEqual(
            "Non-default inventory {0} \"{1}\" has no location ids specified. It will not be used anywhere.",
            validation_line.template)
        self.assertEqual(Severity.WARN, validation_line.severity)
        self.assertEqual((1, "Special Inventory"), validation_line.args)
コード例 #10
0
    def test_validate_inventory_multiple_defaults(self):
        self.inventories_by_id[1] = Inventory(
            1, 0x1,
            Labels("Special Inventory", "in the special inventory",
                   ", where items live sometimes."), 3)

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

        self.assertEqual(2, len(self.inventories_by_id))
        self.assertEqual(1, len(validation))
        validation_line = validation[0]
        self.assertEqual(
            "Multiple default inventories found ({0}). Exactly one inventory must be marked as default.",
            validation_line.template)
        self.assertEqual(Severity.ERROR, validation_line.severity)
        self.assertEqual(([0, 1], ), validation_line.args)
コード例 #11
0
    def test_validate_inventory_default_with_locations(self):
        self.inventories_by_id.clear()
        self.inventories_by_id[1] = Inventory(
            0, 0x1,
            Labels("Main Inventory", "in the main inventory",
                   ", where items live usually."), 3, [12])

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

        self.assertEqual(1, len(self.inventories_by_id))
        self.assertEqual(1, len(validation))
        validation_line = validation[0]
        self.assertEqual(
            "Default inventory {0} \"{1}\" has location ids specified. This is redundant.",
            validation_line.template)
        self.assertEqual(Severity.WARN, validation_line.severity)
        self.assertEqual((0, "Main Inventory"), validation_line.args)
コード例 #12
0
    def test_validate_inventory_no_default(self):
        self.inventories_by_id.clear()
        self.inventories_by_id[1] = Inventory(
            1, 0x0,
            Labels("Special Inventory", "in the special inventory",
                   ", where items live sometimes."), 3, [12])

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

        self.assertEqual(1, len(self.inventories_by_id))
        self.assertEqual(1, len(validation))
        validation_line = validation[0]
        self.assertEqual(
            "No default inventory found. Exactly one inventory must be marked as default.",
            validation_line.template)
        self.assertEqual(Severity.ERROR, validation_line.severity)
        self.assertEqual((), validation_line.args)
コード例 #13
0
ファイル: test_inventory.py プロジェクト: soniloi/vindironta
class TestInventory(unittest.TestCase):
    def setUp(self):

        self.inventory = Inventory(
            0, 0x1,
            Labels("Main Inventory", "in the main inventory",
                   ", where items live usually."), 3)
        self.book = Item(1105, 0x2,
                         Labels("book", "a book", "a book of fairytales"), 2,
                         "The Pied Piper", {})
        self.lamp = Item(1043, 0x10101A,
                         Labels("lamp", "a lamp", "a small lamp"), 2, None, {})
        self.coin = Item(1000, 0x2, Labels("coin", "a coin", "a silver coin"),
                         1, None, {})
        self.medal = Item(1001, 0x2, Labels("medal", "a medal",
                                            "a gold medal"), 1, None, {})
        self.suit = UsableItem(1046, 0x402,
                               Labels("suit", "a suit", "a space-suit"), 2,
                               None, {}, Item.ATTRIBUTE_GIVES_AIR)
        self.water = Item(1109, 0x22902,
                          Labels("water", "some water", "some water"), 1, None,
                          {})
        self.basket = ContainerItem(
            1107, 0x3, Labels("basket", "a basket", "a large basket"), 6, None,
            {})
        self.non_essential_drop_location = Location(
            12, 0x1, Labels("Lighthouse", "at a lighthouse", " by the sea."))
        self.essential_drop_location = Location(
            9, 0x0, Labels("Cave", "in a cave", ". It is dark"))

    def test_insert_non_copyable(self):
        self.inventory.insert(self.book)

        self.assertTrue(self.inventory.contains(self.book))

    def test_insert_copyable(self):
        self.inventory.insert(self.water)

        self.assertFalse(self.inventory.contains(self.water))
        water_copy = self.inventory.get_allow_copy(self.water)
        self.assertTrue(water_copy)
        self.assertEqual(self.water.data_id, water_copy.data_id)
        self.assertIs(self.water, water_copy.copied_from)
        self.assertTrue(water_copy in self.water.copied_to)

    def test_can_accommodate_below_capacity(self):
        self.assertTrue(self.inventory.can_accommodate(self.book))

    def test_can_accommodate_to_capacity(self):
        self.inventory.insert(self.book)

        self.assertTrue(self.inventory.can_accommodate(self.coin))

    def test_can_accommodate_at_capacity(self):
        self.inventory.insert(self.book)
        self.inventory.insert(self.medal)

        self.assertFalse(self.inventory.can_accommodate(self.coin))

    def test_can_accommodate_above_capacity_non_wearable(self):
        self.inventory.insert(self.book)

        self.assertFalse(self.inventory.can_accommodate(self.lamp))

    def test_can_accommodate_above_capacity_wearable_not_being_used(self):
        self.inventory.insert(self.suit)
        self.suit.being_used = False

        self.assertFalse(self.inventory.can_accommodate(self.lamp))

    def test_can_accommodate_above_capacity_wearable_being_used(self):
        self.inventory.insert(self.suit)
        self.suit.being_used = True

        self.assertTrue(self.inventory.can_accommodate(self.lamp))

    def test_can_accommodate_remove_above_capacity_wearable_being_used(self):
        self.inventory.insert(self.lamp)
        self.suit.being_used = True

        self.assertFalse(self.inventory.can_accommodate_remove(self.suit))

    def test_drop_all_items_none(self):
        self.inventory.drop_all_items(self.non_essential_drop_location,
                                      self.essential_drop_location)

        self.assertFalse(self.inventory.has_items())
        self.assertFalse(self.non_essential_drop_location.has_items())
        self.assertFalse(self.essential_drop_location.has_items())

    def test_drop_all_items_single(self):
        self.inventory.insert(self.book)

        self.inventory.drop_all_items(self.non_essential_drop_location,
                                      self.essential_drop_location)

        self.assertFalse(self.inventory.has_items())
        self.assertTrue(self.non_essential_drop_location.contains(self.book))
        self.assertFalse(self.essential_drop_location.has_items())

    def test_drop_all_items_multiple_with_only_non_essential(self):
        self.inventory.insert(self.coin)
        self.inventory.insert(self.medal)
        self.inventory.insert(self.book)

        self.inventory.drop_all_items(self.non_essential_drop_location,
                                      self.essential_drop_location)

        self.assertFalse(self.inventory.has_items())
        self.assertTrue(self.non_essential_drop_location.contains(self.coin))
        self.assertTrue(self.non_essential_drop_location.contains(self.medal))
        self.assertTrue(self.non_essential_drop_location.contains(self.book))
        self.assertFalse(self.essential_drop_location.has_items())

    def test_drop_all_items_multiple_with_essential_item_simple(self):
        self.inventory.insert(self.book)
        self.inventory.insert(self.lamp)

        self.inventory.drop_all_items(self.non_essential_drop_location,
                                      self.essential_drop_location)

        self.assertFalse(self.inventory.has_items())
        self.assertTrue(self.non_essential_drop_location.contains(self.book))
        self.assertFalse(self.non_essential_drop_location.contains(self.lamp))
        self.assertTrue(self.essential_drop_location.has_items())
        self.assertFalse(self.essential_drop_location.contains(self.book))
        self.assertTrue(self.essential_drop_location.contains(self.lamp))

    def test_drop_all_items_multiple_with_essential_item_nested(self):
        self.basket.insert(self.lamp)
        self.inventory.insert(self.basket)

        self.inventory.drop_all_items(self.non_essential_drop_location,
                                      self.essential_drop_location)

        self.assertFalse(self.inventory.has_items())
        self.assertFalse(self.non_essential_drop_location.has_items())
        self.assertTrue(self.essential_drop_location.has_items())
        self.assertFalse(self.lamp in self.essential_drop_location.items)
        self.assertTrue(self.basket in self.essential_drop_location.items)
        self.assertTrue(self.basket.contains(self.lamp))
コード例 #14
0
 def Init(self):
     self.location = None
     self.inventory = Inventory(5, self)
     self.items = dict()
     self.isDead = False
コード例 #15
0
ファイル: test_item.py プロジェクト: soniloi/vindironta
    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
コード例 #16
0
ファイル: test_item.py プロジェクト: soniloi/vindironta
class TestItem(unittest.TestCase):
    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

    def test_copy(self):
        water_copy = copy(self.water)
        self.assertEqual(self.water.data_id, water_copy.data_id)
        self.assertEqual(self.water.shortname, water_copy.shortname)
        self.assertEqual(self.water.longname, water_copy.longname)
        self.assertEqual(self.water.description, water_copy.description)
        self.assertEqual(self.water.extended_descriptions,
                         water_copy.extended_descriptions)
        self.assertFalse(water_copy.is_copyable())
        self.assertIs(self.steam, water_copy.transformations[98])
        self.assertIs(self.water, water_copy.copied_from)
        self.assertTrue(water_copy in self.water.copied_to)

    def test_get_original_not_copied(self):
        self.assertEqual(self.book, self.book.get_original())

    def test_get_original_copied_once(self):
        water_copy = copy(self.water)

        self.assertEqual(self.water, water_copy.get_original())

    def test_get_original_copied_twice(self):
        water_copy = copy(self.water)
        water_copy_copy = copy(water_copy)

        self.assertEqual(self.water, water_copy_copy.get_original())

    def test_break_open_non_container(self):
        self.assertIsNone(self.lamp.break_open())

    def test_get_list_name_location_no_list_templates(self):
        self.assertEqual("\n\ta book", self.book.get_list_name_location())

    def test_get_list_name_inventory_no_list_templates(self):
        self.assertEqual("\n\ta book", self.book.get_list_name_inventory())

    def test_get_list_name_location_with_list_template(self):
        self.assertEqual("\n\tsome rope (coiled neatly)",
                         self.rope.get_list_name_location())

    def test_get_list_name_inventory_with_list_template(self):
        self.assertEqual("\n\tsome rope (tied safely)",
                         self.rope.get_list_name_inventory())

    def test_get_full_description_without_extended_descriptions(self):
        self.assertEqual(["a book of fairytales"],
                         self.book.get_full_description())

    def test_get_full_description_with_extended_descriptions(self):
        self.assertEqual(["some water. It is cold"],
                         self.water.get_full_description())

    def test_break_open_container(self):
        self.box.insert(self.book)

        self.assertEqual(self.book, self.box.break_open())

    def test_get_list_name_location_empty(self):
        self.assertEqual("\n\ta box (open) (---)",
                         self.box.get_list_name_location())

    def test_get_list_name_location_container_nonempty_single(self):
        self.box.insert(self.book)

        self.assertEqual("\n\ta box (open) +\n\t\ta book",
                         self.box.get_list_name_location())

    def test_get_list_name_location_container_nonempty_multi(self):
        self.basket.insert(self.box)
        self.box.insert(self.book)

        self.assertEqual(
            "\n\ta basket (upright) +\n\t\ta box (open) +\n\t\t\ta book",
            self.basket.get_list_name_location())

    def test_contains_simple(self):
        self.assertFalse(self.desk.contains(self.book))

    def test_contains_container_empty(self):
        self.assertFalse(self.basket.contains(self.book))

    def test_contains_container_nonempty_single(self):
        self.box.insert(self.book)

        self.assertTrue(self.box.contains(self.book))

    def test_contains_container_nonempty_multi(self):
        self.basket.insert(self.box)
        self.box.insert(self.book)

        self.assertTrue(self.basket.contains(self.box))
        self.assertTrue(self.box.contains(self.book))
        self.assertTrue(self.basket.contains(self.book))

    def test_get_allow_copy_single(self):
        book_copy = copy(self.book)
        self.box.insert(book_copy)

        self.assertFalse(self.box.contains(self.book))
        self.assertEqual(book_copy, self.box.get_allow_copy(self.book))

    def test_get_allow_copy_multi(self):
        book_copy = copy(self.book)
        self.box.insert(book_copy)
        self.basket.insert(self.box)

        self.assertFalse(self.basket.contains(self.book))
        self.assertEqual(book_copy, self.basket.get_allow_copy(self.book))

    def test_get_outermost_container_location(self):
        self.mine_location.insert(self.book)

        self.assertEqual(self.mine_location,
                         self.book.get_outermost_container())

    def test_get_outermost_container_inventory(self):
        self.inventory.insert(self.book)

        self.assertEqual(self.inventory, self.book.get_outermost_container())

    def test_get_outermost_container_multi(self):
        self.mine_location.insert(self.basket)
        self.basket.insert(self.box)
        self.box.insert(self.book)

        self.assertEqual(self.mine_location,
                         self.book.get_outermost_container())

    def test_get_list_name_location_sentient(self):
        self.assertEqual("\n\ta cat", self.cat.get_list_name_location())

    def test_get_list_name_sentient_carrying_item(self):
        self.cat.insert(self.book)

        self.assertEqual("\n\ta cat +\n\t\ta book",
                         self.cat.get_list_name_location())

    def test_switch_on_self(self):
        self.lamp.switched_element = self.lamp

        self.lamp.switch_on()

        self.assertTrue(self.lamp.gives_light())

    def test_switch_off_self(self):
        self.lamp.switched_element = self.lamp

        self.lamp.switch_off()

        self.assertFalse(self.lamp.gives_light())

    def test_switch_on_other_item(self):
        self.button.switched_element = self.lamp

        self.button.switch_on()

        self.assertTrue(self.lamp.gives_light())

    def test_switch_off_other_item(self):
        self.button.switched_element = self.lamp

        self.button.switch_off()

        self.assertFalse(self.lamp.gives_light())

    def test_switch_on_other_location(self):
        self.lever.switched_element = self.mine_location

        self.lever.switch_on()

        self.assertTrue(self.mine_location.gives_light())

    def test_switch_off_other_location(self):
        self.lever.switched_element = self.mine_location

        self.lever.switch_off()

        self.assertFalse(self.mine_location.gives_light())

    def test_get_list_name_location_switchable_off(self):
        self.lamp.switched_element = self.lamp
        self.lamp.switch_off()

        self.assertEqual("\n\ta lamp (off)",
                         self.lamp.get_list_name_location())

    def test_get_list_name_location_switchable_on(self):
        self.lever.switched_element = self.mine_location
        self.lever.switch_on()

        self.assertEqual("\n\ta lever (up)",
                         self.lever.get_list_name_location())

    def test_get_full_description_switchable_without_extended_descriptions(
            self):
        self.lamp.switched_element = self.lamp
        self.lamp.switch_off()

        self.assertEqual(["a small lamp", "off"],
                         self.lamp.get_full_description())

    def test_get_full_description_switchable_with_extended_descriptions(self):
        self.button.switched_element = self.lamp
        self.button.switch_off()

        self.assertEqual(["a red button. It is dark", "up"],
                         self.button.get_full_description())

    def test_has_attribute_wearable_not_being_used(self):
        self.suit.being_used = False

        self.assertFalse(self.suit.gives_air())

    def test_has_attribute_wearable_being_used(self):
        self.suit.being_used = True

        self.assertTrue(self.suit.gives_air())

    def test_list_name_inventory_wearable_not_being_used(self):
        self.suit.being_used = False

        self.assertEqual("\n\ta suit", self.suit.get_list_name_inventory())

    def test_list_name_inventory_wearable_being_used(self):
        self.suit.being_used = True

        self.assertEqual("\n\ta suit (being worn)",
                         self.suit.get_list_name_inventory())