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