Gift card API: Allow to inspect transactions (#1868)

This commit is contained in:
Raphael Michel
2020-12-02 16:10:05 +01:00
committed by GitHub
parent 87a514ca8b
commit 99c3981e2d
6 changed files with 130 additions and 7 deletions

View File

@@ -186,3 +186,26 @@ def test_giftcard_no_deletion(token_client, organizer, event, giftcard):
'/api/v1/organizers/{}/giftcards/{}/'.format(organizer.slug, giftcard.pk),
)
assert resp.status_code == 405
@pytest.mark.django_db
def test_giftcard_transactions(token_client, organizer, giftcard):
resp = token_client.get(
'/api/v1/organizers/{}/giftcards/{}/transactions/'.format(organizer.slug, giftcard.pk),
)
assert resp.status_code == 200
assert resp.data == {
"count": 1,
"next": None,
"previous": None,
"results": [
{
"id": giftcard.transactions.first().pk,
"datetime": giftcard.transactions.first().datetime.isoformat().replace("+00:00", "Z"),
"value": "23.00",
"event": None,
"order": None,
"text": None
}
]
}

View File

@@ -148,6 +148,8 @@ org_permission_sub_urls = [
('get', 'can_manage_gift_cards', 'giftcards/1/', 404),
('put', 'can_manage_gift_cards', 'giftcards/1/', 404),
('patch', 'can_manage_gift_cards', 'giftcards/1/', 404),
('get', 'can_manage_gift_cards', 'giftcards/1/transactions/', 404),
('get', 'can_manage_gift_cards', 'giftcards/1/transactions/1/', 404),
('get', 'can_change_organizer_settings', 'devices/', 200),
('post', 'can_change_organizer_settings', 'devices/', 400),
('get', 'can_change_organizer_settings', 'devices/1/', 404),