From b54ef76881085b1c0d8dd6b2f7842c718149638c Mon Sep 17 00:00:00 2001 From: Bastiaan Welmers Date: Thu, 7 May 2020 22:51:06 +0200 Subject: [PATCH] Stub video page view test --- tests/videodinges/views/test_video.py | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/videodinges/views/test_video.py diff --git a/tests/videodinges/views/test_video.py b/tests/videodinges/views/test_video.py new file mode 100644 index 0000000..655d20f --- /dev/null +++ b/tests/videodinges/views/test_video.py @@ -0,0 +1,59 @@ +""" Test video page """ +from django.http import HttpResponse +from django.test import TestCase, Client +from django.urls import reverse + +from tests.videodinges import factories +from videodinges import models + + +class VideoTestCase(TestCase): + def setUp(self): + self.client = Client() + + def test_video(self): + + video = factories.create( + models.Video, + title='Vid 1', + slug='vid-1', + ) + transcoding1 = factories.create( + models.Transcoding, + video=video, + quality='480p', + type='video/webm', + url='http://480p.webm', + ) + transcoding2 = factories.create( + models.Transcoding, + video=video, + quality='480p', + type='video/mp4', + url='http://480p.mp4', + ) + transcoding3 = factories.create( + models.Transcoding, + video=video, + quality='720p', + type='video/webm', + url='http://720p.webm', + ) + transcoding4 = factories.create( + models.Transcoding, + video=video, + quality='720p', + type='video/mp4', + url='http://720p.mp4', + ) + + resp:HttpResponse = self.client.get(reverse('video', args=['vid-1'])) + content:str = resp.content.decode(resp.charset) + # TODO: parse HTML, check for essential elements + self.assertEqual(resp.status_code, 200) + self.assertContains(resp, 'Vid 1') + #self.assertContains(resp, '') + #self.assertRegexpMatches(resp.content) + + #self.assertContains(resp, 'Vid 2') + #self.assertContains(resp, 'vid-2.html')