Skip to content

Commit

Permalink
Added failing test case for #17.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwatts committed Aug 20, 2013
1 parent f96024a commit e343319
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
Empty file.
24 changes: 24 additions & 0 deletions positions/examples/school/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.db import models

from positions import PositionField


class SubUnit(models.Model):
name = models.CharField(max_length=100)


class Task(models.Model):
"""
Base class for lessons/exercises - ordered items within a sub-unit
"""
sub_unit = models.ForeignKey(SubUnit)
position = PositionField(collection='sub_unit')


class Lesson(Task):
subject = models.CharField(max_length=100)
text = models.TextField(blank=True)


class Exercise(Task):
description = models.CharField(max_length=100)
25 changes: 25 additions & 0 deletions positions/examples/school/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.db import models

from positions.examples.school.models import SubUnit, Lesson, Exercise


tests = """
>>> american_revolution = SubUnit.objects.create(name="American Revolution")
>>> no_taxation = Lesson.objects.create(sub_unit=american_revolution, subject="No Taxation without Representation")
>>> no_taxation.position
0
>>> research_paper = Exercise.objects.create(sub_unit=american_revolution, description="Two pages, double spaced")
>>> research_paper.position
1
>>> tea_party = Lesson.objects.create(sub_unit=american_revolution, subject="Boston Tea Party")
>>> tea_party.position
2
"""


__test__ = {'tests': tests}
1 change: 1 addition & 0 deletions positions/examples/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
'positions.examples.todo',
'positions.examples.store',
'positions.examples.photos',
'positions.examples.school',
)

0 comments on commit e343319

Please sign in to comment.