Ejemplo n.º 1
0
def test_attack():
    """
    fonction pour attacker un autre animal
    """
    test_attacking = Cat("Test", 5, 2, "KILL")
    test_victim = Cat("Test2", 10, 1, "HELP")
    test_attacking.attack(test_victim)
    assert test_victim.get_life_point() == 8
Ejemplo n.º 2
0
def test_feeding_zoo():
    """
    fonction test_feeding_zoo
    """
    test_animal = Dog("Rex", 17, 10, "testing2", 4)
    test_animal5 = Cat("kitty", 8, 10, "testing2", 4)
    test_enclosure1 = Enclosure("enclos-1", [test_animal, test_animal5])
    test_animal1 = Dog("Test1", 5, 10, "testing1")
    test_animal2 = Cat("Test2", 25, 10, "testing2")
    test_animal3 = Pigeon("Test3", 15, 10, "testing3")
    test_animal4 = Eagle("Test4", 10, 10, "testing4")
    test_enclosure2 = Enclosure(
        "test", [test_animal1, test_animal2, test_animal3, test_animal4])
    test_zoo = Zoo("zomba", [test_enclosure1, test_enclosure2])
    test_zoo.feed_all(100)
    print(test_animal.get_life_point())
    print(test_animal1.get_life_point())
    print(test_animal2.get_life_point())
    print(test_animal3.get_life_point())
    print(test_animal4.get_life_point())
    print(test_animal5.get_life_point())
Ejemplo n.º 3
0
def test_feed_all():
    """
    test de la fonction feed_all zoo
    """
    test_animal1 = Animal("Test1", 5, 10, "testing1")
    test_animal2 = Animal("Test2", 10, 10, "testing2")
    test_enclosure1 = Enclosure("test", [test_animal1, test_animal2])
    test_animal3 = Dog("Fox", 15, 10, "testing")
    test_animal4 = Cat("Miao", 20, 10, "testing2")
    test_enclosure2 = Enclosure("enclos-0", [test_animal3, test_animal4])
    test_zoo = Zoo("zomba", [test_enclosure1, test_enclosure2])
    test_zoo.feed_all(5)
    assert test_animal1.get_life_point() == 10
    assert test_animal2.get_life_point() == 15
    assert test_animal3.get_life_point() == 20
    assert test_animal4.get_life_point() == 25