Esempio n. 1
0
def test_animal_enqueue_several():
    animal_instance_one = Animal("dog", "Doggy")
    animal_instance_two = Animal("cat", "Kitty")
    shelter_instance = AnimalShelter()
    shelter_instance.enqueue(animal_instance_one)
    shelter_instance.enqueue(animal_instance_two)
    actual = shelter_instance.cats.peek()
    expected = animal_instance_two
    assert actual == expected
Esempio n. 2
0
def test_animal_dequeue_several_types():
    animal_instance_one = Animal("cat", "Meow")
    animal_instance_two = Animal("dog", "Bark")
    shelter_instance = AnimalShelter()
    shelter_instance.enqueue(animal_instance_one)
    shelter_instance.enqueue(animal_instance_two)
    shelter_instance.dequeue("cat")
    actual = shelter_instance.dequeue("dog")
    expected = animal_instance_two
    assert actual == expected
Esempio n. 3
0
def test_animal_dequeue_several():
    animal_instance_one = Animal("dog", "Trump")
    animal_instance_two = Animal("dog", "Ivanka")
    shelter_instance = AnimalShelter()
    shelter_instance.enqueue(animal_instance_one)
    shelter_instance.enqueue(animal_instance_two)
    shelter_instance.dequeue("dog")
    actual = shelter_instance.dequeue("dog")
    expected = animal_instance_two
    assert actual == expected
Esempio n. 4
0
def test_animal_enqueue_one():
    animal_instance = Animal("cat", "Fluffers")
    shelter_instance = AnimalShelter()
    shelter_instance.enqueue(animal_instance)
    actual = shelter_instance.cats.peek()
    expected = animal_instance
    assert actual == expected
Esempio n. 5
0
def test_animal_dequeue_one():
    animal_instance = Animal("cat", "Carl")
    shelter_instance = AnimalShelter()
    shelter_instance.enqueue(animal_instance)
    actual = shelter_instance.dequeue("cat")
    expected = animal_instance
    assert actual == expected
Esempio n. 6
0
def test_animal_enqueue_invalid_type():
    animal_instance = Animal("cow", "Moo")
    shelter_instance = AnimalShelter()
    with pytest.raises(Exception):
        shelter.enqueue(animal_instance)
Esempio n. 7
0
import pytest
from code_challenges.fifo_animal_shelter.fifo_animal_shelter import AnimalShelter, Animal

#define  Animal Objects as Animals for use in testing AnimalShelter Queue
ferran = Animal('Ferran', 'cat')
raya = Animal('Raya', 'cat')
jora = Animal('Jora', 'dog')
athena = Animal('Athena', 'dog')


def test_shelter_enqueue_cat():
    shelter = AnimalShelter()
    shelter.enqueue(ferran)
    actual_1 = shelter.cat.front.value.name
    actual_2 = shelter.cat.rear.value.name
    expected = 'Ferran'
    assert actual_1 == expected
    assert actual_2 == expected


def test_shelter_enqueue_dog():
    shelter = AnimalShelter()
    shelter.enqueue(jora)
    actual_1 = shelter.dog.front.value.name
    actual_2 = shelter.dog.rear.value.name
    expected = 'Jora'
    assert actual_1 == expected
    assert actual_2 == expected


def test_shelter_enqueue_multi_cat():