def test_serialize(self): # Test serialization of the entire GroupFeedbackSetList. # Create AssignmentGroup testgroup1 = mommy.make('core.AssignmentGroup') testgroup2 = mommy.make('core.AssignmentGroup') # Create examiner testexaminer = mommy.make(settings.AUTH_USER_MODEL, shortname='donduc', fullname='Donald Duck') # Create FeedbackSet test_feedbackset1 = devilry_group_mommy_factories.feedbackset_first_attempt_published( grading_points=1, grading_published_by=testexaminer, group=testgroup1) test_feedbackset2 = devilry_group_mommy_factories.feedbackset_first_attempt_published( grading_points=1, grading_published_by=testexaminer, group=testgroup2) groupfeedbacksetlist = groups_groupedby_relatedstudent_and_assignments.GroupFeedbackSetList( ) groupfeedbacksetlist.append((testgroup1, test_feedbackset1)) groupfeedbacksetlist.append((testgroup2, test_feedbackset2)) serialized = groupfeedbacksetlist.serialize() self.assertEquals(2, len(serialized)) self.assertEquals(serialized[0]['id'], testgroup1.id) self.assertEquals(serialized[1]['id'], testgroup2.id)
def test_serialize_feedbackset(self): # Test serialization of feedbackset. # Create FeedbackSet feedbackset = devilry_group_mommy_factories.feedbackset_first_attempt_published( grading_points=1, grading_published_by=mommy.make(settings.AUTH_USER_MODEL, shortname='donduc', fullname='Donald Duck')) groupfeedbacksetlist = groups_groupedby_relatedstudent_and_assignments.GroupFeedbackSetList( ) serialized_feedbackset = groupfeedbacksetlist._serialize_feedbackset( feedbackset) self.assertEquals(serialized_feedbackset['id'], feedbackset.id) self.assertEquals(serialized_feedbackset['grade'], 'NA') self.assertEquals(serialized_feedbackset['points'], feedbackset.grading_points) self.assertEquals(serialized_feedbackset['published_by'], feedbackset.grading_published_by) self.assertEquals(serialized_feedbackset['published'], feedbackset.grading_published_datetime) self.assertEquals(serialized_feedbackset['deadline'], feedbackset.current_deadline())
def test_append_errorhandling_not_a_tuple(self): # Test that adding something not a tuple will raise a ValueError. groupfeedbacksetlist = groups_groupedby_relatedstudent_and_assignments.GroupFeedbackSetList( ) with self.assertRaisesMessage( ValueError, 'Appended object must be a tuple of ' 'objects (AssignmentGroup, FeedbackSet).'): groupfeedbacksetlist.append(1)
def test_append_errorhandling_not_supported_objects(self): # Test that adding a tuple with objects not of the required type will raise a ValueError. groupfeedbacksetlist = groups_groupedby_relatedstudent_and_assignments.GroupFeedbackSetList( ) with self.assertRaisesMessage( ValueError, 'Objects in tuple must be of (AssignmentGroup, FeedbackSet) ' 'in that order.'): groupfeedbacksetlist.append((1, 1))
def test_serialize_group(self): # Test serialization of AssignmentGroup # Create AssignmentGroup testgroup = mommy.make('core.AssignmentGroup') # Create FeedbackSet feedbackset = devilry_group_mommy_factories.feedbackset_first_attempt_published( grading_points=1, grading_published_by=mommy.make(settings.AUTH_USER_MODEL, shortname='donduc', fullname='Donald Duck') ) groupfeedbacksetlist = groups_groupedby_relatedstudent_and_assignments.GroupFeedbackSetList() serialized_group = groupfeedbacksetlist._serialize_group(testgroup, feedbackset) self.assertEquals(serialized_group['id'], testgroup.id) self.assertEquals(type(serialized_group['feedbackset']), dict) self.assertEquals(serialized_group['status'], testgroup.get_status())