Used QuerySet.bulk_create() in a couple of postgres tests.

Follow up to 0ce2ad9ca4.
This commit is contained in:
oliver 2019-03-22 07:05:29 +09:00 committed by Tim Graham
parent dc740dde50
commit 2aaabe2004
2 changed files with 21 additions and 21 deletions

View File

@ -104,19 +104,19 @@ class TestSaveLoad(PostgreSQLTestCase):
class TestQuerying(PostgreSQLTestCase): class TestQuerying(PostgreSQLTestCase):
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):
cls.objs = [ cls.objs = JSONModel.objects.bulk_create([
JSONModel.objects.create(field=None), JSONModel(field=None),
JSONModel.objects.create(field=True), JSONModel(field=True),
JSONModel.objects.create(field=False), JSONModel(field=False),
JSONModel.objects.create(field='yes'), JSONModel(field='yes'),
JSONModel.objects.create(field=7), JSONModel(field=7),
JSONModel.objects.create(field=[]), JSONModel(field=[]),
JSONModel.objects.create(field={}), JSONModel(field={}),
JSONModel.objects.create(field={ JSONModel(field={
'a': 'b', 'a': 'b',
'c': 1, 'c': 1,
}), }),
JSONModel.objects.create(field={ JSONModel(field={
'a': 'b', 'a': 'b',
'c': 1, 'c': 1,
'd': ['e', {'f': 'g'}], 'd': ['e', {'f': 'g'}],
@ -125,13 +125,13 @@ class TestQuerying(PostgreSQLTestCase):
'j': None, 'j': None,
'k': {'l': 'm'}, 'k': {'l': 'm'},
}), }),
JSONModel.objects.create(field=[1, [2]]), JSONModel(field=[1, [2]]),
JSONModel.objects.create(field={ JSONModel(field={
'k': True, 'k': True,
'l': False, 'l': False,
}), }),
JSONModel.objects.create(field={'foo': 'bar'}), JSONModel(field={'foo': 'bar'}),
] ])
def test_exact(self): def test_exact(self):
self.assertSequenceEqual( self.assertSequenceEqual(

View File

@ -167,13 +167,13 @@ class TestQuerying(PostgreSQLTestCase):
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):
cls.objs = [ cls.objs = RangesModel.objects.bulk_create([
RangesModel.objects.create(ints=NumericRange(0, 10)), RangesModel(ints=NumericRange(0, 10)),
RangesModel.objects.create(ints=NumericRange(5, 15)), RangesModel(ints=NumericRange(5, 15)),
RangesModel.objects.create(ints=NumericRange(None, 0)), RangesModel(ints=NumericRange(None, 0)),
RangesModel.objects.create(ints=NumericRange(empty=True)), RangesModel(ints=NumericRange(empty=True)),
RangesModel.objects.create(ints=None), RangesModel(ints=None),
] ])
def test_exact(self): def test_exact(self):
self.assertSequenceEqual( self.assertSequenceEqual(