[1.5.x] Minor fixes in the known_related_objects tests.
* Fixed JSON indentation.
* Avoided relying on implicit ordering.
Backport of a7b7efe
.
This commit is contained in:
parent
056ace0f39
commit
7be9fa224c
|
@ -4,22 +4,22 @@
|
||||||
"model": "known_related_objects.tournament",
|
"model": "known_related_objects.tournament",
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "Tourney 1"
|
"name": "Tourney 1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pk": 2,
|
"pk": 2,
|
||||||
"model": "known_related_objects.tournament",
|
"model": "known_related_objects.tournament",
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "Tourney 2"
|
"name": "Tourney 2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
"model": "known_related_objects.organiser",
|
"model": "known_related_objects.organiser",
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "Organiser 1"
|
"name": "Organiser 1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
"model": "known_related_objects.pool",
|
"model": "known_related_objects.pool",
|
||||||
|
@ -27,8 +27,8 @@
|
||||||
"tournament": 1,
|
"tournament": 1,
|
||||||
"organiser": 1,
|
"organiser": 1,
|
||||||
"name": "T1 Pool 1"
|
"name": "T1 Pool 1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pk": 2,
|
"pk": 2,
|
||||||
"model": "known_related_objects.pool",
|
"model": "known_related_objects.pool",
|
||||||
|
@ -36,8 +36,8 @@
|
||||||
"tournament": 1,
|
"tournament": 1,
|
||||||
"organiser": 1,
|
"organiser": 1,
|
||||||
"name": "T1 Pool 2"
|
"name": "T1 Pool 2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pk": 3,
|
"pk": 3,
|
||||||
"model": "known_related_objects.pool",
|
"model": "known_related_objects.pool",
|
||||||
|
@ -45,8 +45,8 @@
|
||||||
"tournament": 2,
|
"tournament": 2,
|
||||||
"organiser": 1,
|
"organiser": 1,
|
||||||
"name": "T2 Pool 1"
|
"name": "T2 Pool 1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pk": 4,
|
"pk": 4,
|
||||||
"model": "known_related_objects.pool",
|
"model": "known_related_objects.pool",
|
||||||
|
@ -54,23 +54,23 @@
|
||||||
"tournament": 2,
|
"tournament": 2,
|
||||||
"organiser": 1,
|
"organiser": 1,
|
||||||
"name": "T2 Pool 2"
|
"name": "T2 Pool 2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
"model": "known_related_objects.poolstyle",
|
"model": "known_related_objects.poolstyle",
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "T1 Pool 2 Style",
|
"name": "T1 Pool 2 Style",
|
||||||
"pool": 2
|
"pool": 2
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pk": 2,
|
"pk": 2,
|
||||||
"model": "known_related_objects.poolstyle",
|
"model": "known_related_objects.poolstyle",
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "T2 Pool 1 Style",
|
"name": "T2 Pool 1 Style",
|
||||||
"pool": 3
|
"pool": 3
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class ExistingRelatedInstancesTests(TestCase):
|
||||||
|
|
||||||
def test_foreign_key_multiple_prefetch(self):
|
def test_foreign_key_multiple_prefetch(self):
|
||||||
with self.assertNumQueries(2):
|
with self.assertNumQueries(2):
|
||||||
tournaments = list(Tournament.objects.prefetch_related('pool_set'))
|
tournaments = list(Tournament.objects.prefetch_related('pool_set').order_by('pk'))
|
||||||
pool1 = tournaments[0].pool_set.all()[0]
|
pool1 = tournaments[0].pool_set.all()[0]
|
||||||
self.assertIs(tournaments[0], pool1.tournament)
|
self.assertIs(tournaments[0], pool1.tournament)
|
||||||
pool2 = tournaments[1].pool_set.all()[0]
|
pool2 = tournaments[1].pool_set.all()[0]
|
||||||
|
@ -81,7 +81,7 @@ class ExistingRelatedInstancesTests(TestCase):
|
||||||
|
|
||||||
def test_one_to_one_multi_select_related(self):
|
def test_one_to_one_multi_select_related(self):
|
||||||
with self.assertNumQueries(1):
|
with self.assertNumQueries(1):
|
||||||
poolstyles = list(PoolStyle.objects.select_related('pool'))
|
poolstyles = list(PoolStyle.objects.select_related('pool').order_by('pk'))
|
||||||
self.assertIs(poolstyles[0], poolstyles[0].pool.poolstyle)
|
self.assertIs(poolstyles[0], poolstyles[0].pool.poolstyle)
|
||||||
self.assertIs(poolstyles[1], poolstyles[1].pool.poolstyle)
|
self.assertIs(poolstyles[1], poolstyles[1].pool.poolstyle)
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class ExistingRelatedInstancesTests(TestCase):
|
||||||
|
|
||||||
def test_one_to_one_multi_prefetch_related(self):
|
def test_one_to_one_multi_prefetch_related(self):
|
||||||
with self.assertNumQueries(2):
|
with self.assertNumQueries(2):
|
||||||
poolstyles = list(PoolStyle.objects.prefetch_related('pool'))
|
poolstyles = list(PoolStyle.objects.prefetch_related('pool').order_by('pk'))
|
||||||
self.assertIs(poolstyles[0], poolstyles[0].pool.poolstyle)
|
self.assertIs(poolstyles[0], poolstyles[0].pool.poolstyle)
|
||||||
self.assertIs(poolstyles[1], poolstyles[1].pool.poolstyle)
|
self.assertIs(poolstyles[1], poolstyles[1].pool.poolstyle)
|
||||||
|
|
||||||
|
@ -117,12 +117,12 @@ class ExistingRelatedInstancesTests(TestCase):
|
||||||
|
|
||||||
def test_reverse_one_to_one_multi_select_related(self):
|
def test_reverse_one_to_one_multi_select_related(self):
|
||||||
with self.assertNumQueries(1):
|
with self.assertNumQueries(1):
|
||||||
pools = list(Pool.objects.select_related('poolstyle'))
|
pools = list(Pool.objects.select_related('poolstyle').order_by('pk'))
|
||||||
self.assertIs(pools[1], pools[1].poolstyle.pool)
|
self.assertIs(pools[1], pools[1].poolstyle.pool)
|
||||||
self.assertIs(pools[2], pools[2].poolstyle.pool)
|
self.assertIs(pools[2], pools[2].poolstyle.pool)
|
||||||
|
|
||||||
def test_reverse_one_to_one_multi_prefetch_related(self):
|
def test_reverse_one_to_one_multi_prefetch_related(self):
|
||||||
with self.assertNumQueries(2):
|
with self.assertNumQueries(2):
|
||||||
pools = list(Pool.objects.prefetch_related('poolstyle'))
|
pools = list(Pool.objects.prefetch_related('poolstyle').order_by('pk'))
|
||||||
self.assertIs(pools[1], pools[1].poolstyle.pool)
|
self.assertIs(pools[1], pools[1].poolstyle.pool)
|
||||||
self.assertIs(pools[2], pools[2].poolstyle.pool)
|
self.assertIs(pools[2], pools[2].poolstyle.pool)
|
||||||
|
|
Loading…
Reference in New Issue