def test_dequeue_two_cats(): shelter = AnimalShelter() shelter.enqueue('cat') shelter.enqueue('cat') shelter.dequeue('cat') shelter.dequeue('cat') assert not shelter.cats.front and not shelter.cats.rear
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_dequeue_two_dogs(): shelter = AnimalShelter() shelter.enqueue('dog') shelter.enqueue('dog') shelter.dequeue('dog') shelter.dequeue('dog') assert not shelter.dogs.front and not shelter.dogs.rear
def test_enqueue_dog(): shelter1 = AnimalShelter('shelter1') dog1 = Dog('dog1') dog2 = Dog('dog2') shelter1.enqueue(dog1) shelter1.enqueue(dog2) assert shelter1
def test_returns_none_if_no_preference(): q = AnimalShelter() q.enqueue("dog") q.enqueue("cat") q.enqueue("dog") actual = q.dequeue() expected = None assert actual == expected
def test_shelter_enq_deq(): shelter = AnimalShelter() shelter.enqueue(Animal(AnimalType.CAT)) animal = shelter.dequeue() expected = '{"animaltype": 1}' actual = animal.serialize() assert actual == expected
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_dequeue_returns_prefered_cat(): q = AnimalShelter() q.enqueue("dog") q.enqueue("cat") q.enqueue("dog") actual = q.dequeue("cat") expected = 'cat' assert actual == expected
def test_if_dog_dequeue(): animal = AnimalShelter() animal.enqueue("cat") animal.enqueue("dog") animal.enqueue("cat") actual = animal.dequeue("dog") expected = "dog" assert actual == expected
def test_enqueue_cat(): a = AnimalShelter() a.enqueue("dog") a.enqueue("dog") a.enqueue("cat") a.enqueue("cat") actual = a.cat_shelter.peek() expected = "cat" assert actual == expected
def test_enqueue_nodog(): a = AnimalShelter() a.enqueue("dog") a.enqueue("dog") # a.enqueue("cat") # a.enqueue("cat") actual = a.cat_shelter.peek() expected = 'empty queue' assert actual == expected
def test_dequeue_dog(): a = AnimalShelter() a.enqueue("dog") a.enqueue("dog") a.enqueue("cat") a.enqueue("cat") actual = a.dequeue("cat") expected = "cat" assert actual == expected
def test_dequeue_pin(): a = AnimalShelter() a.enqueue("dog") a.enqueue("dog") a.enqueue("cat") a.enqueue("cat") actual = a.dequeue("pineapple") expected = None assert actual == expected
def test_dequeue_cat(): shelter1 = AnimalShelter('shelter1') cat1 = Cat('cat1') cat2 = Cat('cat2') cat3 = Cat('cat3') shelter1.enqueue(cat1) shelter1.enqueue(cat2) shelter1.enqueue(cat3) assert shelter1.dequeue('cat').name == 'cat1'
def test_shelter_deq_pref_notfound(): shelter = AnimalShelter() # Inc 10 (ALTERNATING) shelter.enqueue(Animal(AnimalType.CAT)) shelter.enqueue(Animal(AnimalType.CAT)) shelter.enqueue(Animal(AnimalType.CAT)) actual = shelter.dequeue(AnimalType.DOG) expected = None assert actual == expected
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 helper_shelter_enq10(): shelter = AnimalShelter() # Inc 10 (ALTERNATING) shelter.enqueue(Animal(AnimalType.CAT)) shelter.enqueue(Animal(AnimalType.DOG)) shelter.enqueue(Animal(AnimalType.CAT)) shelter.enqueue(Animal(AnimalType.DOG)) shelter.enqueue(Animal(AnimalType.CAT)) shelter.enqueue(Animal(AnimalType.DOG)) shelter.enqueue(Animal(AnimalType.CAT)) shelter.enqueue(Animal(AnimalType.DOG)) shelter.enqueue(Animal(AnimalType.CAT)) shelter.enqueue(Animal(AnimalType.DOG)) return shelter
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_enqueue_many_to_animal_shelter(): new_shelter = AnimalShelter() new_shelter.enqueue('dog') new_shelter.enqueue('cat') new_shelter.enqueue('cat') new_shelter.enqueue('cat') new_shelter.enqueue('cat') assert new_shelter.front.name == 'Ima dog'
def test_dequeue_cat_from_shelter_of_many(): new_shelter = AnimalShelter() new_shelter.enqueue('dog') new_shelter.enqueue('cat') new_shelter.enqueue('cat') new_shelter.enqueue('cat') new_shelter.enqueue('cat') new_shelter.enqueue('dog') assert new_shelter.dequeue('cat').name == 'Ima cat'
def test_dequeue_first_from_shelter_no_preference(): new_shelter = AnimalShelter() new_shelter.enqueue('dog') new_shelter.enqueue('cat') new_shelter.enqueue('cat') new_shelter.enqueue('cat') new_shelter.enqueue('cat') new_shelter.enqueue('dog') assert new_shelter.dequeue().name == 'Ima dog' assert new_shelter.front.name == 'Ima cat'
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_deq_pref_found(): shelter = AnimalShelter() # Inc 10 (ALTERNATING) shelter.enqueue(Animal(AnimalType.CAT)) shelter.enqueue(Animal(AnimalType.CAT)) shelter.enqueue(Animal(AnimalType.CAT)) shelter.enqueue(Animal(AnimalType.DOG)) shelter.enqueue(Animal(AnimalType.DOG)) animal = shelter.dequeue(AnimalType.DOG) actual = animal.serialize() expected = '{"animaltype": 2}' assert actual == expected
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(): 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_enqueue_cat(): q = AnimalShelter() q.enqueue("cat") actual = q.cats.peek() expected = "cat" assert actual == expected
def test_if_dog_enqueue(): animal = AnimalShelter() animal.enqueue("dog") assert animal.dog_queue.front
def test_enqueue_dog(): q = AnimalShelter() q.enqueue("dog") actual = q.dogs.peek() expected = "dog" assert actual == expected
def test_enqueue_dog_does_not_put_cats_in_dog_queue(): q = AnimalShelter() q.enqueue("cat") actual = q.dogs.is_empty() expected = True assert actual == expected
def test_enqueue_cat_does_not_put_dogs_in_cat_queue(): q = AnimalShelter() q.enqueue("dog") actual = q.cats.is_empty() expected = True assert actual == expected