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'
Пример #2
0
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"
Пример #3
0
def test_last_enqueue():
    animals = AnimalShelter()

    animals.enqueue('Cherry', 'cat')
    animals.enqueue('Oscar', 'dog')
    animals.enqueue('Bobi', 'dog')

    expected = 'Front -> Cherry -> Oscar -> Bobi -> Rear'
    actual = animals.__str__()
    assert actual == expected
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_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_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
Пример #7
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
Пример #8
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
Пример #9
0
def fixed_shelter():
    shelter = AnimalShelter()
    shelter.enqueue(Cat('Tom'))
    shelter.enqueue(Dog('Spike'))
    shelter.enqueue(Cat('Mdhat'))

    return shelter
Пример #10
0
def test_enqueu_cat_dog():
    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 = ('alex', 'Aln', 'Sherry', 'Semsem')
    actual = alex.name, aln.name, Sherry.name, Semsem.name
    assert expected == actual
def test_addeing_animal():
    new_shelter = AnimalShelter()
    new_shelter.enqueue('Oscar', 'dog')
    actual = new_shelter.dog.__str__()
    expected = 'Oscar-> None'
    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
Пример #13
0
def test_shelter_enqueue_notcar_or_dog():
    shelter = AnimalShelter()
    assert shelter.enqueue(Node('1')) == "Animal must be cat or dog"
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'
Пример #15
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'
def test_dequeue_from_empty_shelter():
    new_shelter = AnimalShelter()
    assert new_shelter.dequeue('dog') == None
def test_creating_empty_animal_shelter():
    assert AnimalShelter().front == None
Пример #18
0
def test_shelter_dequeue_empty():
    shelter = AnimalShelter()
    pet_adopted = shelter.dequeue('dog')
    assert pet_adopted == 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
Пример #20
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
Пример #21
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'
Пример #22
0
def test_enqueue():
    animals = AnimalShelter()
    animals.enqueue('Cherry', 'cat')
    expected = 'Cherry'
    actual = animals.front.name
    assert actual == expected
Пример #23
0
def test_enqueu_any_value():
    animals = AnimalShelter()
    expected = 'Add Cat or Dog Only'
    actual = animals.enqueue('any')
    assert expected == actual
Пример #24
0
def test_dequeue_None():
    animals = AnimalShelter()

    expected = 'The queue is empty'
    actual = animals.dequeue('cat')
    assert actual == expected
Пример #25
0
def test_dequeue_second_object():
    animals = AnimalShelter()

    animals.enqueue('Cherry', 'cat')
    animals.enqueue('Oscar', 'dog')
    animals.enqueue('Bobi', 'dog')

    animals.dequeue('dog')
    expected = 'Front -> Cherry -> Bobi -> Rear'
    actual = animals.__str__()
    assert actual == expected