Skip to content

Commit

Permalink
demonstrate issue in test
Browse files Browse the repository at this point in the history
  • Loading branch information
sdreher committed Nov 4, 2015
1 parent c4df30e commit 74ed978
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mediathread/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def responses_by_course(self, course, viewer):
projects = Project.objects.filter(
course=course, project_type=PROJECT_TYPE_COMPOSITION)

# filter down to responses
# filter down to responses only based on the collaboration parent state
collaborations = Collaboration.objects.get_for_object_list(projects)
collaborations = collaborations.filter(_parent__isnull=False)
collaborations = collaborations.order_by('object_pk')
Expand Down
27 changes: 27 additions & 0 deletions mediathread/projects/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def test_responses_by_course(self):
response = ProjectFactory.create(
course=self.sample_course, author=self.student_one,
policy='PrivateEditorsAreOwners', parent=self.assignment)

self.assert_responses_by_course(self.student_one, [response], [])
self.assert_responses_by_course(self.instructor_one, [], [response])
self.assert_responses_by_course(self.student_two, [], [response])
Expand Down Expand Up @@ -267,6 +268,32 @@ def test_responses_by_course(self):
self.assert_responses_by_course(self.student_two,
[response, response2], [])

def test_many_responses_by_course(self):
# additional responses ensure selected collaborations/projects
# don't line-up by default

response1 = ProjectFactory.create(
title='Zeta', course=self.sample_course, author=self.student_three,
date_submitted=datetime.now(), policy='PublicEditorsAreOwners',
parent=self.assignment)

# private response
response2 = ProjectFactory.create(
title='Omega', course=self.sample_course, author=self.student_one,
policy='PrivateEditorsAreOwners', parent=self.assignment)

response3 = ProjectFactory.create(
title='Beta', course=self.sample_course, author=self.student_two,
date_submitted=datetime.now(), policy='PublicEditorsAreOwners',
parent=self.assignment)

self.assert_responses_by_course(self.student_one,
[response1, response2, response3], [])
self.assert_responses_by_course(self.instructor_one,
[response1, response3], [response2])
self.assert_responses_by_course(self.student_two,
[response1, response3], [response2])

def test_project_clean_date_field(self):
try:
self.assignment.due_date = datetime(2012, 3, 13, 0, 0)
Expand Down

0 comments on commit 74ed978

Please sign in to comment.