@@ -31,6 +31,70 @@ def setUpTestData(cls):
3131 cls .html_content = TEST_HTML_PATH .read_text ()
3232 cls .video_content = TEST_VIDEO_PATH .read_bytes ()
3333
34+ @responses .activate (assert_all_requests_are_fired = True )
35+ def test_copy_video_recording_no_cookie (self ):
36+ """
37+ Test the copy_video_recording task without cookie.
38+ """
39+ # Prepare URLs
40+ record_url = "https://example.com/recording/1234/video"
41+ playback_url = "https://example.com/playback/video/1234"
42+ html_video_url = "https://example.com/video/1234"
43+ video_file_url = f"{ html_video_url } /video-0.m4v"
44+
45+ # First redirect from record URL
46+ responses .add (
47+ responses .GET ,
48+ record_url ,
49+ status = 302 ,
50+ headers = {
51+ "Location" : playback_url ,
52+ "Content-Type" : "text/html" ,
53+ },
54+ )
55+
56+ # Second redirect to HTML video page
57+ responses .add (
58+ responses .GET ,
59+ playback_url ,
60+ status = 302 ,
61+ headers = {"Location" : html_video_url , "Content-Type" : "text/html" },
62+ )
63+
64+ # HTML video page response
65+ responses .add (
66+ responses .GET ,
67+ html_video_url ,
68+ status = 200 ,
69+ body = self .html_content ,
70+ headers = {"Content-Type" : "text/html" },
71+ )
72+
73+ # Video file response
74+ responses .add (
75+ responses .GET ,
76+ video_file_url ,
77+ status = 200 ,
78+ body = self .video_content ,
79+ headers = {"Content-Type" : "video/mp4" },
80+ )
81+
82+ video = VideoFactory ()
83+ stamp = "1640995200"
84+
85+ copy_video_recording (record_url , video .pk , stamp )
86+
87+ video .refresh_from_db ()
88+ self .assertEqual (video .upload_state , defaults .PROCESSING )
89+
90+ expected_key = f"tmp/{ str (video .pk )} /video/{ stamp } "
91+ self .assertTrue (file_storage .exists (expected_key ))
92+ with file_storage .open (expected_key , "rb" ) as video_file :
93+ self .assertEqual (
94+ video_file .read (),
95+ self .video_content ,
96+ )
97+
3498 @responses .activate (assert_all_requests_are_fired = True )
3599 def test_copy_video_recording (self ):
36100 """
0 commit comments