Пример #1
0
 def test_get_nearby_checkpoints(self):
     """
     unit tests get_nearby_checkpoints
     """
     #group a
     a_user1 = self.create_saved_test_user()
     a_user2 = self.create_saved_test_user()
     self.befriend_test_user(a_user1, [a_user2])
     
     #anon users
     anon_user1 = self.create_saved_test_user()
     
     #create checkpoints in group a
     checkpoint_a_data = CheckpointTests.mock_checkpoint_data(a_user1.user_obj.id, (999.9, 999.9))
     a1_checkpoint = add_checkpoint(*checkpoint_a_data)
     a1_ucp = add_checkpoint_to_user(a_user1.user_obj, a1_checkpoint)
     
     checkpoint_b_data = CheckpointTests.mock_checkpoint_data(a_user2.user_obj.id, (-999.9, -999.9))
     a2_checkpoint = add_checkpoint(*checkpoint_b_data)
     a2_ucp = add_checkpoint_to_user(a_user2.user_obj, a2_checkpoint)
     
     checkpoint_c_data = CheckpointTests.mock_checkpoint_data(anon_user1.user_obj.id, (999.9, 999.9))
     a3_checkpoint = add_checkpoint(*checkpoint_c_data)
     a3_ucp = add_checkpoint_to_user(anon_user1.user_obj, a3_checkpoint)
     
     #verification
     friends_ucp, anon_ucp = get_nearby_checkpoints(a_user1.user_obj, (999.9, 999.9), 0.1)
     
     assert a1_ucp in friends_ucp
     assert not a2_ucp in friends_ucp
     assert a3_ucp in anon_ucp
Пример #2
0
def _checkpoints_near_me():
    """
    return checkpoints given a location, from both friends/anonymous
    as well as notifications on new comments, etc.
    """
    user_id = request.args.get("user_id")
    point_coord = float(request.args.get("latitude")), float(request.args.get("longitude"))
    radius = float(request.args.get("radius", 5))
    user = get_user(user_id) 
    
    friends_ucp, anon_ucp = get_nearby_checkpoints(user, point_coord, radius)
    notifications = get_my_notifications(user)
                                                     
    return friends_ucp, anon_ucp, notifications