2018-07-09 23:22:26 +02:00
|
|
|
import pytest
|
2016-09-18 16:00:31 +02:00
|
|
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
|
|
|
|
|
|
|
from openslides.mediafiles.models import Mediafile
|
|
|
|
|
2018-07-09 23:22:26 +02:00
|
|
|
from ..helpers import count_queries
|
2016-09-18 16:00:31 +02:00
|
|
|
|
|
|
|
|
2018-07-09 23:22:26 +02:00
|
|
|
@pytest.mark.django_db(transaction=False)
|
|
|
|
def test_mediafiles_db_queries():
|
2016-09-18 16:00:31 +02:00
|
|
|
"""
|
2018-07-09 23:22:26 +02:00
|
|
|
Tests that only the following db queries are done:
|
2019-04-23 16:57:35 +02:00
|
|
|
* 1 requests to get the list of all files
|
|
|
|
* 1 request to get all lists of speakers.
|
2018-07-09 23:22:26 +02:00
|
|
|
"""
|
|
|
|
for index in range(10):
|
|
|
|
Mediafile.objects.create(
|
2019-01-12 23:01:42 +01:00
|
|
|
title=f"some_file{index}",
|
|
|
|
mediafile=SimpleUploadedFile(f"some_file{index}", b"some content."),
|
2019-01-06 16:22:33 +01:00
|
|
|
)
|
2016-09-18 16:00:31 +02:00
|
|
|
|
2019-04-23 16:57:35 +02:00
|
|
|
assert count_queries(Mediafile.get_elements) == 2
|