Implement Last-Modified for a number of API resources

This commit is contained in:
Raphael Michel
2018-05-17 16:09:08 +02:00
parent 118259a96b
commit 26029508c6
12 changed files with 111 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
import time
from datetime import datetime, timedelta
from decimal import Decimal
from unittest import mock
@@ -116,6 +117,22 @@ def test_category_list(token_client, organizer, event, team, category):
assert resp.status_code == 200
assert [res] == resp.data['results']
category.log_action('foo')
resp = token_client.get('/api/v1/organizers/{}/events/{}/categories/'.format(
organizer.slug, event.slug))
assert resp.status_code == 200
lmd = resp['Last-Modified']
assert lmd
time.sleep(1)
resp = token_client.get('/api/v1/organizers/{}/events/{}/categories/'.format(
organizer.slug, event.slug), HTTP_IF_MODIFIED_SINCE=lmd)
assert resp.status_code == 304
time.sleep(1)
category.log_action('foo')
resp = token_client.get('/api/v1/organizers/{}/events/{}/categories/'.format(
organizer.slug, event.slug), HTTP_IF_MODIFIED_SINCE=lmd)
assert resp.status_code == 200
@pytest.mark.django_db
def test_category_detail(token_client, organizer, event, team, category):