Ignore:
Timestamp:
26 Nov 2011, 21:39:11 (13 years ago)
Author:
Henrik Bettermann
Message:

Add tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7205 r7218  
    368368        return
    369369
    370     def test_manage_access_wo_certificate(self):
    371         # Managers can access studycourse even if student
    372         # doesn't have a certificate
    373         student = Student()
    374         student.fullname = u'Lazy Student'
    375         self.app['students'].addStudent(student)
    376         student_id = student.student_id
     370    def test_manage_remove_department(self):
     371        # Lazy student is studying CERT1
     372        lazystudent = Student()
     373        lazystudent.fullname = u'Lazy Student'
     374        self.app['students'].addStudent(lazystudent)
     375        student_id = lazystudent.student_id
    377376        student_path = self.container_path + '/' + student_id
     377        lazystudent['studycourse'].certificate = self.certificate
     378        notify(grok.ObjectModifiedEvent(lazystudent))
    378379        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    379380        self.browser.open(student_path + '/studycourse')
     381        self.assertTrue('CERT1' in self.browser.contents)
     382        # After some years the department is removed
     383        del self.app['faculties']['fac1']['dep1']
     384        # So CERT1 does no longer exist and lazy student's
     385        # certificate reference is removed too
     386        self.browser.open(student_path + '/studycourse')
    380387        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    381388        self.assertEqual(self.browser.url, student_path + '/studycourse')
     389        self.assertFalse('CERT1' in self.browser.contents)
    382390        self.assertMatches('...<div class="widget">Nothing</div>...',
    383391                           self.browser.contents)
     
    705713            '...<a href="http://localhost/app/faculties/fac1/dep1">...',
    706714            self.browser.contents)
    707         # CO can view the student
     715        # CO can view the student ...
    708716        self.browser.open(self.clearance_student_path)
    709717        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    710718        self.assertEqual(self.browser.url, self.clearance_student_path)
     719        # ... but not other students
     720        other_student = Student()
     721        other_student.fullname = u'Dep2 Student'
     722        self.app['students'].addStudent(other_student)
     723        other_student_path = (
     724            'http://localhost/app/students/%s' % other_student.student_id)
     725        self.assertRaises(
     726            Unauthorized, self.browser.open, other_student_path)
    711727        # Only in state clearance requested the CO does see the 'Clear' button
     728        self.browser.open(self.clearance_student_path)
    712729        self.assertFalse('Clear student' in self.browser.contents)
    713730        IWorkflowInfo(self.student).fireTransition('request_clearance')
     
    733750        self.assertTrue('Student is in the wrong state'
    734751            in self.browser.contents)
     752        # The CO can go to his department throug the my_roles page
     753        self.browser.open('http://localhost/app/users/mrclear/my_roles')
     754        self.browser.getLink("http://localhost/app/faculties/fac1/dep1").click()
     755        # and view the list of students
     756        self.browser.getLink("Show students").click()
     757        self.assertTrue(self.student_id in self.browser.contents)
    735758
    736759    def test_student_change_password(self):
Note: See TracChangeset for help on using the changeset viewer.