OpenSlides/tests/integration/mediafiles/test_viewset.py
Oskar Hahn 10b3bb6497 Update to channels 2
* geis does not work with channels2 and never will be (it has to be python now)
* pytest
* rewrote cache system
* use username instead of pk for admin user in tests
2018-08-22 06:30:11 +02:00

23 lines
647 B
Python

import pytest
from django.core.files.uploadedfile import SimpleUploadedFile
from openslides.mediafiles.models import Mediafile
from ..helpers import count_queries
@pytest.mark.django_db(transaction=False)
def test_mediafiles_db_queries():
"""
Tests that only the following db queries are done:
* 1 requests to get the list of all files.
"""
for index in range(10):
Mediafile.objects.create(
title='some_file{}'.format(index),
mediafile=SimpleUploadedFile(
'some_file{}'.format(index),
b'some content.'))
assert count_queries(Mediafile.get_elements) == 1