39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
from datetime import timedelta
|
|
|
|
from django.utils import timezone
|
|
|
|
from events.models import EventOccurrence
|
|
from tests.conftest import EventPageFactory
|
|
|
|
|
|
def test_graphql_endpoint_responds(db, graphql_post):
|
|
response, body = graphql_post("{ __schema { queryType { name } } }")
|
|
|
|
assert response.status_code == 200
|
|
assert "errors" not in body
|
|
assert body["data"]["__schema"]["queryType"]["name"] == "Query"
|
|
|
|
|
|
def test_event_index_future_events_query(event_index, graphql_post):
|
|
upcoming = EventPageFactory(parent=event_index, title="Upcoming gig")
|
|
EventOccurrence.objects.create(
|
|
event=upcoming,
|
|
start=timezone.now() + timedelta(days=3),
|
|
venue_custom="Storsalen",
|
|
)
|
|
|
|
response, body = graphql_post(
|
|
"""
|
|
query {
|
|
eventIndex {
|
|
futureEvents { title }
|
|
}
|
|
}
|
|
"""
|
|
)
|
|
|
|
assert response.status_code == 200
|
|
assert "errors" not in body, body
|
|
titles = [e["title"] for e in body["data"]["eventIndex"]["futureEvents"]]
|
|
assert "Upcoming gig" in titles
|