mirror of
https://github.com/pretix/pretix.git
synced 2026-05-03 14:54:04 +00:00
Prepare the pretixdroid API for an async mode in the app
This commit is contained in:
@@ -56,6 +56,18 @@ def test_flush_key(client, env):
|
||||
env[0].settings.get('pretixdroid_key') != 'abcdefg'
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_custom_datetime(client, env):
|
||||
env[0].settings.set('pretixdroid_key', 'abcdefg')
|
||||
dt = now() - timedelta(days=1)
|
||||
resp = client.post('/pretixdroid/api/%s/%s/redeem/?key=%s' % (env[0].organizer.slug, env[0].slug, 'abcdefg'),
|
||||
data={'secret': '1234', 'datetime': dt.isoformat()})
|
||||
jdata = json.loads(resp.content.decode("utf-8"))
|
||||
assert jdata['version'] == 2
|
||||
assert jdata['status'] == 'ok'
|
||||
assert Checkin.objects.last().datetime == dt
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_only_once(client, env):
|
||||
env[0].settings.set('pretixdroid_key', 'abcdefg')
|
||||
@@ -72,6 +84,21 @@ def test_only_once(client, env):
|
||||
assert jdata['reason'] == 'already_redeemed'
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_forced_multiple(client, env):
|
||||
env[0].settings.set('pretixdroid_key', 'abcdefg')
|
||||
|
||||
resp = client.post('/pretixdroid/api/%s/%s/redeem/?key=%s' % (env[0].organizer.slug, env[0].slug, 'abcdefg'),
|
||||
data={'secret': '1234'})
|
||||
jdata = json.loads(resp.content.decode("utf-8"))
|
||||
assert jdata['version'] == 2
|
||||
assert jdata['status'] == 'ok'
|
||||
resp = client.post('/pretixdroid/api/%s/%s/redeem/?key=%s' % (env[0].organizer.slug, env[0].slug, 'abcdefg'),
|
||||
data={'secret': '1234', 'force': 'true'})
|
||||
jdata = json.loads(resp.content.decode("utf-8"))
|
||||
assert jdata['status'] == 'ok'
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_require_paid(client, env):
|
||||
env[0].settings.set('pretixdroid_key', 'abcdefg')
|
||||
@@ -120,6 +147,16 @@ def test_search(client, env):
|
||||
assert jdata['results'][0]['secret'] == '5678910'
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_download_all_data(client, env):
|
||||
env[0].settings.set('pretixdroid_key', 'abcdefg')
|
||||
resp = client.get('/pretixdroid/api/%s/%s/download/?key=%s' % (env[0].organizer.slug, env[0].slug, 'abcdefg'))
|
||||
jdata = json.loads(resp.content.decode("utf-8"))
|
||||
assert len(jdata['results']) == 2
|
||||
assert jdata['results'][0]['secret'] == '1234'
|
||||
assert jdata['results'][1]['secret'] == '5678910'
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_status(client, env):
|
||||
env[0].settings.set('pretixdroid_key', 'abcdefg')
|
||||
|
||||
Reference in New Issue
Block a user