1010import pytz
1111import tempfile
1212import unittest
13+ from mock import patch
1314
1415from courseware .models import StudentModule
1516from django .contrib .auth .models import User
@@ -396,6 +397,13 @@ def test_upload_download_assignment(self):
396397 response = block .download_assignment (None )
397398 self .assertEqual (response .body , expected )
398399
400+ with patch (
401+ "edx_sga.sga.StaffGradedAssignmentXBlock._file_storage_path" ,
402+ return_value = block ._file_storage_path ("" , "test_notfound.txt" )
403+ ):
404+ response = block .download_assignment (None )
405+ self .assertEqual (response .status_code , 404 )
406+
399407 def test_staff_upload_download_annotated (self ):
400408 # pylint: disable=no-member
401409 """
@@ -413,6 +421,14 @@ def test_staff_upload_download_annotated(self):
413421 'module_id' : fred .id }))
414422 self .assertEqual (response .body , expected )
415423
424+ with patch (
425+ "edx_sga.sga.StaffGradedAssignmentXBlock._file_storage_path" ,
426+ return_value = block ._file_storage_path ("" , "test_notfound.txt" )
427+ ):
428+ response = block .staff_download_annotated (mock .Mock (params = {
429+ 'module_id' : fred .id }))
430+ self .assertEqual (response .status_code , 404 )
431+
416432 def test_download_annotated (self ):
417433 # pylint: disable=no-member
418434 """
@@ -430,6 +446,13 @@ def test_download_annotated(self):
430446 response = block .download_annotated (None )
431447 self .assertEqual (response .body , expected )
432448
449+ with patch (
450+ "edx_sga.sga.StaffGradedAssignmentXBlock._file_storage_path" ,
451+ return_value = block ._file_storage_path ("" , "test_notfound.txt" )
452+ ):
453+ response = block .download_annotated (None )
454+ self .assertEqual (response .status_code , 404 )
455+
433456 def test_staff_download (self ):
434457 """
435458 Test download for staff.
@@ -445,6 +468,14 @@ def test_staff_download(self):
445468 'student_id' : student ['item' ].student_id }))
446469 self .assertEqual (response .body , expected )
447470
471+ with patch (
472+ "edx_sga.sga.StaffGradedAssignmentXBlock._file_storage_path" ,
473+ return_value = block ._file_storage_path ("" , "test_notfound.txt" )
474+ ):
475+ response = block .staff_download (mock .Mock (params = {
476+ 'student_id' : student ['item' ].student_id }))
477+ self .assertEqual (response .status_code , 404 )
478+
448479 def test_download_annotated_unicode_filename (self ):
449480 """
450481 Tests download annotated assignment
@@ -462,6 +493,13 @@ def test_download_annotated_unicode_filename(self):
462493 response = block .download_annotated (None )
463494 self .assertEqual (response .body , expected )
464495
496+ with patch (
497+ "edx_sga.sga.StaffGradedAssignmentXBlock._file_storage_path" ,
498+ return_value = block ._file_storage_path ("" , "test_notfound.txt" )
499+ ):
500+ response = block .download_annotated (None )
501+ self .assertEqual (response .status_code , 404 )
502+
465503 def test_staff_download_unicode_filename (self ):
466504 """
467505 Tests download assignment with filename in unicode for staff.
@@ -476,6 +514,13 @@ def test_staff_download_unicode_filename(self):
476514 response = block .staff_download (mock .Mock (params = {
477515 'student_id' : student ['item' ].student_id }))
478516 self .assertEqual (response .body , expected )
517+ with patch (
518+ "edx_sga.sga.StaffGradedAssignmentXBlock._file_storage_path" ,
519+ return_value = block ._file_storage_path ("" , "test_notfound.txt" )
520+ ):
521+ response = block .staff_download (mock .Mock (params = {
522+ 'student_id' : student ['item' ].student_id }))
523+ self .assertEqual (response .status_code , 404 )
479524
480525 def test_get_staff_grading_data_not_staff (self ):
481526 """
0 commit comments