CSC108-Fall-2022-A3 / test_a3.py
test_a3.py
Raw
""" Tests to test function get_bigger_neighbourhood in a3.py """
from a3 import get_bigger_neighbourhood as gbn
from a3 import SAMPLE_DATA
from a3 import SAMPLE_DATA_2


def test_first_bigger() -> None:
    """Test that test_first_bigger correctly returns the first neighbourhood
    when its population is strictly greater than the population of the second
    neighbourhood.
    """
    result = gbn(SAMPLE_DATA, 'Rexdale-Kipling', 'Elms-Old Rexdale')
    assert result == 'Rexdale-Kipling'

def test_second_bigger() -> None:
    """Test that test_second_bigger correctly returns the second neighbourhood when its population is strictly greater than neighbourhood.
    """
    result = gbn(SAMPLE_DATA, 'Mount Olive-Silverstone-Jamestown', 'West Humber-Clairville')
    assert result == 'West Humber-Clairville'

def test_first_not_in_data() -> None:
    """Test that the test_first_not_in_data correctly returns the second neighbourhood since the first neighbourhood's population would be assumed to be 0.
    """
    result = gbn(SAMPLE_DATA, 'Test Neighbourhood', 'Thistletown-Beaumond Heights')
    assert result == 'Thistletown-Beaumond Heights'

def test_second_not_in_data() -> None:
    """Test that the test_first_not_in_data correctly returns the first neighbourhood since the second neighbourhood's population would be assumed to be 0.
    """
    result = gbn(SAMPLE_DATA, 'Rexdale-Kipling', 'Test Neighbourhood')
    assert result == 'Rexdale-Kipling'

def test_both_not_in_data() -> None:
    """Test that the test_both_not_in_data correctly returns neighbourhood 1 since they would both have a population of 0.
    """
    result = gbn(SAMPLE_DATA, 'Test Neighbourhood 1', 'Test Neighbourhood 2') 
    assert result == 'Test Neighbourhood 1' 

def test_both_same_size() -> None:
    """Test that the test_both_same_size correctly returns neighbourhood_1.
    """
    result = gbn(SAMPLE_DATA_2, 'Rexdale-Kipling', 'Rexdale-Kipling TWO') 
    assert result == 'Rexdale-Kipling'


    

if __name__ == '__main__':
    import pytest
    pytest.main(['test_a3.py'])