def test_args_dict():
    with pytest.raises(Exception) as e:
        get_dist_between_coords({
            'i': 0,
            'j': 1
        }, {
            'i': 0,
            'j': 1
        }, {
            'i': 0,
            'j': 1
        }, {
            'i': 0,
            'j': 1
        })
def get_users_within_dist(users: List[User], threshold_dist: Decimal,
                          lat: Decimal, long: Decimal) -> List[User]:
    """
    Extracts users within dist of lat, long coordinate

    Args:
        users (List[User]): list of users.
        threshold_dist (Decimal): threshold distance.
        lat (Decimal): latitude.
        long (Decimal): longitude.

    Returns:
        List[User] list of users within distance
    """

    # check lines is a list
    if not isinstance(users, list):
        if PRINT_MESSAGES: print("[ERROR] parameter is not a list")
        raise Exception("parameter is not a list")

    # no users provided
    if len(users) == 0:
        if PRINT_MESSAGES: print("[ERROR] no users provided")
        raise Exception("no users provided")

    # check threshold
    if not isinstance(threshold_dist, numbers.Number):
        if PRINT_MESSAGES: print("[ERROR] threshold is not valid")
        raise Exception("threshold is not valid")

    if threshold_dist <= 0 and threshold_dist > 40075:  # circumference of earth
        if PRINT_MESSAGES: print("[ERROR] threshold distance is not valid")
        raise Exception("threshold distance is not valid")

    # check lat and long
    if not maths_utils.check_lat_arg(lat) or not maths_utils.check_long_arg(
            long):
        if PRINT_MESSAGES:
            print("[ERROR] latitidues and longitudes are not valid")
        raise Exception("latitidues are not valid")

    invited_users = []
    for user in users:
        # calculate distance, check it is within range and add to list of invited guests
        # may throw exxception
        dist = maths_utils.get_dist_between_coords(user.latitude,
                                                   user.longitude, lat, long)

        if dist < threshold_dist:
            invited_users.append(user)

    # if there is no one in range, print message and exit
    if len(invited_users) == 0:
        if PRINT_MESSAGES: print("[ERROR] no users within distance")
        raise Exception("no users are within the distance")

    return invited_users
def test_args_list():
    with pytest.raises(Exception) as e:
        get_dist_between_coords([0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0])
def test_args_string():
    with pytest.raises(Exception) as e:
        get_dist_between_coords("string", "string", "string", "string")
def test_args_none():
    with pytest.raises(Exception) as e:
        get_dist_between_coords(None, None, None, None)
def test_same_place():
    with pytest.raises(Exception) as e:
        get_dist_between_coords(50.0, 6.25, 50.0, 6.25)
def test_zero_args():
    with pytest.raises(Exception) as e:
        get_dist_between_coords(0, 0, 0, 0)
def test_working():
    # checked using online calculator and random coords
    assert math.isclose(get_dist_between_coords(40.7486, -6.4826, -50.4826,
                                                12.5626),
                        Decimal('10313'),
                        rel_tol=0.5) == True
def test_args_tuple():
    with pytest.raises(Exception) as e:
        get_dist_between_coords((0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0))
def test_args_bool():
    with pytest.raises(Exception) as e:
        assert get_dist_between_coords(True, False, True, False)