0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-30 19:41:46 +01:00
posthog/ee/api/test/base.py
2021-03-31 19:00:58 -07:00

30 lines
877 B
Python

from typing import Optional, cast
from django.utils import timezone
from ee.models.license import License, LicenseManager
from posthog.test.base import APIBaseTest
class LicensedTestMixin:
"""
Test API using Django REST Framework test suite, for licensed PostHog (mainly enterprise edition).
"""
CONFIG_LICENSE_PLAN: Optional[str] = "enterprise"
license: License = None # type: ignore
@classmethod
def setUpTestData(cls):
super().setUpTestData() # type: ignore
if cls.CONFIG_LICENSE_PLAN:
cls.license = super(LicenseManager, cast(LicenseManager, License.objects)).create(
key=cls.CONFIG_LICENSE_PLAN,
plan=cls.CONFIG_LICENSE_PLAN,
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
)
class APILicensedTest(LicensedTestMixin, APIBaseTest):
pass