mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
update test to handle django-1.10 change in FileField storage
This commit is contained in:
parent
3e38bab785
commit
865841eedf
@ -890,8 +890,15 @@ class TestPageEdit(TestCase, WagtailTestUtils):
|
||||
|
||||
# Check the new file exists
|
||||
file_page = FilePage.objects.get()
|
||||
self.assertEqual(file_page.file_field.name,
|
||||
os.path.join('.', file_upload.name))
|
||||
|
||||
# In Django < 1.10 the file_field.name starts with ./ whereas in 1.10 it is the basename;
|
||||
# we test against os.path.basename(file_page.file_field.name) so that both possibilities
|
||||
# are handled. os.path.basename can be removed when support for Django <= 1.9 is dropped.
|
||||
|
||||
# (hello, future person grepping for the string `if DJANGO_VERSION < (1, 10)`)
|
||||
|
||||
self.assertEqual(os.path.basename(file_page.file_field.name),
|
||||
os.path.basename(file_upload.name))
|
||||
self.assertTrue(os.path.exists(file_page.file_field.path))
|
||||
self.assertEqual(file_page.file_field.read(), b"A new file")
|
||||
|
||||
@ -919,10 +926,16 @@ class TestPageEdit(TestCase, WagtailTestUtils):
|
||||
# Publish the draft just created
|
||||
FilePage.objects.get().get_latest_revision().publish()
|
||||
|
||||
# In Django < 1.10 the file_field.name starts with ./ whereas in 1.10 it is the basename;
|
||||
# we test against os.path.basename(file_page.file_field.name) so that both possibilities
|
||||
# are handled. os.path.basename can be removed when support for Django <= 1.9 is dropped.
|
||||
|
||||
# (hello, future person grepping for the string `if DJANGO_VERSION < (1, 10)`)
|
||||
|
||||
# Get the file page, check the file is set
|
||||
file_page = FilePage.objects.get()
|
||||
self.assertEqual(file_page.file_field.name,
|
||||
os.path.join('.', file_upload.name))
|
||||
self.assertEqual(os.path.basename(file_page.file_field.name),
|
||||
os.path.basename(file_upload.name))
|
||||
self.assertTrue(os.path.exists(file_page.file_field.path))
|
||||
self.assertEqual(file_page.file_field.read(), b"A new file")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user