I need to compose a unit test to cover this scenario:
- manually assign multiple assignments to a student
- use the same query that is used for the student dashboard to ensure that the only assignments returned are the ones with a start date <= today's date
- ensure that the student only sees the first assignment (with the earliest start date) in the list.
Note: I would like to only use the built in django.test features for now, if possible
from my home/views.py file
Expand|Select|Wrap|Line Numbers
- @login_required
- def index(request):
- user_type = request.user.type.text
- if user_type == 'Student':
- """ Only return the first test so the student sees one test at a time"""
- assignment = Assignment.objects.filter(
- student=request.user,
- start_date__lte=datetime.date.today(),
- completed=False).first()
- if (assignment):
- context = {
- 'test_pk': assignment.test.pk,
- }
- else:
- context = {}
- return render(request, 'home/student.html', context)