Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to fix non-determinism in tests #856

Merged
merged 2 commits into from
Oct 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions cadasta/resources/migrations/0004_add_ordering_for_resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-10-20 16:48
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('resources', '0003_spatialresource'),
]

operations = [
migrations.AlterModelOptions(
name='resource',
options={'ordering': ('name',)},
),
migrations.AlterModelOptions(
name='spatialresource',
options={'ordering': ('name',)},
),
]
3 changes: 3 additions & 0 deletions cadasta/resources/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class Resource(RandomIDModel):

history = HistoricalRecords()

class Meta:
ordering = ('name',)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resources could have the same name so we still have a nondeterministic ordering. It may help to have the resource ID as the second field.

On the other hand, this ordering is simply to make testing deterministic. So if all our tests stick to unique resource names, then this should be OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. It's just for testing.


class TutelaryMeta:
perm_type = 'resource'
path_fields = ('project', 'pk')
Expand Down