1
1
import datetime
2
2
import io
3
3
import os
4
- import unittest
5
4
6
5
import requests
7
6
from django .core .files .base import ContentFile
8
7
from django .test import TestCase , override_settings
9
8
from freezegun import freeze_time
10
9
from minio .error import S3Error
11
10
12
- from minio_storage .errors import MinIOError
13
11
from minio_storage .storage import MinioMediaStorage
14
12
15
13
from .utils import BaseTestMixin
@@ -41,7 +39,7 @@ def test_file_size(self):
41
39
test_file = self .media_storage .save ("sizetest.txt" , ContentFile (b"1234" ))
42
40
self .assertEqual (4 , self .media_storage .size (test_file ))
43
41
44
- def test_size_of_non_existent_throws (self ):
42
+ def test_size_of_non_existent_raises_exception (self ):
45
43
test_file = self .media_storage .save ("sizetest.txt" , ContentFile (b"1234" ))
46
44
self .media_storage .delete (test_file )
47
45
with self .assertRaises (S3Error ):
@@ -62,7 +60,7 @@ def test_created_time(self):
62
60
self .media_storage .created_time (self .new_file ), datetime .datetime
63
61
)
64
62
65
- def test_modified_time_of_non_existent_throws (self ):
63
+ def test_modified_time_of_non_existent_raises_exception (self ):
66
64
with self .assertRaises (S3Error ):
67
65
self .media_storage .modified_time ("nonexistent.jpg" )
68
66
@@ -116,19 +114,10 @@ def test_file_exists(self):
116
114
def test_file_exists_failure (self ):
117
115
self .assertFalse (self .media_storage .exists ("nonexistent.txt" ))
118
116
119
- @unittest .skip ("Skipping this test because undecided if it should raise exception" )
120
- def test_opening_non_existing_file_raises_oserror (self ):
121
- with self .assertRaises (OSError ):
122
- self .media_storage .open ("this does not exist" )
123
-
124
- @unittest .skip ("Skipping this test because undecided if it should raise exception" )
125
- def test_opening_non_existing_file_raises_minioerror (self ):
126
- with self .assertRaises (MinIOError ):
127
- self .media_storage .open ("this does not exist" )
128
- try :
129
- self .media_storage .open ("this does not exist" )
130
- except MinIOError as e :
131
- assert e .cause .__class__ == S3Error
117
+ def test_reading_non_existing_file_raises_exception (self ):
118
+ with self .assertRaises (Exception ):
119
+ f = self .media_storage .open ("this does not exist" )
120
+ f .read ()
132
121
133
122
def test_file_names_are_properly_sanitized (self ):
134
123
self .media_storage .save ("./meh22222.txt" , io .BytesIO (b"stuff" ))
0 commit comments