Issue #5349: Submission tests fail confusingly on missing dependency
authorChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 4 Feb 2016 23:40:28 +0000 (15:40 -0800)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 4 Feb 2016 23:40:28 +0000 (15:40 -0800)
They gave a DetachedInstanceError, despite being totally unrelated to
anything in database-land!

mediagoblin/tests/test_submission.py

index 0ec49ec78614753cf8ece17f53b68015f573d0ac..9a4f4645c884e68d9fb11720797fb057c7677402 100644 (file)
@@ -52,6 +52,21 @@ FORM_CONTEXT = ['mediagoblin/submit/start.html', 'submit_form']
 REQUEST_CONTEXT = ['mediagoblin/user_pages/user.html', 'request']
 
 
+SKIP_AUDIO = False
+SKIP_VIDEO = False
+
+try:
+    import gi.repository.Gst
+except ImportError:
+    SKIP_AUDIO = True
+    SKIP_VIDEO = True
+
+try:
+    import scikits.audiolab
+except ImportError:
+    SKIP_AUDIO = True
+
+
 class TestSubmission:
     @pytest.fixture(autouse=True)
     def setup(self, test_app):
@@ -389,14 +404,20 @@ class TestSubmission:
         media = self.check_media(None, {"title": u"With GPS data"}, 1)
         assert media.get_location.position["latitude"] == 59.336666666666666
 
+    @pytest.mark.skipif(SKIP_AUDIO,
+                        reason="Dependencies for audio not met")
     def test_audio(self):
         with create_av(make_audio=True) as path:
             self.check_normal_upload('Audio', path)
 
+    @pytest.mark.skipif(SKIP_VIDEO,
+                        reason="Dependencies for video not met")
     def test_video(self):
         with create_av(make_video=True) as path:
             self.check_normal_upload('Video', path)
 
+    @pytest.mark.skipif(SKIP_AUDIO or SKIP_VIDEO,
+                        reason="Dependencies for audio or video not met")
     def test_audio_and_video(self):
         with create_av(make_audio=True, make_video=True) as path:
             self.check_normal_upload('Audio and Video', path)