import pytest
from django.urls import reverse

from .utils import create_grouped_order

pytestmark = pytest.mark.django_db


def test_get_ical(client, other_user):
    grouped_order = create_grouped_order(
        days_before_delivery_date=5,
        days_before_deadline=2,
        name="gr order test",
        orga_user=other_user,
    )
    grouped_order.delivery_slot = "le matin"
    grouped_order.description = "apportez vos tup"
    grouped_order.save()

    detail_url = reverse(
        "order:grouped_order_event",
        kwargs={
            "code": grouped_order.code,
        },
    )
    response = client.get(detail_url)
    assert response.status_code == 200
    assert b"DTSTART" in response.content
