mirror of
https://github.com/mediacms-io/mediacms.git
synced 2024-11-07 08:54:36 +01:00
parent
2ce8dba163
commit
32e07035f3
@ -3,6 +3,7 @@ from __future__ import absolute_import
|
||||
import os
|
||||
|
||||
from celery import Celery
|
||||
from django.conf import settings
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cms.settings")
|
||||
app = Celery("cms")
|
||||
@ -14,5 +15,8 @@ app.conf.beat_schedule = app.conf.CELERY_BEAT_SCHEDULE
|
||||
app.conf.broker_transport_options = {"visibility_timeout": 60 * 60 * 24} # 1 day
|
||||
# http://docs.celeryproject.org/en/latest/getting-started/brokers/redis.html#redis-caveats
|
||||
|
||||
# setting this to settings.py file only is not respected. Setting here too
|
||||
app.conf.task_always_eager = settings.CELERY_TASK_ALWAYS_EAGER
|
||||
|
||||
|
||||
app.conf.worker_prefetch_multiplier = 1
|
||||
|
BIN
fixtures/medium_video.mp4
Normal file
BIN
fixtures/medium_video.mp4
Normal file
Binary file not shown.
BIN
fixtures/small_video.mp4
Normal file
BIN
fixtures/small_video.mp4
Normal file
Binary file not shown.
BIN
fixtures/test_image.png
Normal file
BIN
fixtures/test_image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
@ -4,7 +4,7 @@ import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cms.settings")
|
||||
os.environ.setdefault("TESTING", "True")
|
||||
# os.environ.setdefault("TESTING", "True")
|
||||
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
|
@ -1,9 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class TestX(TestCase):
|
||||
fixtures = ["fixtures/categories.json", "fixtures/encoding_profiles.json"]
|
||||
|
||||
def test_X(self):
|
||||
# add new file, check it is added and more (eg for videos it is transcoded etc)
|
||||
pass
|
39
tests/api/test_new_media.py
Normal file
39
tests/api/test_new_media.py
Normal file
@ -0,0 +1,39 @@
|
||||
import uuid
|
||||
|
||||
from django.test import Client, TestCase
|
||||
|
||||
from files.models import Encoding, Media
|
||||
from files.tests import create_account
|
||||
|
||||
API_V1_LOGIN_URL = '/api/v1/login'
|
||||
|
||||
|
||||
class TestX(TestCase):
|
||||
fixtures = ["fixtures/categories.json", "fixtures/encoding_profiles.json"]
|
||||
|
||||
def setUp(self):
|
||||
self.password = 'this_is_a_fake_password'
|
||||
self.user = create_account(password=self.password)
|
||||
|
||||
def test_file_upload(self):
|
||||
client = Client()
|
||||
client.login(username=self.user, password=self.password)
|
||||
|
||||
# use both ways, form + API to upload a new media file
|
||||
# ffmpeg will transcode files synchronously
|
||||
with open('fixtures/small_video.mp4', 'rb') as fp:
|
||||
client.post('/api/v1/media', {'title': 'small video file test', 'media_file': fp})
|
||||
|
||||
with open('fixtures/test_image.png', 'rb') as fp:
|
||||
client.post('/api/v1/media', {'title': 'image file test', 'media_file': fp})
|
||||
|
||||
with open('fixtures/medium_video.mp4', 'rb') as fp:
|
||||
client.post('/fu/upload/', {'qqfile': fp, 'qqfilename': 'medium_video.mp4', 'qquuid': str(uuid.uuid4())})
|
||||
|
||||
self.assertEqual(Media.objects.all().count(), 3, "Problem with file upload")
|
||||
self.assertEqual(Media.objects.filter(state='public').count(), 3, "Expected all media to be public, as per the default portal workflow")
|
||||
self.assertEqual(Media.objects.filter(media_type='video', encoding_status='success').count(), 2, "Encoding did not finish well")
|
||||
self.assertEqual(Media.objects.filter(media_type='video').count(), 2, "Media identification failed")
|
||||
self.assertEqual(Media.objects.filter(media_type='image').count(), 1, "Media identification failed")
|
||||
self.assertEqual(Media.objects.filter(user=self.user).count(), 3, "User assignment failed")
|
||||
self.assertEqual(Encoding.objects.filter(status='success').count(), 9, "Not all video transcodings finished well")
|
Loading…
Reference in New Issue
Block a user