Add test for get_all_media()
authorvijeth-aradhya <vijthaaa@gmail.com>
Wed, 16 Aug 2017 16:21:55 +0000 (21:51 +0530)
committervijeth-aradhya <vijthaaa@gmail.com>
Wed, 16 Aug 2017 16:22:22 +0000 (21:52 +0530)
Check for it's returned values.

mediagoblin/tests/test_submission.py

index ff45b107038454fa4b24828dd7443a2583558c5f..d346e0c6cef9cd5e846da4ac5cf8692b9b9ba285 100644 (file)
@@ -55,7 +55,7 @@ from celery import Signature
 from mediagoblin.tests.tools import (
     fixture_add_user, fixture_add_collection, get_app)
 from mediagoblin import mg_globals
-from mediagoblin.db.models import MediaEntry, User, LocalUser, Activity
+from mediagoblin.db.models import MediaEntry, User, LocalUser, Activity, MediaFile
 from mediagoblin.db.base import Session
 from mediagoblin.tools import template
 from mediagoblin.media_types.image import ImageMediaManager
@@ -561,6 +561,25 @@ class TestSubmissionVideo(BaseTestSubmission):
         for each_res in video_config['available_resolutions']:
             assert (('webm_' + str(each_res)) in media.media_files)
 
+        result = media.get_all_media()
+        if result[0][0] == 'default':
+            media_file = MediaFile.query.filter_by(media_entry=media.id,
+                                                   name=('webm_video')).first()
+            assert len(result) == 1
+            assert len(result[0]) == 3
+            assert result[0][1] == list(ACCEPTED_RESOLUTIONS['webm'])
+            assert result[0][2] == media_file.file_path
+        else:
+            assert len(result) == len(video_config['available_resolutions'])
+            for i in range(len(video_config['available_resolutions'])):
+                assert len(result[i]) == 3
+                media_file = MediaFile.query.filter_by(media_entry=media.id,
+                                                        name=('webm_'+str(result[i][0]))).first()
+                assert result[i][0] == video_config['available_resolutions'][i]
+                assert result[i][1] == list(ACCEPTED_RESOLUTIONS[
+                                            video_config['available_resolutions'][i]])
+                assert result[i][2] == media_file.file_path
+
     @mock.patch('mediagoblin.media_types.video.processing.processing_cleanup.signature')
     @mock.patch('mediagoblin.media_types.video.processing.complimentary_task.signature')
     @mock.patch('mediagoblin.media_types.video.processing.main_task.signature')