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