summaryrefslogtreecommitdiff
path: root/tests/fixtures
diff options
context:
space:
mode:
authorPaolo Melchiorre <paolo@melchiorre.org>2020-05-07 15:57:37 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-08 08:16:50 +0200
commit2e0f04507b17362239ba49830d26fec504d46978 (patch)
treebe0eb0e2d460383b414c46342e3880ce62ef2c3f /tests/fixtures
parent6789ded0a6ab797f0dcdfa6ad5d1cfa46e23abcd (diff)
Added tests for loaddata with gzip/bzip2 compressed fixtures.
Co-authored-by: Adam Johnson <me@adamj.eu>
Diffstat (limited to 'tests/fixtures')
-rw-r--r--tests/fixtures/fixtures/fixture5.json.bz2bin0 -> 166 bytes
-rw-r--r--tests/fixtures/tests.py19
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/fixtures/fixtures/fixture5.json.bz2 b/tests/fixtures/fixtures/fixture5.json.bz2
new file mode 100644
index 0000000000..046bfa5820
--- /dev/null
+++ b/tests/fixtures/fixtures/fixture5.json.bz2
Binary files differ
diff --git a/tests/fixtures/tests.py b/tests/fixtures/tests.py
index 1e723a7b66..cac3ccabc4 100644
--- a/tests/fixtures/tests.py
+++ b/tests/fixtures/tests.py
@@ -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'"