示例#1
0
def test_get_name():
    """
    getteur de name
    """
    animal1 = Animal()
    test_enclosure = Enclosure("Test", [animal1])
    assert test_enclosure.get_name() == "Test"
示例#2
0
def test_add_animal():
    """
    test:permet d’ajouter un Animal dans la liste
    """
    test_enclosure = Enclosure("test")
    test_animal1 = Animal("Test1", 5, 10, "testing2")
    test_enclosure.add_animal(test_animal1)
    assert len(test_enclosure.get_list_animaux()) == 1
示例#3
0
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"
示例#4
0
def test_remove_animal():
    """
    test:permet de retirer un Animal de la liste en fonction de sa position dans la liste
    """
    test_animal1 = Animal("Test1", 5, 10, "testing1")
    test_animal2 = Animal("Test2", 10, 10, "testing2")
    test_enclosure = Enclosure("test", [test_animal1, test_animal2])
    test_enclosure.remove_animal(1)
    assert len(test_enclosure.get_list_animaux()) == 1
示例#5
0
def test_get_list_animaux():
    """
    test getteur de name
    """
    animal1 = Animal("test1")
    animal2 = Animal("test2")
    animal3 = Animal("test3")
    test_enclosure = Enclosure("test", [animal1, animal2, animal3])
    assert test_enclosure.get_list_animaux() == [animal1, animal2, animal3]
示例#6
0
def test_get_list_enclosure():
    """
    test getteur de liste enclosure
    """
    enclo1 = Enclosure("test1")
    enclo2 = Enclosure("test2")
    enclo3 = Enclosure("test3")
    test_zoo = Zoo("test", [enclo1, enclo2, enclo3])
    assert test_zoo.get_list_enclosure() == [enclo1, enclo2, enclo3]
示例#7
0
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()))
示例#8
0
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
示例#9
0
def test_feeding_enclo():
    """
    fonction test_feeding_enclo
    """
    test_animal1 = Animal("Test1", 5, 10, "testing1")
    test_animal2 = Animal("Test2", 10, 10, "testing2")
    test_enclosure = Enclosure("test", [test_animal1, test_animal2])
    test_enclosure.feed_all(50)
    print(test_animal1.get_life_point())
    print(test_animal2.get_life_point())
示例#10
0
def test_feed_all():
    """
    test:permet de retirer un Animal de la liste en fonction de sa position dans la liste
    """
    test_animal1 = Animal("Test1", 5, 10, "testing1")
    test_animal2 = Animal("Test2", 10, 10, "testing2")
    test_enclosure = Enclosure("test", [test_animal1, test_animal2])
    test_enclosure.feed_all()
    assert test_animal1.get_life_point() == 10
    assert test_animal2.get_life_point() == 15
示例#11
0
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()))
示例#12
0
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()))
示例#13
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
示例#14
0
def test_get_name():
    """
    getteur de name
    """
    enco = Enclosure("enclos")
    test_zoo = Zoo("Test", [enco])
    assert test_zoo.get_name() == "Test"
示例#15
0
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()))
示例#16
0
def test_all_attacking():
    """
    test:permet de retirer un Animal de la liste en fonction de sa position dans la liste
    """
    dog_0 = Dog("Dog-0", 5, 10, "Voice-Dog-0")
    dog_1 = Dog("Dog-1", 5, 10, "Voice-Dog-1")
    dog_2 = Dog("Dog-2", 5, 10, "Voice-Dog-2")
    dog_3 = Dog("Dog-3", 5, 10, "Voice-Dog-3")
    dog_4 = Dog("Dog-4", 5, 10, "Voice-Dog-4")
    dog_5 = Dog("Dog-5", 5, 10, "Voice-Dog-5")
    dog_6 = Dog("Dog-6", 5, 10, "Voice-Dog-6")
    dog_7 = Dog("Dog-7", 5, 10, "Voice-Dog-7")

    enclosure_0 = Enclosure(
        "Enclos-0", [dog_0, dog_1, dog_2, dog_3, dog_4, dog_5, dog_6, dog_7])
    assert enclosure_0.all_attacking() == 0
示例#17
0
def test_set_name():
    """
    test setteur de name
    """
    animal1 = Animal()
    test_enclosure = Enclosure("Test", [animal1])
    test_zoo = Zoo("zoo", [test_enclosure])
    assert test_zoo.set_name() == 0
    test_zoo2 = Zoo("ok", [])
    assert test_zoo2.set_name(520) == 1
示例#18
0
def test_create_enclosure():
    """
    permet de tester la création d'un enclos
    """
    test_animal1 = Dog("Test1", 5, 10, "hab-hab")
    test_animal2 = Dog("Test2", 10, 10, "grrr")
    enclo1 = Enclosure("test", [test_animal1, test_animal2])
    test_zoo = Zoo("zomba", [enclo1])
    test_zoo.create_enclosure("zomba")
    assert len(test_zoo.get_list_enclosure()) == 2
示例#19
0
文件: zoo.py 项目: b00ba/Zoo-project
 def create_enclosure(self, name):
     """
     permet de créer un enclos
     """
     for enclos in self.__list_enclosure:
         if enclos.get_name() == name:
             return None
         nvenclos = Enclosure(name, [])
         self.__list_enclosure.append(nvenclos)
         return nvenclos
示例#20
0
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()))
示例#21
0
def test_set_list_enclosure():
    """
    test setteur de list animaux
    """
    ma_liste = []
    animal1 = Animal("test1")
    enclos = Enclosure("Test", [animal1])
    ma_liste.append(enclos)
    test_zoo1 = Zoo("zoo", [])
    assert test_zoo1.set_list_enclosure(ma_liste) == 0
    test_zoo2 = Zoo("ok", [])
    assert test_zoo2.set_list_enclosure(520) == 1
示例#22
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())
示例#23
0
def test_set_name():
    """
    test setteur de name
    """
    animal1 = Animal()
    test_enclosure = Enclosure("Test", [animal1])
    assert test_enclosure.set_name() == 0
    test_enclosure_2 = Enclosure("ok", [])
    assert test_enclosure_2.set_name(520) == 1
示例#24
0
def test_set_list_animaux():
    """
    test setteur de list animaux
    """
    ma_liste = []
    animal1 = Animal("Test", 5, 10, "testing")
    ma_liste.append(animal1)
    test_enclosure = Enclosure("Test", [])
    assert test_enclosure.set_list_animaux(ma_liste) == 0
    test_enclosure_2 = Enclosure("ok", [])
    assert test_enclosure_2.set_list_animaux(520) == 1
示例#25
0
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")
示例#26
0
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
示例#27
0
def test_all_attacking():
    """
    test:permet de faire attacker les animaux
    """
    dog_0 = Dog("Dog-0", 5, 10, "Voice-Dog-0")
    dog_1 = Dog("Dog-1", 5, 20, "Voice-Dog-1")
    dog_2 = Dog("Dog-2", 5, 10, "Voice-Dog-2")
    dog_3 = Dog("Dog-3", 50, 10, "Voice-Dog-3")
    dog_4 = Dog("Dog-4", 5, 20, "Voice-Dog-4")
    dog_5 = Dog("Dog-5", 15, 10, "Voice-Dog-5")
    dog_6 = Dog("Dog-6", 50, 20, "Voice-Dog-6")
    dog_7 = Dog("Dog-7", 5, 30, "Voice-Dog-7")

    enclosure_0 = Enclosure(
        "Enclos-0", [dog_0, dog_1, dog_2, dog_3, dog_4, dog_5, dog_6, dog_7])
    print("=== Before attack:")
    print(str(enclosure_0.to_string()))
    print("=== After attack:")
    enclosure_0.all_attacking()
    print(str(enclosure_0.to_string()))