def test_drop_item_not_in_inv(self): item = Thing(self.game, "shoe") item.invItem = True self.start_room.addThing(item) self.assertFalse(self.me.containsItem(item)) self.game.turnMain(f"drop {item.verbose_name}") self.assertIn("You are not holding", self.app.print_stack.pop())
def test_set_on_floor_add_item_to_outer_room(self): item = Thing(self.game, "thing") item.invItem = True item.moveTo(self.game.me) self.assertIsNot(item.location, self.start_room) self.game.turnMain(f"set thing on floor") self.assertIs(item.location, self.start_room)
def test_verb_func_drops_item(self): item = Thing(self.game, self._get_unique_noun()) item.invItem = True self.me.addThing(item) self.assertIn(item.ix, self.me.contains) self.assertEqual(len(self.me.contains[item.ix]), 1) self.assertIn(item, self.me.contains[item.ix]) self.game.turnMain(f"drop {item.verbose_name}") self.assertItemNotIn(item, self.me.contains, "Dropped item, but item still in inventory")
def test_cannot_set_under_non_underspace(self): item = Thing(self.game, self._get_unique_noun()) item.invItem = True self.me.addThing(item) invalid_iobj = Thing(self.game, self._get_unique_noun()) self.start_room.addThing(invalid_iobj) self.assertNotIn(item.ix, invalid_iobj.contains) self.game.turnMain( f"set {item.verbose_name} under {invalid_iobj.verbose_name}") self.assertNotIn(item.ix, invalid_iobj.contains)
def test_set_in_adds_item(self): item = Thing(self.game, self._get_unique_noun()) item.invItem = True self.me.addThing(item) container = Container(self.game, self._get_unique_noun()) self.start_room.addThing(container) self.assertNotIn(item.ix, container.contains) self.game.turnMain( f"set {item.verbose_name} in {container.verbose_name}") self.assertIn(item.ix, container.contains) self.assertIn(item, container.contains[item.ix])
def test_set_under_adds_item(self): item = Thing(self.game, self._get_unique_noun()) item.invItem = True self.me.addThing(item) underspace = UnderSpace(self.game, self._get_unique_noun()) self.start_room.addThing(underspace) self.assertNotIn(item.ix, underspace.contains) self.game.turnMain( f"set {item.verbose_name} under {underspace.verbose_name}") self.assertIn(item.ix, underspace.contains) self.assertIn(item, underspace.contains[item.ix])
def test_set_on_adds_item(self): item = Thing(self.game, self._get_unique_noun()) item.invItem = True self.me.addThing(item) surface = Surface(self.game, self._get_unique_noun()) self.start_room.addThing(surface) self.assertNotIn(item.ix, surface.contains) self.game.turnMain( f"set {item.verbose_name} on {surface.verbose_name}") self.assertIn(item.ix, surface.contains) self.assertIn(item, surface.contains[item.ix])