def test_delete_other_users_move(user, call_endpoint):
    someone_else, _ = get_or_create_user("someone-else")
    someone_elses_trip = create_trip(created_by=someone_else, title="Foo")
    someone_elses_location_1 = create_location(someone_elses_trip, "foo", 51, 0)
    someone_elses_location_2 = create_location(someone_elses_trip, "bar", 51, 0)
    someone_elses_move = create_move(someone_elses_location_1, someone_elses_location_2)

    response = call_endpoint(user=user, move_id=someone_elses_move.move_id)
    assert response.status_code == 404
    someone_elses_move.refresh_from_db()
    assert someone_elses_move.is_deleted is False
def test_create_move_success(call_endpoint, user, trip):
    location_1 = create_location(trip, "1", 51, 0)
    location_2 = create_location(trip, "2", 51, 0)

    assert len(Move.objects.all()) == 0
    response = call_endpoint(
        user=user,
        data={
            "start_location_id": str(location_1.location_id),
            "end_location_id": str(location_2.location_id),
        },
    )
    assert response.status_code == 201
    assert 1 == len(Move.objects.all())
Ejemplo n.º 3
0
def persist_location(trip, event):
    location = create_location(
        trip=trip,
        display_name=event.display_name,
        lat=event.coords.lat,
        lng=event.coords.lng,
        google_place_id=event.google_place_id,
    )
    return Location.from_db_model(location)
def test_create_move_with_other_users_location(call_endpoint, user, trip):
    my_location = create_location(trip, "my location", 51, 0)

    someone_else, _ = get_or_create_user("someone-else")
    not_my_location = create_location(
        trip=create_trip(someone_else, "someone elses trip", "test description"),
        display_name="not my location",
        lat=51,
        lng=0,
    )

    response = call_endpoint(
        user=user,
        data={
            "start_location_id": str(my_location.location_id),
            "end_location_id": str(not_my_location.location_id),
        },
    )
    assert response.status_code == 400
    assert b"does not exist" in response.content
    assert 0 == len(Move.objects.all())
Ejemplo n.º 5
0
def test_return_trip_with_locations(user, trip):
    location = create_location(trip,
                               display_name="London",
                               lat=51.105667,
                               lng=-0.12)

    response = call_endpoint(user, trip.trip_id)
    assert response.status_code == 200
    assert {
        "trip_id":
        str(trip.trip_id),
        "title":
        "some trip",
        "created_on":
        "2019-01-01T10:00:00Z",
        "locations": [{
            "location_id": str(location.location_id),
            "display_name": "London",
            "coords": [51.105667, -0.120000],
        }],
    } == response.json()
def location_2(trip):
    return create_location(trip, "location two", lat=51, lng=0)
def location_1(trip):
    return create_location(trip, "location one", lat=51, lng=0)
Ejemplo n.º 8
0
def location(trip):
    return create_location(trip, "test location", 51, 0)
Ejemplo n.º 9
0
def location_2(trip):
    return create_location(trip, "location 2", 2.1, 2.2)
Ejemplo n.º 10
0
def location_1(trip):
    return create_location(trip,
                           "location 1",
                           1.1,
                           1.2,
                           google_place_id="goog123")