def test_input_threshold_positive(): """ Test for error if threshold is negative """ try: filter_distances(point=x, data=df, threshold=-5.5) except: assert True
def test_input_threshold_numeric(): """ Test for error if input threshold is not a single value """ try: filter_distances(point=x, data=df, threshold="five") except: assert True
def test_input_threshold_single(): """ Test for error if input threshold is not a single value """ try: filter_distances(point=x, data=df, threshold=[1, 2, 3]) except: assert True
def test_input_point_list(): """ Test for error if point is not a list """ try: filter_distances(point=1, data=df, threshold=threshold) except: assert True else: assert False
def test_input_data_type(): """ Test for error if data input is not a DataFrame """ try: filter_distances(point=x, data=[1, 2, 3], threshold=threshold) except: assert True else: assert False
def test_output_ints(): """ Test that output contains ints only """ output = filter_distances(point=x, data=df, threshold=threshold) assert (all(isinstance(x, int) for x in output))
def test_output_positive(): """ Test that output contains non-negative ints (since they are indices, they cannot be negative) """ output = filter_distances(point=x, data=df, threshold=threshold) assert (all(x >= 0 for x in output))
def test_output_type(): """ Test that output is of type list """ assert (type(filter_distances(point=x, data=df, threshold=threshold)) == list)