from typing import Any

from django.test import TestCase
from django.urls import reverse


class GraphQLPaymentsTests(TestCase):
    def graphql(self, query: str, variables: dict | None = None):
        url = reverse("graphql-platform")
        payload: dict[str, Any] = {"query": query}
        if variables:
            payload["variables"] = variables
        response = self.client.post(url, data=payload, content_type="application/json")
        self.assertEqual(response.status_code, 200, response.json())
        return response.json()
