Browse files

[1.5.x] Minor fixes in the known_related_objects tests.

* Fixed JSON indentation.
* Avoided relying on implicit ordering.

Backport of a7b7efe.
  • Loading branch information...
1 parent 056ace0 commit 7be9fa224ceaeed7070541430c31b9235d309f0a @aaugustin aaugustin committed Jan 2, 2013
View
34 tests/modeltests/known_related_objects/fixtures/tournament.json
@@ -4,73 +4,73 @@
"model": "known_related_objects.tournament",
"fields": {
"name": "Tourney 1"
- }
- },
+ }
+ },
{
"pk": 2,
"model": "known_related_objects.tournament",
"fields": {
"name": "Tourney 2"
- }
- },
+ }
+ },
{
"pk": 1,
"model": "known_related_objects.organiser",
"fields": {
"name": "Organiser 1"
- }
- },
+ }
+ },
{
"pk": 1,
"model": "known_related_objects.pool",
"fields": {
"tournament": 1,
"organiser": 1,
"name": "T1 Pool 1"
- }
- },
+ }
+ },
{
"pk": 2,
"model": "known_related_objects.pool",
"fields": {
"tournament": 1,
"organiser": 1,
"name": "T1 Pool 2"
- }
- },
+ }
+ },
{
"pk": 3,
"model": "known_related_objects.pool",
"fields": {
"tournament": 2,
"organiser": 1,
"name": "T2 Pool 1"
- }
- },
+ }
+ },
{
"pk": 4,
"model": "known_related_objects.pool",
"fields": {
"tournament": 2,
"organiser": 1,
"name": "T2 Pool 2"
- }
- },
+ }
+ },
{
"pk": 1,
"model": "known_related_objects.poolstyle",
"fields": {
"name": "T1 Pool 2 Style",
"pool": 2
- }
- },
+ }
+ },
{
"pk": 2,
"model": "known_related_objects.poolstyle",
"fields": {
"name": "T2 Pool 1 Style",
"pool": 3
- }
}
+ }
]
View
10 tests/modeltests/known_related_objects/tests.py
@@ -21,7 +21,7 @@ def test_foreign_key_prefetch_related(self):
def test_foreign_key_multiple_prefetch(self):
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]
self.assertIs(tournaments[0], pool1.tournament)
pool2 = tournaments[1].pool_set.all()[0]
@@ -81,7 +81,7 @@ def test_one_to_one_select_related(self):
def test_one_to_one_multi_select_related(self):
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[1], poolstyles[1].pool.poolstyle)
@@ -93,7 +93,7 @@ def test_one_to_one_prefetch_related(self):
def test_one_to_one_multi_prefetch_related(self):
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[1], poolstyles[1].pool.poolstyle)
@@ -117,12 +117,12 @@ def test_reverse_one_to_one_prefetch_related(self):
def test_reverse_one_to_one_multi_select_related(self):
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[2], pools[2].poolstyle.pool)
def test_reverse_one_to_one_multi_prefetch_related(self):
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[2], pools[2].poolstyle.pool)

0 comments on commit 7be9fa2

Please sign in to comment.