Added tests for loaddata with gzip/bzip2 compressed fixtures.
Co-authored-by: Adam Johnson <me@adamj.eu>
This commit is contained in:
parent
6789ded0a6
commit
2e0f04507b
1
AUTHORS
1
AUTHORS
|
@ -695,6 +695,7 @@ answer newbie questions, and generally made Django that much better:
|
|||
Owen Griffiths
|
||||
Pablo Martín <goinnn@gmail.com>
|
||||
Panos Laganakos <panos.laganakos@gmail.com>
|
||||
Paolo Melchiorre <paolo@melchiorre.org>
|
||||
Pascal Hartig <phartig@rdrei.net>
|
||||
Pascal Varet
|
||||
Patrik Sletmo <patrik.sletmo@gmail.com>
|
||||
|
|
Binary file not shown.
|
@ -21,6 +21,12 @@ from .models import (
|
|||
PrimaryKeyUUIDModel, ProxySpy, Spy, Tag, Visa,
|
||||
)
|
||||
|
||||
try:
|
||||
import bz2 # NOQA
|
||||
HAS_BZ2 = True
|
||||
except ImportError:
|
||||
HAS_BZ2 = False
|
||||
|
||||
|
||||
class TestCaseFixtureLoadingTests(TestCase):
|
||||
fixtures = ['fixture1.json', 'fixture2.json']
|
||||
|
@ -540,6 +546,19 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
|
|||
'<Article: WoW subscribers now outnumber readers>',
|
||||
])
|
||||
|
||||
def test_compressed_loading_gzip(self):
|
||||
management.call_command('loaddata', 'fixture5.json.gz', verbosity=0)
|
||||
self.assertQuerysetEqual(Article.objects.all(), [
|
||||
'<Article: WoW subscribers now outnumber readers>',
|
||||
])
|
||||
|
||||
@unittest.skipUnless(HAS_BZ2, 'No bz2 library detected.')
|
||||
def test_compressed_loading_bz2(self):
|
||||
management.call_command('loaddata', 'fixture5.json.bz2', verbosity=0)
|
||||
self.assertQuerysetEqual(Article.objects.all(), [
|
||||
'<Article: WoW subscribers now outnumber readers>',
|
||||
])
|
||||
|
||||
def test_ambiguous_compressed_fixture(self):
|
||||
# The name "fixture5" is ambiguous, so loading raises an error.
|
||||
msg = "Multiple fixtures named 'fixture5'"
|
||||
|
|
Loading…
Reference in New Issue