Пример #1
0
def test_AnimalShelter_enqueue_Exception():
    with pytest.raises(Exception):
        shelter = AnimalShelter()
        cookie = Bird('Cookie')
        actual = shelter.enqueue(cookie)
        expected = 'We can only accept a cat or a dog.'
        assert actual == expected
Пример #2
0
def test_AnimalShelter_enqueue_Dog():
    shelter = AnimalShelter()
    oliver = Dog('Oliver')
    shelter.enqueue(oliver)
    actual = str(shelter)
    expected = '[dog: Oliver] <- None'
    assert actual == expected
Пример #3
0
def test_AnimalShelter_enqueue_Dog():
    shelter = AnimalShelter()
    oliver = Dog('Oliver')
    shelter.enqueue(oliver)
    actual = shelter.peek()
    expected = oliver
    assert actual == expected
Пример #4
0
def test_AnimalShelter_enqueue_Dog_Cat():
    shelter = AnimalShelter()
    oliver = Dog('Oliver')
    cheeto = Cat('Cheeto')
    shelter.enqueue(oliver)
    shelter.enqueue(cheeto)
    actual = str(shelter)
    expected = '[dog: Oliver] <- [cat: Cheeto] <- None'
    assert actual == expected
Пример #5
0
def test_AnimalShelter_dequeue_pref_dog():
    shelter = AnimalShelter()
    cheeto = Cat('Cheeto')
    oliver = Dog('Oliver')
    shelter.enqueue(cheeto)
    shelter.enqueue(oliver)
    actual = shelter.dequeue('dog')
    expected = 'cat'
    assert actual == expected
Пример #6
0
def test_AnimalShelter_dequeue_pref_not_catOrDog():
    shelter = AnimalShelter()
    cheeto = Cat('Cheeto')
    oliver = Dog('Oliver')
    shelter.enqueue(cheeto)
    shelter.enqueue(oliver)
    actual = shelter.dequeue('bird')
    expected = None
    assert actual == expected
Пример #7
0
def test_AnimalShelter_enqueue_Cat():
    shelter = AnimalShelter()
    cheeto = Cat('Cheeto')
    oliver = Dog('Oliver')
    shelter.enqueue(cheeto)
    shelter.enqueue(oliver)
    actual = shelter.peek()
    expected = cheeto
    assert actual == expected
Пример #8
0
def ash():
    ash = AnimalShelter()
    ash.enqueue("dog", "Lucky")
    ash.enqueue("cat", "Queen")
    ash.enqueue("rabbit", "Jo")
    ash.enqueue("dog", "Happy")
    ash.enqueue("cat", "Jack")
    ash.enqueue("snake", "King")
    return ash
Пример #9
0
def test_AnimalShelter_dequeue_cat_first():
    shelter = AnimalShelter()
    oliver = Dog('Oliver')
    cheeto = Cat('Cheeto')
    shelter.enqueue(cheeto)
    shelter.enqueue(oliver)
    actual = shelter.dequeque('cat')
    expected = 'Cheeto'
    assert actual == expected
Пример #10
0
def test_AnimalShelter_dequeue_dog_not_first():
    shelter = AnimalShelter()
    oliver = Dog('Oliver')
    cheeto = Cat('Cheeto')
    sneakers = Cat('Sneakers')
    shelter.enqueue(cheeto)
    shelter.enqueue(sneakers)
    shelter.enqueue(oliver)
    actual = shelter.dequeque('dog')
    expected = 'Oliver'
    assert actual == expected
Пример #11
0
def test_animalshelter_instantiate_empty():
    ash = AnimalShelter()
    actual = ash._dog_shelter.isEmpty() and ash._cat_shelter.isEmpty() and ash._others_shelter.isEmpty()
    expected = True
    assert actual == expected
Пример #12
0
def test_animalshelter_isEmpty_True():
    ash = AnimalShelter()
    actual = ash.isEmpty()
    expected = True
    assert actual == expected
Пример #13
0
def test_animalshelter_import():
    assert AnimalShelter()
Пример #14
0
def test_animalshelter_enqueue_other():
    ash = AnimalShelter()
    ash.enqueue("rabbit", "Jo")
    actual = str(ash._others_shelter)
    expected = "{rabbit-Jo} -> NULL"
    assert actual == expected
Пример #15
0
def test_animalshelter_enqueue_cat():
    ash = AnimalShelter()
    ash.enqueue("cat", "Queen")
    actual = str(ash._cat_shelter)
    expected = "{Queen} -> NULL"
    assert actual == expected
Пример #16
0
def test_AnimalShelter_enqueue_something():
    shelter = AnimalShelter()
    shelter.enqueue('something')
    actual = shelter.peek()
    expected = 'something'
    assert actual == expected
Пример #17
0
def test_AnimalShelter_dequeue_alternating():
    shelter = AnimalShelter()
    oliver = Dog('Oliver')
    cheeto = Cat('Cheeto')
    poncho = Dog('Poncho')
    sneakers = Cat('Sneakers')
    peso = Dog('Peso')
    shelter.enqueue(oliver)
    shelter.enqueue(poncho)
    shelter.enqueue(cheeto)
    shelter.enqueue(sneakers)
    shelter.enqueue(peso)
    actual = shelter.dequeque('cat')
    expected = 'Cheeto'

    assert actual == expected
Пример #18
0
def test_animalshelter_enqueue_dog():
    ash = AnimalShelter()
    ash.enqueue("dog", "Lucky")
    actual = str(ash._dog_shelter)
    expected = "{Lucky} -> NULL"
    assert actual == expected