Esempio n. 1
0
    def test_update(self):
        periodbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
            .add_admins(self.testuser)

        publishing_time = DateTimeBuilder.now().plus(days=10)
        assignment1builder = periodbuilder.add_assignment('assignment1',
            long_name='Assignment One',
            anonymous=True,
            publishing_time=publishing_time,
            deadline_handling=1,
            max_points=10, # Should not be touched by the update
            passing_grade_min_points=8 # Should not be touched by the update
        )

        new_publishing_time = DateTimeBuilder.now().plus(days=20).replace(second=0, microsecond=0, tzinfo=None)
        response = self._postas(assignment1builder.assignment.id, self.testuser, {
            'long_name': 'Test One',
            'short_name': 'test1',
            'anonymous': '',
            'publishing_time': isoformat_datetime(new_publishing_time),
            'deadline_handling': 0
        })
        self.assertEquals(response.status_code, 302)
        assignment1builder.reload_from_db()
        assignment = assignment1builder.assignment
        self.assertEquals(assignment.long_name, 'Test One')
        self.assertEquals(assignment.short_name, 'test1')
        self.assertFalse(assignment.anonymous)
        self.assertEquals(assignment.publishing_time, new_publishing_time)
        self.assertEquals(assignment.deadline_handling, 0)
        self.assertEquals(assignment.max_points, 10)
        self.assertEquals(assignment.passing_grade_min_points, 8)
Esempio n. 2
0
    def test_render(self):
        periodbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
            .add_admins(self.testuser)

        publishing_time = DateTimeBuilder.now().plus(days=10)
        assignment1builder = periodbuilder.add_assignment('assignment1',
            long_name='Assignment One',
            anonymous=True,
            publishing_time=publishing_time,
            deadline_handling=1)
        response = self._getas(assignment1builder.assignment.id, self.testuser)
        self.assertEquals(response.status_code, 200)
        html = response.content
        self.assertEquals(cssGet(html, 'input[name=long_name]')['value'], 'Assignment One')
        self.assertEquals(cssGet(html, 'select[name=deadline_handling] option[value=1]')['selected'], 'selected')
        self.assertEquals(cssGet(html, 'input[name=publishing_time]')['value'],
            isoformat_datetime(publishing_time))
        self.assertEquals(cssGet(html, 'input[name=short_name]')['value'], 'assignment1')