Testing Django MPTT models with Django Dynamic Fixture 1.2.1

86 views
Skip to first unread message

Paulo Cheque

unread,
Mar 13, 2011, 4:45:12 AM3/13/11
to django-mptt-dev
Hi, now you can use django dynamic fixture (1.2.1) to generate Django
MPTT models instances in automated tests.

Example:

Model: class Category(MPTTModel): pass

Test:
def test_something(self):
mptt_fields = ['tree', 'tree_id', 'lft', 'rght', 'level', ]
# Create a Category1 with parent Category2
category = get(Category, ignore_fields=mptt_fields)
# Create a Category1 without parent
category = get(Category, number_of_laps=0,
ignore_fields=mptt_fields)
# Create a Category1 with parent Category2 with parent Category3
category = get(Category, number_of_laps=3,
ignore_fields=mptt_fields)

Links:
http://code.google.com/p/django-dynamic-fixture

http://pythonsmalltalk.blogspot.com/2011/03/django-dynamic-fixture-121.html

Paulo
http://pythonsmalltalk.blogspot.com
Reply all
Reply to author
Forward
0 new messages