def test_dequeue_dog(): shelter1 = AnimalShelter('shelter1') dog1 = Dog('dog1') dog2 = Dog('dog2') shelter1.enqueue(dog1) shelter1.enqueue(dog2) assert shelter1.dequeue('dog').name == 'dog1'
def test_enqueue_dog(): shelter1 = AnimalShelter('shelter1') dog1 = Dog('dog1') dog2 = Dog('dog2') shelter1.enqueue(dog1) shelter1.enqueue(dog2) assert shelter1
def test_enqueue_cats_and_dogs(): shelter2 = AnimalShelter('shelter2') dog1 = Dog('dog1') cat1 = Cat('cat1') dog2 = Dog('dog2') cat2 = Cat('cat2') shelter2.enqueue(dog1) shelter2.enqueue(cat1) shelter2.enqueue(dog2) shelter2.enqueue(cat2) assert shelter2
def test_shelter_enqueue(): shelter = AnimalShelter() shelter.enqueue(Cat("1")) assert shelter.queue1.front.value == "1" assert shelter.queue1.rear.value == "1" shelter.enqueue(Dog("2")) assert shelter.queue1.rear.value == "2" shelter.enqueue(Cat("3")) assert shelter.queue1.rear.value == "3" shelter.enqueue(Dog("4")) assert shelter.queue1.rear.value == "4" assert shelter.queue1.front.value == "1"
def test_shelter_enqueue_when_not_empty(animal_shelter): """The animal shelter should add an animal to the queue when the queue is empty.""" animals = [Cat(), Cat(), Dog()] for animal in animals: animal_shelter.enqueue(animal) assert isinstance(animal_shelter.peek(), Cat)
def test_shelter_dequeue_when_not_empty_and_not_at_top(animal_shelter): """The animal shelter removes an animal from the queue when the queue isn't empty and the animal isn't at the front of the animal shelter.""" animals = [Cat(), Cat(), Dog()] for animal in animals: animal_shelter.enqueue(animal) assert isinstance(animal_shelter.dequeue(Dog), Dog)
def test_AnimalShelter_enqueue_multiple(): animal_queue = AnimalShelter() animal_queue.enqueue(Cat()) animal_queue.enqueue(Cat()) animal_queue.enqueue(Dog()) expected = Cat() actual = animal_queue.peek() assert actual == expected
def test_shelter_enqueue(): shelter = AnimalShelter() shelter.enqueue(Cat('1')) assert shelter.cats.front.name == '1' assert shelter.cats.rear.name == '1' shelter.enqueue(Dog('2')) assert shelter.dogs.rear.name == '2' shelter.enqueue(Cat('3')) assert shelter.cats.rear.name == '3' assert shelter.cats.front.name == '1'
def test_shelter_dequeue(): shelter = AnimalShelter() shelter.enqueue(Cat('1')) shelter.enqueue(Dog('2')) shelter.enqueue(Cat('3')) shelter.enqueue(Cat('4')) shelter.enqueue(Dog('5')) taken = shelter.dequeue('cat') assert taken.type == 'cat' assert taken.name == '1' taken = shelter.dequeue('cat') assert taken.type == 'cat' assert taken.name == '3' taken = shelter.dequeue('dog') assert taken.type == 'dog' assert taken.name == '2' assert shelter.dogs.front.name == '5'
def test_shelter_dequeue(): shelter = AnimalShelter() shelter.enqueue(Cat("1")) shelter.enqueue(Dog("2")) shelter.enqueue(Cat("3")) shelter.enqueue(Cat("a")) shelter.enqueue(Dog("4")) pet_adopted = shelter.dequeue('cat') assert pet_adopted.type == 'cat' assert pet_adopted.value == '1' pet_adopted = shelter.dequeue('cat') assert pet_adopted.type == 'cat' assert pet_adopted.value == '3' pet_adopted = shelter.dequeue('dog') assert shelter.queue1.front.value == "a" assert pet_adopted.type == 'dog' assert pet_adopted.value == '2'
def test_shelter_dequeue_capital(): shelter = AnimalShelter() shelter.enqueue(Cat("1")) shelter.enqueue(Dog("2")) pet_adopted = shelter.dequeue('Dog') assert pet_adopted.value == '2'
def small_shelter(): """Create a short, alternating shelter queue.""" return shelter([Dog(), Cat(), Dog(), Cat()])
def test_add_remove_one_cat(shelter): shelter.enqueue(Dog('Dog')) shelter.enqueue(Cat('Cat')) assert shelter.dequeue('cat').name == 'Cat'
def test_class_exists(): AnimalShelter() Animal(AnimalType.CAT) Cat() Dog()
def test_add_remove_one_cat(shelter): shelter.enqueue(Dog("chester")) shelter.enqueue(Cat("doggo")) assert shelter.dequeue("cat").name == "doggo"
def test_cat(): assert Dog('Dog')
def test_add_remove_one_dog(shelter): shelter.enqueue(Dog("alvin")) shelter.enqueue(Cat("barb")) assert shelter.dequeue("dog").name == "alvin"
def test_cat(): assert Dog("Peeve")
def test_shelter_dequeue_not_in_list2(): shelter = AnimalShelter() shelter.enqueue(Cat("1")) shelter.enqueue(Dog("2")) pet_adopted = shelter.dequeue('parrot') assert pet_adopted == None
def test_dog(): dog = Dog("Sam") assert dog.value == 'Sam' assert dog.type == 'dog' assert dog.next == None
def test_dog(): dog = Dog("Rex") assert dog.name == 'Rex' assert dog.type == 'dog' assert dog.next == None
def test_dog(): dog = Dog() assert dog
def test_creating_dog_object(): assert Dog().name == 'Ima dog'