diff --git a/tests/test_api.py b/tests/test_api.py index cdfdce2..1f6435c 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -424,7 +424,7 @@ def test_storage_error(app, partner_southpark, cut_kevin_uuid, acl, caplog): app.get(url, status=500) -def test_concurrent_put(app, transactional_db): +def test_concurrent_put(app, transactional_db, settings): '''Test concurrent PUT to the same key''' from utils import create_cut, create_partner, create_service, create_acl_record @@ -438,22 +438,23 @@ def test_concurrent_put(app, transactional_db): payload = json.loads(force_text(get_tests_file_content('books.json'))) url = '/api/%s/%s/loans/' % (southpark.name, uuid) - pool_count = 40 - put_count = 60 + pool_count = 5 + put_count = 100 + + response = app.put_json(url, params=payload) + assert response.status_code == 201 pool = ThreadPool(pool_count) def f(i): from django.db import connection if i % 2 == 0: - headers = {'If-None-Match': '*'} + response = app.get(url, status=200) else: - headers = {} - - response = app.put_json(url, params=payload, headers=headers, status='*') - assert response.status_code in (412, 201, 200) + response = app.put_json(url, params=payload, status=200) connection.close() - return i, response.status_code + return i - l = pool.map(f, range(put_count)) - assert len(l) == put_count + results = pool.map(f, range(put_count)) + assert len(results) == put_count + assert sum(len(files) for _, _, files in os.walk(settings.MEDIA_ROOT)) == 1