3
3
import os
4
4
5
5
from django .contrib .staticfiles import finders
6
+ from django .core .files .storage import FileSystemStorage
6
7
from django .test import TestCase
7
8
8
9
from pipeline .collector import default_collector
9
10
from pipeline .finders import PipelineFinder
10
11
11
12
13
+ def local_path (path ):
14
+ return os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' , path ))
15
+
16
+
12
17
class CollectorTest (TestCase ):
13
18
def tearDown (self ):
14
19
super (CollectorTest , self ).tearDown ()
@@ -31,6 +36,24 @@ def test_collect_with_files(self):
31
36
'pipeline/js/second.js' ,
32
37
]))
33
38
39
+ def test_delete_file_with_modified (self ):
40
+ list (default_collector .collect ())
41
+
42
+ storage = FileSystemStorage (local_path ('assets' ))
43
+ new_mtime = os .path .getmtime (storage .path ('js/first.js' )) - 1000
44
+ os .utime (default_collector .storage .path ('pipeline/js/first.js' ),
45
+ (new_mtime , new_mtime ))
46
+
47
+ self .assertTrue (default_collector .delete_file (
48
+ 'js/first.js' , 'pipeline/js/first.js' , storage ))
49
+
50
+ def test_delete_file_with_unmodified (self ):
51
+ list (default_collector .collect (files = ['pipeline/js/first.js' ]))
52
+
53
+ self .assertFalse (default_collector .delete_file (
54
+ 'js/first.js' , 'pipeline/js/first.js' ,
55
+ FileSystemStorage (local_path ('assets' ))))
56
+
34
57
def _get_collectable_files (self ):
35
58
for finder in finders .get_finders ():
36
59
if not isinstance (finder , PipelineFinder ):
0 commit comments