def zoo_to_string(): """ fonction to_string """ test_animal = Dog("Rex", 5, 10, "testing2", 4) test_animal5 = Cat("kitty", 5, 10, "testing2", 4) test_enclosure1 = Enclosure("enclos-1", [test_animal, test_animal5]) test_animal1 = Dog("Test1", 5, 10, "testing1") test_animal2 = Cat("Test2", 10, 10, "testing2") test_animal3 = Pigeon("Test3", 5, 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]) print(str(test_zoo.to_string()))
def test_to_string(): """ fonction to_string_zoo """ test_animal1 = Dog("Fox", 5, 10, "testing") test_animal2 = Cat("Miao", 10, 10, "testing2") test_enclosure1 = Enclosure("enclos-0", [test_animal1, test_animal2]) test_animal = Dog("Rex", 5, 10, "testing2", 4) test_animal3 = Cat("kitty", 5, 10, "testing2", 4) test_enclosure2 = Enclosure("enclos-1", [test_animal, test_animal3]) test_zoo = Zoo("zomba", [test_enclosure1, test_enclosure2]) msg = "Le zoo appelé zomba contient : \n" + str( test_enclosure1.to_string() + "\n") + str(test_enclosure2.to_string() + "\n") assert test_zoo.to_string() == msg
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
def test_all_speaking_zoo(): """ fonction test_speaking_zoo """ test_animal = Dog("Rex", 17, 10, "testing2", 4) test_animal5 = Cat("kitty", 8, 10, "testing2", 4) test_enclosure1 = Enclosure("enclos-1", list_animaux=[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]) print(str(test_zoo.all_speaking()))
def enclos_to_string(): """ fonction to_string """ test_animal1 = Dog("Rex", 5, 10, "testing2", 4) test_animal2 = Cat("kitty", 5, 10, "testing2", 4) test_enclosure = Enclosure("enclos-1", list_animaux=[test_animal1, test_animal2]) print(str(test_enclosure.to_string()))
def test_all_speaking(): """ test: permet de retirer un Animal de la liste en fonction de sa position dans la liste """ test_animal3 = Dog("Test3", 5, 10, "testing3") test_animal4 = Cat("Test4", 10, 10, "testing4") test_enclosure = Enclosure("test", [test_animal4, test_animal3]) assert test_enclosure.all_speaking( ) == "l'animal Test4 dit :testing4\nl'animal Test3 dit :testing3\n"
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
def test_to_string(): """ fonction to_string """ test_animal1 = Dog("Fox", 5, 10, "testing") test_animal2 = Cat("Miao", 10, 10, "testing2") test_enclosure = Enclosure("enclos-1", list_animaux=[test_animal1, test_animal2]) msg = "L enclos appelé enclos-1 contient :\nFox a 5 PV et 10 PA et je dis testing et j'ai 4 pattes\nMiao a 10 PV et 10 PA et je dis testing2 et j'ai 4 pattes\n" assert test_enclosure.to_string() == msg
def test_create_enclos(): """ fonction test_create_enclo """ test_animal6 = Dog("Test1", 5, 10, "testing1", 4) test_animal5 = Cat("kitty", 8, 10, "testing2", 4) test_enclosure1 = Enclosure("enclos", [test_animal6, test_animal5]) test_zoo = Zoo("zoo", [test_enclosure1]) # assert isinstance(test_zoo.create_enclosure("test123"), Enclosure) print(str(test_zoo.create_enclosure("enclos1"))) print(str(test_zoo.to_string()))
def test_all_speaking(): """ test all speaking """ test_animal1 = Dog("Test1", 5, 10, "testing1") test_animal2 = Cat("Test2", 10, 10, "testing2") test_animal3 = Pigeon("Test3", 5, 10, "testing3") test_animal4 = Eagle("Test4", 10, 10, "testing4") test_enclosure = Enclosure( "test", [test_animal1, test_animal2, test_animal3, test_animal4]) print(str(test_enclosure.all_speaking()))
def test_all_speaking(): """ test de la fonction feed_all_speaking zoo """ test_animal1 = Dog("Test1", 5, 10, "hab-hab") test_animal2 = Dog("Test2", 10, 10, "grrr") enclo1 = Enclosure("test", [test_animal1, test_animal2]) test_animal3 = Dog("Fox", 15, 10, "miao") test_animal4 = Cat("Miao", 20, 10, "myiiiao") enclo2 = Enclosure("enclos-0", [test_animal3, test_animal4]) test_zoo = Zoo("zomba", [enclo1, enclo2]) assert test_zoo.all_speaking( ) == str(enclo1.all_speaking() + "\n") + str(enclo2.all_speaking() + "\n")
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())
def test_speak(): """ fonction qui fait parler l animal """ chat = Cat("chat", 5, 2, "miaw") chat.speak()