示例#1
0
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
        })
示例#2
0
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
示例#3
0
def testArgsTupleDistance():
    with pytest.raises(Exception) as e:
        getDistance((0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0))
示例#4
0
def testArgsBoolDistance():
    with pytest.raises(Exception) as e:
        assert getDistance(True, False, True, False)
示例#5
0
def testArgsListDistance():
    with pytest.raises(Exception) as e:
        getDistance([0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0])
示例#6
0
def testArgsStringDistance():
    with pytest.raises(Exception) as e:
        getDistance("string", "string", "string", "string")
示例#7
0
def testArgsNoneDistance():
    with pytest.raises(Exception) as e:
        getDistance(None, None, None, None)
示例#8
0
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