def test_show_render_no_feedback(self): delivery = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1).delivery response = self._getas('examiner1', delivery.id) html = response.content self.assertIsNone(delivery.last_feedback) self.assertFalse(cssExists(html, '.read-feedback-box')) self.assertTrue(cssExists(html, '.no-feedback-box')) self.assertEquals(cssGet(html, '.no-feedback-box').text.strip(), 'Write feedbackNo feedback on this delivery.')
def test_filemeta_links_single(self): deliverybuilder = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1) deliverybuilder.add_filemeta(filename='testfile.txt', data='test') response = self._getas('examiner1', deliverybuilder.delivery.id) html = response.content self.assertTrue(cssExists(html, '.delivery_files')) self.assertEquals(len(cssFind(html, '.delivery_files a')), 1) self.assertTrue(cssExists(html, '.delivery_files .btn')) self.assertEquals(cssGet(html, '.delivery_files a.btn').text.strip(), 'testfile.txt')
def test_give_another_chance(self): groupbuilder = self.week1builder\ .add_group(students=[self.student1], examiners=[self.examiner1]) deliverybuilder = groupbuilder\ .add_deadline_in_x_weeks(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1) deliverybuilder.add_failed_feedback(saved_by=UserBuilder('testuser').user) response = self._getas('examiner1', groupbuilder.group.id) html = response.content groupbuilder.reload_from_db() self.assertEquals(groupbuilder.group.feedback, deliverybuilder.delivery.last_feedback) self.assertEquals(groupbuilder.group.delivery_status, 'corrected') self.assertFalse(groupbuilder.group.feedback.is_passing_grade) self.assertTrue(cssExists(html, '.devilry_give_another_chance_box')) box = cssGet(html, '.devilry_give_another_chance_box') self.assertIn('The last feedback for this group is a failing grade.', box.text.strip()) self.assertEquals(cssGet(html, '.devilry_give_another_chance_box form input[name=group_ids]')['value'], str(groupbuilder.group.id)) self.assertEquals(cssGet(html, '.devilry_give_another_chance_box form input[name=give_another_chance]')['value'], 'true') self.assertEquals(cssGet(html, '.devilry_give_another_chance_box form input[name=success_url]')['value'], reverse('devilry_examiner_singlegroupoverview', kwargs={'groupid': groupbuilder.group.id})) self.assertEquals(cssGet(html, '.devilry_give_another_chance_box form input[name=cancel_url]')['value'], reverse('devilry_examiner_singlegroupoverview', kwargs={'groupid': groupbuilder.group.id}))
def test_filemeta_links_multi(self): deliverybuilder = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1) deliverybuilder.add_filemeta( filename='b.txt', data='test') deliverybuilder.add_filemeta(filename='a.txt', data='test') response = self._getas('examiner1', deliverybuilder.delivery.id) html = response.content self.assertTrue(cssExists(html, '.delivery_files')) self.assertEquals(len(cssFind(html, '.delivery_files a')), 3) # One for the "Download files"-button and one for each file self.assertTrue(cssExists(html, '.delivery_files .btn')) self.assertEquals(cssGet(html, '.delivery_files .btn').text.strip(), 'Download files') filenames = map(lambda e: e.text.strip(), cssFind(html, '.delivery_files ul li')) self.assertEquals(filenames, ['a.txt', 'b.txt'])
def test_filemeta_links_nofiles(self): deliverybuilder = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1) response = self._getas('examiner1', deliverybuilder.delivery.id) html = response.content self.assertFalse(cssExists(html, '.delivery_files'))
def test_not_last_delivery_message_not_shown_on_last(self): delivery = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1).delivery response = self._getas('examiner1', delivery.id) html = response.content self.assertFalse(cssExists(html, '.not_last_delivery_message'))
def test_render(self): group1 = self.assignment1builder\ .add_group(examiners=[self.examiner1]).group response = self._postas(self.examiner1, { 'group_ids': [group1.id] }) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, '.page-header h1').text.strip(), 'Add non-electronic delivery') self.assertEquals(cssGet(html, '.page-header .subheader').text.strip(), "Assignment One — duck1010, active") self.assertTrue(cssExists(html, 'input[name=success_url]')) self.assertTrue(cssExists(html, 'input[name=cancel_url]')) self.assertTrue(cssExists(html, 'input[name=group_ids]')) self.assertTrue(cssExists(html, '[name=add_nonelectronic_deliveries_form]')) self.assertTrue(cssExists(html, '[name=submit_cancel]'))
def test_render(self): groupbuilder = self.assignment1builder.add_group(examiners=[self.examiner1]) groupbuilder.add_deadline_in_x_weeks(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1) response = self._post_as(self.examiner1, { 'group_ids': groupbuilder.group.id }) self.assertEquals(response.status_code, 200) html = response.content self.assertTrue(cssExists(html, '#id_points'))
def test_group_naming_anonymous(self): self.week1builder.update(anonymous=True) self.week1builder.add_group( students=[self.student1], examiners=[self.examiner1]) html = self._getas('examiner1', self.week1builder.assignment.id).content self.assertEquals( cssGet(html, '.infolistingtable .group .groupinfo h3 .group_long_displayname').text.strip(), 'candidate-id missing') self.assertFalse(cssExists(html, '.infolistingtable .group .groupinfo h3 .group_short_displayname'))
def test_render(self): myregistry = GradingSystemPluginRegistry() myregistry.add(MockPointsPluginApi) self.assignmentbuilder.update(grading_system_plugin_id=MockPointsPluginApi.id) with patch("devilry.apps.core.models.assignment.gradingsystempluginregistry", myregistry): response = self.get_as(self.admin1) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, ".page-header h1").text.strip(), "Set the maximum possible number of points") self.assertTrue(cssExists(html, "#id_max_points")) self.assertEquals(cssGet(html, "#id_max_points")["value"], "1") # The default value
def test_render(self): myregistry = GradingSystemPluginRegistry() myregistry.add(MockPointsPluginApi) self.assignmentbuilder.update(grading_system_plugin_id=MockPointsPluginApi.id) with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry): response = self.get_as(self.admin1) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, '.page-header h1').text.strip(), 'Set the minumum number of points required to pass') self.assertTrue(cssExists(html, '#id_passing_grade_min_points')) self.assertEquals(cssGet(html, '#id_passing_grade_min_points')['value'], '1') # The default value
def test_give_another_chance_only_when_last_feedback(self): groupbuilder = self.week1builder.add_group( students=[self.student1], examiners=[self.examiner1]) deadlinebuilder = groupbuilder.add_deadline_in_x_weeks(weeks=1) delivery1builder = deadlinebuilder.add_delivery_x_hours_before_deadline(hours=2) delivery2builder = deadlinebuilder.add_delivery_x_hours_before_deadline(hours=1) testuser = UserBuilder('testuser').user delivery2builder.add_failed_feedback(saved_by=testuser) delivery1builder.add_failed_feedback(saved_by=testuser) response = self._getas('examiner1', delivery2builder.delivery.id) html = response.content groupbuilder.reload_from_db() self.assertEquals(groupbuilder.group.feedback, delivery1builder.delivery.last_feedback) self.assertFalse(cssExists(html, '.devilry_give_another_chance_box'))
def test_give_another_chance_only_when_failed(self): groupbuilder = self.week1builder\ .add_group(students=[self.student1], examiners=[self.examiner1]) deliverybuilder = groupbuilder\ .add_deadline_in_x_weeks(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1) deliverybuilder.add_passed_feedback(saved_by=UserBuilder('testuser').user) response = self._getas('examiner1', groupbuilder.group.id) html = response.content groupbuilder.reload_from_db() self.assertEquals(groupbuilder.group.feedback, deliverybuilder.delivery.last_feedback) self.assertEquals(groupbuilder.group.delivery_status, 'corrected') self.assertTrue(groupbuilder.group.feedback.is_passing_grade) self.assertFalse(cssExists(html, '.devilry_give_another_chance_box'))
def test_delivery_render(self): groupbuilder = self.week1builder.add_group( examiners=[self.examiner1]) delivery = groupbuilder.add_deadline_in_x_weeks(weeks=1)\ .add_delivery().delivery with self.settings(DATETIME_FORMAT=_DJANGO_ISODATETIMEFORMAT, USE_L10N=False): response = self._getas('examiner1', groupbuilder.group.id) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, '.delivery h3 a').text.strip(), 'Delivery #1') self.assertEquals(cssGet(html, '.delivery .no-feedback-message').text.strip(), 'No feedback') self.assertEquals(cssGet(html, '.delivery .time_of_delivery').text.strip(), _isoformat_datetime(delivery.time_of_delivery)) self.assertFalse(cssExists(html, '.delivery .after_deadline_message'))
def test_readonly_feedback_render(self): feedback = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1)\ .add_feedback( points=10, grade='10/100', is_passing_grade=False, saved_by=UserBuilder('testuser').user, rendered_view='This is a test.' ).feedback response = self._getas('examiner1', feedback.delivery.id) html = response.content self.assertFalse(cssExists(html, '.no-feedback-box')) self.assertTrue(cssExists(html, '.read-feedback-box')) self.assertEquals(cssGet(html, '.read-feedback-box .feedback_gradebox .feedback_grade').text.strip(), '10/100') self.assertEquals(cssGet(html, '.read-feedback-box .feedback_gradebox .feedback_is_passing_grade').text.strip(), 'failed') self.assertIn('alert-warning', cssGet(html, '.read-feedback-box .feedback_gradebox')['class']) self.assertEquals(cssGet(html, '.read-feedback-box .feedback_rendered_view').text.strip(), 'This is a test.')
def test_render(self): draft = FeedbackDraft.objects.create( points=40, delivery=self.deliverybuilder.delivery, saved_by=self.examiner1, feedbacktext_html='This is a test.' ) response = self._get_as(self.examiner1, draft.id) self.assertEquals(response.status_code, 200) html = response.content self.assertTrue(cssExists(html, '.read-feedback-box')) self.assertEquals(cssGet(html, '.read-feedback-box .feedback_gradebox .feedback_grade').text.strip(), '40/100') self.assertEquals(cssGet(html, '.read-feedback-box .feedback_gradebox .feedback_is_passing_grade').text.strip(), 'passed') self.assertIn('alert-success', cssGet(html, '.read-feedback-box .feedback_gradebox')['class']) self.assertEquals(cssGet(html, '.read-feedback-box .feedback_rendered_view').text.strip(), 'This is a test.')
def test_render_custom_table(self): myregistry = GradingSystemPluginRegistry() myregistry.add(MockPointsPluginApi) self.assignmentbuilder.update( grading_system_plugin_id=MockPointsPluginApi.id, points_to_grade_mapper='custom-table') self.assignmentbuilder.assignment.get_point_to_grade_map().create_map( (0, 'Bad'), (30, 'Better'), (60, 'Good')) with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry): response = self.get_as(self.admin1) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, '.page-header h1').text.strip(), 'Select the grade required to pass') self.assertTrue(cssExists(html, '#id_passing_grade_min_points')) self.assertEquals(len(cssFind(html, '#id_passing_grade_min_points option')), 3) self.assertEquals(cssGet(html, '#id_passing_grade_min_points option[value=0]').text.strip(), 'Bad') self.assertEquals(cssGet(html, '#id_passing_grade_min_points option[value=30]').text.strip(), 'Better') self.assertEquals(cssGet(html, '#id_passing_grade_min_points option[value=60]').text.strip(), 'Good')
def test_add_nonelectronic_delivery_anytime_form(self): groupbuilder = self.week1builder.add_group(examiners=[self.examiner1]) groupbuilder.add_deadline_in_x_weeks(weeks=1) html = self._getas('examiner1', groupbuilder.group.id).content self.assertTrue(cssExists(html, '.devilry_add_nonelectronic_delivery_anytime_form')) self.assertFalse(cssExists(html, '.devilry_missing_expected_delivery_box'))
def test_missing_expected_delivery_box(self): groupbuilder = self.week1builder.add_group(examiners=[self.examiner1]) groupbuilder.add_deadline_x_weeks_ago(weeks=1) html = self._getas('examiner1', groupbuilder.group.id).content self.assertTrue(cssExists(html, '.devilry_missing_expected_delivery_box'))
def test_add_deadline_anytime_form(self): groupbuilder = self.week1builder.add_group(examiners=[self.examiner1]) groupbuilder.add_deadline_in_x_weeks(weeks=1) html = self._getas('examiner1', groupbuilder.group.id).content self.assertTrue(cssExists(html, '.devilry_add_deadline_anytime_form')) self.assertFalse(cssExists(html, '.devilry_give_another_chance_box'))
def test_render(self): response = self._get_as(self.examiner1) self.assertEquals(response.status_code, 200) html = response.content self.assertTrue(cssExists(html, '#id_points'))