Ejemplo n.º 1
0
def test_search_place_full():
    game = Game()
    game.load("games/SearchTest.xml")
    message = "You found a sword\n" \
              + "You found a amulet\n" \
              + "You found a shield\n"
    assert game.search("Forest") == message
Ejemplo n.º 2
0
def test_search_basic():
    game = Game()
    game.load("games/SearchTest.xml")
    message = "You found a sword\n" \
              + "You found a amulet\n" \
              + "You found a shield\n"
    assert game.search() == message
Ejemplo n.º 3
0
def test_look_object_equipped_shield():
    game = Game()
    game.load("games/LookTest.xml")
    game.pickup("shield")
    game.equip("shield")
    assert game.look_at(
        "shield") == "Just a lousy shield. You have it equipped"
Ejemplo n.º 4
0
def test_reequip_shield():
    game = Game()
    game.load("games/EquipTest.xml")
    game.pickup("shield+1")
    game.pickup("shield+2")
    game.equip("shield+1")
    assert game.equip("shield+2") == "You equipped your shield+2"
    message = "You look in your backpack:" \
              + "\n\tYou have a shield+1"
    assert game.search("backpack") == message
Ejemplo n.º 5
0
def test_search_backpack_full():
    game = Game()
    game.load("games/SearchTest.xml")
    game.pickup("sword")
    game.pickup("amulet")
    game.pickup("shield")
    message = "You look in your backpack:" \
              + "\n\tYou have a sword" \
              + "\n\tYou have a amulet" \
              + "\n\tYou have a shield"
    assert game.search("backpack") == message
Ejemplo n.º 6
0
def test_look_object_switch_equipped_weapon():
    game = Game()
    game.load("games/LookTest.xml")
    game.pickup("sword")
    game.pickup("sword2")
    game.equip("sword")
    assert game.look_at("sword") == "Just a lousy sword. You have it equipped"
    assert game.look_at("sword2") == "Another sword"
    game.equip("sword2")
    assert game.look_at("sword") == "Just a lousy sword"
    assert game.look_at("sword2") == "Another sword. You have it equipped"
Ejemplo n.º 7
0
def test_fight_dead_enemy():
    game = Game()
    game.load("games/FightTest.xml")
    game.fight("enemy1")
    assert game.fight("enemy1") == "enemy1 is already dead"
Ejemplo n.º 8
0
def test_fight_basic():
    game = Game()
    game.load("games/FightTest.xml")
    assert game.fight("enemy1") == "You just killed the enemy1"
Ejemplo n.º 9
0
def test_equip_nothing():
    game = Game()
    game.load("games/EquipTest.xml")
    assert game.equip("sword+3") == "You have no sword+3 to equip"
Ejemplo n.º 10
0
def test_cannot_equip():
    game = Game()
    game.load("games/EquipTest.xml")
    game.pickup("amulet")
    assert game.equip("amulet") == "You can't equip amulet"
Ejemplo n.º 11
0
def test_search_dead_enemy2():
    game = Game()
    game.load("games/SearchTest.xml")
    game.fight("Enemy2")
    assert game.search("Enemy2") == "Found nothing in Enemy2"
Ejemplo n.º 12
0
def test_look_far_place_test():
    game = Game()
    game.load("games/LookTest.xml")
    assert game.look_at("town") == "Cannot look at town"
Ejemplo n.º 13
0
def test_basic_look_place_test():
    game = Game()
    game.load("games/LookTest.xml")
    assert game.look_at("forest") == "It is a nice forest."
Ejemplo n.º 14
0
def test_not_connected_place_test():
    game = Game()
    game.load("games/DemoGame.xml")
    assert game.goto("town") == "Cannot go to town"
Ejemplo n.º 15
0
def test_equip_shield():
    game = Game()
    game.load("games/EquipTest.xml")
    game.pickup("shield+1")
    assert game.equip("shield+1") == "You equipped your shield+1"
Ejemplo n.º 16
0
def test_equip_weapon():
    game = Game()
    game.load("games/EquipTest.xml")
    game.pickup("sword+1")
    assert game.equip("sword+1") == "You equipped your sword+1"
Ejemplo n.º 17
0
def test_search_nonexistent():
    game = Game()
    game.load("games/SearchTest.xml")
    assert game.search("nonexistent") == "Cannot search nonexistent"
Ejemplo n.º 18
0
def test_search_backpack_emptied():
    game = Game()
    game.load("games/SearchTest.xml")
    game.pickup("sword")
    game.equip("sword")
    assert game.search("backpack") == "You look in your backpack:"
Ejemplo n.º 19
0
def test_search_backpack_empty():
    game = Game()
    game.load("games/SearchTest.xml")
    assert game.search("backpack") == "You look in your backpack:"
Ejemplo n.º 20
0
def test_fight_enemy_in_other_place():
    game = Game()
    game.load("games/FightTest.xml")
    game.fight("enemy3")
    assert game.fight("enemy3") == "There is no enemy3 to fight"
Ejemplo n.º 21
0
def test_fight_basic_fail():
    game = Game()
    game.load("games/FightTest.xml")
    assert game.fight("nonexistent") == "There is no nonexistent to fight"
Ejemplo n.º 22
0
def test_look_object_at_floor_weapon():
    game = Game()
    game.load("games/LookTest.xml")
    assert game.look_at("sword") == "Just a lousy sword"
Ejemplo n.º 23
0
def test_look_next_place_test():
    game = Game()
    game.load("games/LookTest.xml")
    assert game.look_at("sea") == "You can see the sea from here"
Ejemplo n.º 24
0
def test_look_object_at_floor_item():
    game = Game()
    game.load("games/LookTest.xml")
    assert game.look_at("amulet") == "Pretty amulet"
Ejemplo n.º 25
0
def test_basic_look_enemy():
    game = Game()
    game.load("games/LookTest.xml")
    assert game.look_at("enemy1") == "Description e1"
Ejemplo n.º 26
0
def test_search_dead_enemy1():
    game = Game()
    game.load("games/SearchTest.xml")
    game.fight("Enemy1")
    assert game.search("Enemy1") == "You found a ring\n"
Ejemplo n.º 27
0
def test_look_object_at_floor_shield():
    game = Game()
    game.load("games/LookTest.xml")
    assert game.look_at("shield") == "Just a lousy shield"
Ejemplo n.º 28
0
def test_equip_equipped_shield():
    game = Game()
    game.load("games/EquipTest.xml")
    game.pickup("shield+1")
    game.equip("shield+1")
    assert game.equip("shield+1") == "shield+1 is already equipped"
Ejemplo n.º 29
0
def test_look_object_in_backpack():
    game = Game()
    game.load("games/LookTest.xml")
    game.pickup("sword")
    assert game.look_at("sword") == "Just a lousy sword"
Ejemplo n.º 30
0
def test_equip_fail():
    game = Game()
    game.load("games/EquipTest.xml")
    assert game.equip("nothing") == "You have no nothing to equip"