1
0
mirror of https://github.com/django/django.git synced 2024-12-22 09:05:43 +00:00

Added tests for loaddata with gzip/bzip2 compressed fixtures.

Co-authored-by: Adam Johnson <me@adamj.eu>
This commit is contained in:
Paolo Melchiorre 2020-05-07 15:57:37 +02:00 committed by Mariusz Felisiak
parent 6789ded0a6
commit 2e0f04507b
3 changed files with 20 additions and 0 deletions

View File

@ -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.

View File

@ -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'"