@@ -438,6 +438,7 @@ def test_duration_invalid(self):
438
438
def test_duration_missing (self ):
439
439
del self .file ["duration" ]
440
440
self .file ["file_format" ] = file_formats .EPUB
441
+ self .file ["preset" ] = format_presets .EPUB
441
442
442
443
self .client .force_authenticate (user = self .user )
443
444
response = self .client .post (
@@ -461,9 +462,23 @@ def test_duration_missing_but_required(self):
461
462
462
463
self .assertEqual (response .status_code , 400 )
463
464
465
+ def test_duration_present_but_not_allowed (self ):
466
+ self .file ["file_format" ] = file_formats .EPUB
467
+ self .file ["preset" ] = format_presets .DOCUMENT
468
+
469
+ self .client .force_authenticate (user = self .user )
470
+ response = self .client .post (
471
+ reverse ("file-upload-url" ),
472
+ self .file ,
473
+ format = "json" ,
474
+ )
475
+
476
+ self .assertEqual (response .status_code , 400 )
477
+
464
478
def test_duration_null (self ):
465
479
self .file ["duration" ] = None
466
480
self .file ["file_format" ] = file_formats .EPUB
481
+ self .file ["preset" ] = format_presets .EPUB
467
482
468
483
self .client .force_authenticate (user = self .user )
469
484
response = self .client .post (
@@ -517,6 +532,18 @@ def test_invalid_preset_upload(self):
517
532
response = self .client .post (reverse ("file-upload-url" ), file , format = "json" )
518
533
self .assertEqual (response .status_code , 400 )
519
534
535
+ def test_mismatched_preset_upload (self ):
536
+ self .file ["file_format" ] = file_formats .EPUB
537
+
538
+ self .client .force_authenticate (user = self .user )
539
+ response = self .client .post (
540
+ reverse ("file-upload-url" ),
541
+ self .file ,
542
+ format = "json" ,
543
+ )
544
+
545
+ self .assertEqual (response .status_code , 400 )
546
+
520
547
def test_insufficient_storage (self ):
521
548
self .file ["size" ] = 100000000000000
522
549
0 commit comments