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

bug when using a custom PK name #164

Merged
merged 4 commits into from Jul 31, 2012
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/myapp/models.py
Expand Up @@ -86,3 +86,13 @@ def __unicode__(self):


class Student(Person): class Student(Person):
type = models.CharField(max_length=50) type = models.CharField(max_length=50)

class CustomPKName(MPTTModel):
my_id = models.AutoField(db_column='my_custom_name', primary_key=True)
name = models.CharField(max_length=50)
parent = models.ForeignKey('self', null=True, blank=True,
related_name='children', db_column="my_cusom_parent")

def __unicode__(self):
return self.name

21 changes: 20 additions & 1 deletion tests/myapp/tests.py
Expand Up @@ -3,7 +3,7 @@
from django.test import TestCase from django.test import TestCase


from mptt.exceptions import InvalidMove from mptt.exceptions import InvalidMove
from myapp.models import Category, Genre from myapp.models import Category, Genre, CustomPKName




def get_tree_details(nodes): def get_tree_details(nodes):
Expand Down Expand Up @@ -346,3 +346,22 @@ class InterTreeMovementTestCase(TestCase):


class PositionedInsertionTestCase(TestCase): class PositionedInsertionTestCase(TestCase):
pass pass

class CustomPKNameTestCase(TestCase):
def setUp(self):
c1 = CustomPKName.objects.create(name="c1")
c11 = CustomPKName.objects.create(name="c11", parent=c1)
c12 = CustomPKName.objects.create(name="c12", parent=c1)

c2 = CustomPKName.objects.create(name="c2")
c21 = CustomPKName.objects.create(name="c21", parent=c2)
c22 = CustomPKName.objects.create(name="c22", parent=c2)

c3 = CustomPKName.objects.create(name="c3")

def test_get_next_sibling(self):
root = CustomPKName.objects.get(name="c12")
sib = root.get_next_sibling()
self.assertTrue(sib is None)


2 changes: 1 addition & 1 deletion tests/runtests.sh
Expand Up @@ -2,4 +2,4 @@
export PYTHONPATH="./" export PYTHONPATH="./"
export DJANGO_SETTINGS_MODULE='settings' export DJANGO_SETTINGS_MODULE='settings'


django-admin test --pythonpath="../" django-admin.py test --pythonpath="../"