예제 #1
0
def test_animal_enqueue():
    """Insert only cats and dogs."""
    a = Animal_Shelter()
    assert a.enqueue('dog') == 'dog'
    assert a.enqueue('cat') == 'cat'
    with pytest.raises(TypeError):
        a.enqueue('bird')
예제 #2
0
def test_dequeue_empty_shelter():
    shelter = Animal_Shelter()

    expected = None
    actual = shelter.dequeue('cat')

    assert actual == expected
def default_shelter():
	animal_shelter = Animal_Shelter()
	animal_shelter.welcome_in('dog')
	animal_shelter.welcome_in('cat')
	animal_shelter.welcome_in('cat')
	animal_shelter.welcome_in('cat')
	animal_shelter.welcome_in('dog')
	animal_shelter.welcome_in('dog')
	animal_shelter.welcome_in('cat')
	return animal_shelter
def test_Animal_Shelter_no_dogs():
	animal_shelter = Animal_Shelter()
	animal_shelter.welcome_in('cat')
	animal_shelter.welcome_in('cat')
	animal_shelter.welcome_in('cat')
	animal_shelter.welcome_in('cat')
	assert animal_shelter.adoption_out('dog') == 'There are no dogs left.'
예제 #5
0
def test_enqueue_three_full_hold1_rear():
    shelter = Animal_Shelter()
    shelter.enqueue('dog')
    shelter.enqueue('dog')
    shelter.enqueue('cat')

    assert shelter.Hold1.rear.value == 'cat'
def test_Animal_Shelter_nothing_to_adopt():
	animal_shelter = Animal_Shelter()
	with pytest.raises(InvalidOperationError):
		animal_shelter.adoption_out('dog')
def test_Animal_Shelter_wrong_animal_requested():
	animal_shelter = Animal_Shelter()
	with pytest.raises(InvalidOperationError):
		animal_shelter.adoption_out('penguin')
def test_Animal_Shelter_wrong_animal_given():
	animal_shelter = Animal_Shelter()
	with pytest.raises(InvalidOperationError):
		animal_shelter.welcome_in('penguin')
예제 #9
0
def test_class_instantiation():
    assert Animal_Shelter()
예제 #10
0
def test_enqueue_one_empty_hold1():
    shelter = Animal_Shelter()
    shelter.enqueue('dog')

    assert shelter.Hold1.front.value == 'dog'
예제 #11
0
def shelter():
    return Animal_Shelter()
예제 #12
0
def test_shelter():
    assert Animal_Shelter()
예제 #13
0
def test_animal_dequeue():
    """Remove by preference or first by default."""
    a = Animal_Shelter()
    a.enqueue('dog') == 'dog'
    a.enqueue('cat') == 'cat'
    a.enqueue('cat') == 'cat'
    a.enqueue('cat') == 'cat'
    a.enqueue('dog') == 'dog'
    assert a.dequeue() == 'dog'
    assert a.dequeue() == 'cat'
    assert a.dequeue('dog') == 'dog'
    assert a.dequeue('cat') == 'cat'
    assert a.dequeue() == 'cat'
    assert a.dequeue() is None