mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
API-level tests
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
from django.utils.timezone import now
|
||||
from pytz import UTC
|
||||
from rest_framework.test import APIClient
|
||||
|
||||
from pretix.base.models import Event, Organizer, Team, User
|
||||
from pretix.base.models import Device, Event, Organizer, Team, User
|
||||
from pretix.base.models.devices import generate_api_token
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -69,6 +71,17 @@ def team(organizer):
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def device(organizer):
|
||||
return Device.objects.create(
|
||||
organizer=organizer,
|
||||
all_events=True,
|
||||
name='Foo',
|
||||
initialized=now(),
|
||||
api_token=generate_api_token()
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user():
|
||||
return User.objects.create_user('dummy@dummy.dummy', 'dummy')
|
||||
@@ -96,6 +109,12 @@ def token_client(client, team):
|
||||
return client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def device_client(client, device):
|
||||
client.credentials(HTTP_AUTHORIZATION='Device ' + device.api_token)
|
||||
return client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def subevent(event, meta_prop):
|
||||
event.has_subevents = True
|
||||
|
||||
Reference in New Issue
Block a user