Example #1
0
 def test_submission_form_copy(self):
     submission_form = create_submission_form(presenter=self.user)
     response = self.client.get(reverse('ecs.core.views.copy_latest_submission_form', kwargs={'submission_pk': submission_form.submission.pk}))
     self.failUnlessEqual(response.status_code, 302)
     url = reverse('ecs.core.views.copy_submission_form', kwargs={'submission_form_pk': submission_form.pk})
     self.failUnlessEqual(url, urlsplit(response['Location']).path)
 
     response = self.client.get(url)
     self.failUnlessEqual(response.status_code, 302)
     target_url = response['Location']
     response = self.client.get(target_url)
     self.failUnlessEqual(response.status_code, 200)
     self.failUnlessEqual(response.context['form'].initial.get('project_title'), submission_form.project_title)
Example #2
0
    def setUp(self, *args, **kwargs):
        rval = super(VoteRemindersTest, self).setUp(*args, **kwargs)

        # alice is the submitter and bob is the postmaster
        settings.ECSMAIL['postmaster'] = 'bob'

        # there has to be a test submission
        self.submission_form = create_submission_form()
        self.submission_form.submission.thesis = False
        self.submission_form.submission.save()
        self.submission_form.project_type_education_context = None
        self.submission_form.submitter_email = self.alice.email
        self.submission_form.save()

        self.submission_form_thesis = create_submission_form()
        self.submission_form_thesis.submission.thesis = True
        self.submission_form_thesis.submitter_email = self.alice.email
        self.submission_form_thesis.submission.save()

        self.january_meeting = Meeting.objects.create(title='January Meeting', start=datetime(2042, 1, 1))
        self.february_meeting = Meeting.objects.create(title='February Meeting', start=datetime(2042, 2, 1))
        self.march_meeting = Meeting.objects.create(title='March Meeting', start=datetime(2042, 3, 1))
        self.april_meeting = Meeting.objects.create(title='April Meeting', start=datetime(2042, 4, 1))

        for meeting in (self.january_meeting, self.february_meeting, self.march_meeting, self.april_meeting):
            meeting.started = meeting.start
            meeting.ended = meeting.start + timedelta(hours=8)
            meeting.deadline = meeting.start - timedelta(days=7)
            meeting.deadline_diplomathesis = meeting.start - timedelta(days=2)
            meeting.save()

        self.january_meeting.add_entry(submission=self.submission_form.submission, duration_in_seconds=60)
        self.january_meeting.add_entry(submission=self.submission_form_thesis.submission, duration_in_seconds=60)

        self.vote = Vote.objects.create(submission_form=self.submission_form, top=self.january_meeting.timetable_entries.get(submission=self.submission_form.submission), result='2')
        self.vote_thesis = Vote.objects.create(submission_form=self.submission_form_thesis, top=self.january_meeting.timetable_entries.get(submission=self.submission_form_thesis), result='2')

        return rval
Example #3
0
File: base.py Project: emulbreh/ecs
    def test_automatic_meeting_assignment(self):
        from ecs.core.tests.submissions import create_submission_form
        from ecs.core.models import Submission
        s = create_submission_form().submission

        step = timedelta(days=1)
        start = datetime.now() + step
        meetings = [Meeting.objects.create(start=start + step * i, title="M%s" % i) for i in range(3)]

        def schedule(i):
            meetings[i].add_entry(submission=s, duration=timedelta(hours=1))
            
        def unschedule(i):
            meetings[i].timetable_entries.all().delete()
            
        def check_next(i):
            self.assertEqual(Submission.objects.get(pk=s.pk).next_meeting, None if i is None else meetings[i])

        schedule(1)
        check_next(1)

        schedule(2)
        check_next(1)

        unschedule(1)
        check_next(2)

        unschedule(2)
        check_next(None)
        
        schedule(2)
        check_next(2)
        
        schedule(0)
        check_next(0)
        
        schedule(1)
        check_next(0)
        
        schedule(2)
        check_next(0)

        unschedule(0)
        check_next(1)
Example #4
0
    def test_meeting_assistant(self):
        meeting = Meeting.objects.create(start=self.start)
        submission = create_submission_form().submission
        e0 = meeting.add_entry(duration_in_seconds=42, submission=submission)
        e1 = meeting.add_entry(duration_in_seconds=42*42)

        response = self.client.get(reverse('ecs.meetings.views.meeting_assistant', kwargs={'meeting_pk': meeting.pk}))
        self.failUnlessEqual(response.status_code, 200)
        
        response = self.client.get(reverse('ecs.meetings.views.meeting_assistant_start', kwargs={'meeting_pk': meeting.pk}))
        self.failUnlessEqual(response.status_code, 302)
        meeting = self.refetch(meeting)
        self.failUnless(meeting.started)
        
        response = self.client.get(reverse('ecs.meetings.views.meeting_assistant', kwargs={'meeting_pk': meeting.pk}))
        self.failUnlessEqual(response.status_code, 302)
        
        response = self.client.get(reverse('ecs.meetings.views.meeting_assistant_top', kwargs={'meeting_pk': meeting.pk, 'top_pk': e0.pk}))
        self.failUnlessEqual(response.status_code, 200)
        
        response = self.client.post(reverse('ecs.meetings.views.meeting_assistant_top', kwargs={'meeting_pk': meeting.pk, 'top_pk': e0.pk}), {
            'close_top': 'on',
            'result': '1',
        })
        self.failUnless(response.status_code, 302)
        self.failIf(self.refetch(e0).is_open)

        response = self.client.get(reverse('ecs.meetings.views.meeting_assistant_stop', kwargs={'meeting_pk': meeting.pk}))
        self.failUnlessEqual(response.status_code, 404)

        response = self.client.post(reverse('ecs.meetings.views.meeting_assistant_top', kwargs={'meeting_pk': meeting.pk, 'top_pk': e1.pk}), {
            'close_top': 'on',
            'result': '2',
        })
        self.failUnless(response.status_code, 302)
        self.failIf(self.refetch(e1).is_open)
        
        response = self.client.get(reverse('ecs.meetings.views.meeting_assistant_stop', kwargs={'meeting_pk': meeting.pk}))
        self.failUnlessEqual(response.status_code, 302)
        meeting = self.refetch(meeting)
        self.failUnless(meeting.ended)
Example #5
0
    def setUp(self):
        super(SubmissionAuthTestCase, self).setUp()
        self.additional_review_user = self._create_test_user('additional_review', approved_by_office=True)
        self.anyone = self._create_test_user('anyone', approved_by_office=True)
        self.board_member_user = self._create_test_user('board_member', approved_by_office=True, board_member=True)
        self.expedited_review_user = self._create_test_user('expedited_review', approved_by_office=True, expedited_review=True)
        self.external_review_user = self._create_test_user('external_review', approved_by_office=True, external_review=True)
        self.insurance_review_user = self._create_test_user('insurance_review', approved_by_office=True, insurance_review=True)
        self.internal_user = self._create_test_user('internal', approved_by_office=True, internal=True)
        self.primary_investigator_user = self._create_test_user('primary_investigator', approved_by_office=True)
        self.sponsor_user = self._create_test_user('sponsor', approved_by_office=True)
        self.submitter_user = self._create_test_user('submitter', approved_by_office=True)
        self.thesis_review_user = self._create_test_user('thesis_review', approved_by_office=True, thesis_review=True)
    
        self.another_board_member_user = self._create_test_user('another_board_member', approved_by_office=True, board_member=True)
        self.unapproved_user = self._create_test_user('unapproved_user')
    
        sf = create_submission_form()
        sf.submitter = self.submitter_user
        sf.sponsor = self.sponsor_user
        sf.additional_review_user = self.additional_review_user
        sf.project_title = self.EC_NUMBER
        sf.save()
    
        investigator = sf.investigators.all()[0]
        investigator.user = self.primary_investigator_user
        investigator.save()

        sf.submission.ec_number = self.EC_NUMBER
        sf.submission.additional_reviewers.add(self.additional_review_user)
        sf.submission.external_reviewer_name = self.external_review_user

        meeting = Meeting.objects.create(start=datetime.datetime.now())
        entry = meeting.add_entry(submission=sf.submission, duration_in_seconds=60)
        entry.add_user(self.board_member_user)
        sf.submission.next_meeting = meeting
        sf.submission.save()

        self.sf = sf
Example #6
0
    def test_submission_form_search(self):
        create_submission_form(20200001)
        create_submission_form(20200042)
        create_submission_form(20209942)
        url = reverse('ecs.core.views.submission_forms')
        
        response = self.client.get(url)
        self.failUnlessEqual(response.status_code, 200)
        self.failUnlessEqual(len(response.context['unscheduled_submissions']), 3)
        
        response = self.client.get(url, {'keyword': '42'})
        self.failUnless(response.status_code, 200)
        self.failUnlessEqual(len(response.context['unscheduled_submissions']), 2)
        
        response = self.client.get(url, {'keyword': '2020/42'})
        self.failUnless(response.status_code, 200)
        self.failUnlessEqual(len(response.context['unscheduled_submissions']), 1)

        response = self.client.get(url, {'keyword': '42/2020'})
        self.failUnless(response.status_code, 200)
        self.failUnlessEqual(len(response.context['unscheduled_submissions']), 1)
Example #7
0
 def test_submission_pdf(self):
     submission_form = create_submission_form()
     response = self.client.get(reverse('ecs.core.views.submission_pdf', kwargs={'submission_form_pk': submission_form.pk}))
     self.failUnlessEqual(response.status_code, 200)
     self.failUnlessEqual(response['Content-Type'], 'application/pdf')
     self.failUnlessEqual(response.content[:4], '%PDF')
Example #8
0
 def test_readonly_submission_form(self):
     submission_form = create_submission_form()
     response = self.client.get(reverse('ecs.core.views.readonly_submission_form', kwargs={'submission_form_pk': submission_form.pk}))
     self.failUnlessEqual(response.status_code, 200)