mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Added tests for loaddata with gzip/bzip2 compressed fixtures.
Co-authored-by: Adam Johnson <me@adamj.eu>
This commit is contained in:
committed by
Mariusz Felisiak
parent
6789ded0a6
commit
2e0f04507b
BIN
tests/fixtures/fixtures/fixture5.json.bz2
vendored
Normal file
BIN
tests/fixtures/fixtures/fixture5.json.bz2
vendored
Normal file
Binary file not shown.
19
tests/fixtures/tests.py
vendored
19
tests/fixtures/tests.py
vendored
@@ -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'"
|
||||
|
||||
Reference in New Issue
Block a user