예제 #1
0
def test_dequeue_first_object():
    animals = AnimalShelter()

    animals.enqueue('Cherry', 'cat')
    animals.enqueue('Oscar', 'dog')
    animals.enqueue('Bobi', 'dog')
    animals.dequeue('Cat')
    expected = 'Front -> Oscar -> Bobi -> Rear'
    actual = animals.__str__()
    assert actual == expected
def test_dequeue_works_correctly_there_is_dogs_and_cats():
    new_shelter = AnimalShelter()
    new_shelter.enqueue('Oscar', 'dog')
    new_shelter.enqueue('Sherry', 'cat')
    actual = new_shelter.dequeue('dog')
    expected = 'Oscar'
    assert expected == actual
def test_dequeue_and_enqueue():
    mylo = Dog('mylo')
    reixy = Dog('mylo')
    luna = Dog('luna')
    kitty = Cat('kitty')
    lily = Cat('lily')
    a = AnimalShelter()
    a.enqueue(mylo)
    a.enqueue(reixy)
    a.enqueue(luna)
    a.enqueue(kitty)
    a.enqueue(lily)

    assert a.dequeue('cat') == 'kitty'
    assert a.dequeue('cat') == 'lily'
    assert a.dequeue('dog') == 'mylo'
    assert a.dequeue('dog') == 'mylo'
    assert a.dequeue('dog') == 'luna'
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'
예제 #6
0
def test_dequeue_any():
    animals = AnimalShelter()
    aln = Dog('Aln')
    Sherry = Cat('Sherry')
    animals.enqueue(aln)
    animals.enqueue(Sherry)

    expected = None
    actual = animals.dequeue('any')
    assert expected == actual
예제 #7
0
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'
예제 #8
0
def test_dequeue_cat():
    animals = AnimalShelter()
    alex = Dog('alex')
    aln = Dog('Aln')
    Sherry = Cat('Sherry')
    Semsem = Cat('Semsem')
    animals.enqueue(alex)
    animals.enqueue(aln)
    animals.enqueue(Sherry)
    animals.enqueue(Semsem)

    expected = 'Sherry'
    actual = animals.dequeue('cat')
    assert expected == actual
def test_dequeue_to_a_value_other_than_cat_or_dog():
    new_shelter = AnimalShelter()
    actual = new_shelter.dequeue('potato')
    expected = None
    assert expected == actual
def test_dequeue_from_empty_shelter():
    new_shelter = AnimalShelter()
    assert new_shelter.dequeue('dog') == None
def test_dequeue_one_animal_from_shelter():
    new_shelter = AnimalShelter()
    new_shelter.enqueue('dog')
    assert new_shelter.dequeue('dog').name == 'Ima dog'
    assert new_shelter.front == None
예제 #12
0
def test_dequeue_None():
    animals = AnimalShelter()

    expected = 'The queue is empty'
    actual = animals.dequeue('cat')
    assert actual == expected
예제 #13
0
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'
예제 #14
0
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
예제 #15
0
def test_shelter_dequeue_empty():
    shelter = AnimalShelter()
    pet_adopted = shelter.dequeue('dog')
    assert pet_adopted == None