def testArgsDictDistance(): with pytest.raises(Exception) as e: getDistance({ 'i': 0, 'j': 1 }, { 'i': 0, 'j': 1 }, { 'i': 0, 'j': 1 }, { 'i': 0, 'j': 1 })
def getPeopleWithinThreshold(people, threshold, latitude, longitude): """ Processes people and returns people within threshold distance of input latitude and longitude coordinates args: people(list[Person]): list of person threshold (decimal): threshold distance latitude(decimal): Dublin latitude longitude(decimal): Dublin longitude output: invitedPeople (list[Person]): list of person within threshold """ if not isinstance(threshold, Number): raise Exception("threshold is invalid") invitedPeople = list() for being in people: dist = mathUtils.getDistance(latitude, longitude, being.latitude, being.longitude) if dist < threshold: invitedPeople.append(being) return invitedPeople
def testArgsTupleDistance(): with pytest.raises(Exception) as e: getDistance((0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0))
def testArgsBoolDistance(): with pytest.raises(Exception) as e: assert getDistance(True, False, True, False)
def testArgsListDistance(): with pytest.raises(Exception) as e: getDistance([0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0])
def testArgsStringDistance(): with pytest.raises(Exception) as e: getDistance("string", "string", "string", "string")
def testArgsNoneDistance(): with pytest.raises(Exception) as e: getDistance(None, None, None, None)
def testWorkingDistance(): # checked using online calculator and random coords assert math.isclose(getDistance(44.4523, -14.4543, -55.453, 24.2345), Decimal('10782'), rel_tol=0.5) == True