Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
8e3f9d3e
Kaydet (Commit)
8e3f9d3e
authored
Şub 03, 2017
tarafından
David Sanders
Kaydeden (comit)
Tim Graham
Şub 03, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27741 -- Isolated TestCollectionHashedFilesCache in a tmpdir.
üst
4d658400
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
25 deletions
+39
-25
test_storage.py
tests/staticfiles_tests/test_storage.py
+39
-25
No files found.
tests/staticfiles_tests/test_storage.py
Dosyayı görüntüle @
8e3f9d3e
...
@@ -551,32 +551,46 @@ class TestCollectionHashedFilesCache(CollectionTestCase):
...
@@ -551,32 +551,46 @@ class TestCollectionHashedFilesCache(CollectionTestCase):
hashed_file_path
=
hashed_file_path
hashed_file_path
=
hashed_file_path
def
setUp
(
self
):
def
setUp
(
self
):
self
.
testimage_path
=
os
.
path
.
join
(
TEST_ROOT
,
'project'
,
'documents'
,
'cached'
,
'css'
,
'img'
,
'window.png'
)
with
open
(
self
.
testimage_path
,
'r+b'
)
as
f
:
self
.
_orig_image_content
=
f
.
read
()
super
()
.
setUp
()
super
()
.
setUp
()
self
.
_temp_dir
=
temp_dir
=
tempfile
.
mkdtemp
()
os
.
makedirs
(
os
.
path
.
join
(
temp_dir
,
'test'
))
self
.
addCleanup
(
shutil
.
rmtree
,
temp_dir
)
def
tearDown
(
self
):
def
_get_filename_path
(
self
,
filename
):
with
open
(
self
.
testimage_path
,
'w+b'
)
as
f
:
return
os
.
path
.
join
(
self
.
_temp_dir
,
'test'
,
filename
)
f
.
write
(
self
.
_orig_image_content
)
super
()
.
tearDown
()
def
test_file_change_after_collectstatic
(
self
):
def
test_file_change_after_collectstatic
(
self
):
finders
.
get_finder
.
cache_clear
()
# Create initial static files.
err
=
StringIO
()
file_contents
=
(
call_command
(
'collectstatic'
,
interactive
=
False
,
verbosity
=
0
,
stderr
=
err
)
(
'foo.png'
,
'foo'
),
with
open
(
self
.
testimage_path
,
'w+b'
)
as
f
:
(
'bar.css'
,
'url("foo.png")
\n
url("xyz.png")'
),
f
.
write
(
b
"new content of png file to change it's hash"
)
(
'xyz.png'
,
'xyz'
),
)
# Change modification time of self.testimage_path to make sure it gets
for
filename
,
content
in
file_contents
:
# collected again.
with
open
(
self
.
_get_filename_path
(
filename
),
'w'
)
as
f
:
mtime
=
os
.
path
.
getmtime
(
self
.
testimage_path
)
f
.
write
(
content
)
atime
=
os
.
path
.
getatime
(
self
.
testimage_path
)
os
.
utime
(
self
.
testimage_path
,
(
mtime
+
1
,
atime
+
1
))
with
self
.
modify_settings
(
STATICFILES_DIRS
=
{
'append'
:
self
.
_temp_dir
}):
finders
.
get_finder
.
cache_clear
()
call_command
(
'collectstatic'
,
interactive
=
False
,
verbosity
=
0
,
stderr
=
err
)
err
=
StringIO
()
relpath
=
self
.
hashed_file_path
(
'cached/css/window.css'
)
# First collectstatic run.
with
storage
.
staticfiles_storage
.
open
(
relpath
)
as
relfile
:
call_command
(
'collectstatic'
,
interactive
=
False
,
verbosity
=
0
,
stderr
=
err
)
self
.
assertIn
(
b
'window.a836fe39729e.png'
,
relfile
.
read
())
relpath
=
self
.
hashed_file_path
(
'test/bar.css'
)
with
storage
.
staticfiles_storage
.
open
(
relpath
)
as
relfile
:
content
=
relfile
.
read
()
self
.
assertIn
(
b
'foo.acbd18db4cc2.png'
,
content
)
self
.
assertIn
(
b
'xyz.d16fb36f0911.png'
,
content
)
# Change the contents of the png files.
for
filename
in
(
'foo.png'
,
'xyz.png'
):
with
open
(
self
.
_get_filename_path
(
filename
),
'w+b'
)
as
f
:
f
.
write
(
b
"new content of file to change its hash"
)
# The hashes of the png files in the CSS file are updated after
# a second collectstatic.
call_command
(
'collectstatic'
,
interactive
=
False
,
verbosity
=
0
,
stderr
=
err
)
relpath
=
self
.
hashed_file_path
(
'test/bar.css'
)
with
storage
.
staticfiles_storage
.
open
(
relpath
)
as
relfile
:
content
=
relfile
.
read
()
self
.
assertIn
(
b
'foo.57a5cb9ba68d.png'
,
content
)
self
.
assertIn
(
b
'xyz.57a5cb9ba68d.png'
,
content
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment