Changeset 16299 for main/waeup.kofa/trunk/src/waeup/kofa/students/tests
- Timestamp:
- 4 Nov 2020, 17:52:22 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r16266 r16299 90 90 def setUp(self): 91 91 super(StudentsFullSetup, self).setUp() 92 self.setup_logging() 92 93 93 94 # Setup a sample site for each test … … 252 253 253 254 layer = FunctionalLayer 255 256 def setup_logging(self): 257 # setup a log-handler that catches all fake mailer output 258 self.stream = StringIO() 259 handler = logging.StreamHandler(self.stream) 260 logger = logging.getLogger('test.smtp') 261 logger.addHandler(handler) 262 logger.setLevel(logging.INFO) 263 return 264 265 def get_fake_smtp_output(self): 266 # get output generated by fake mailer 267 self.stream.flush() 268 self.stream.seek(0) 269 return self.stream.read() 254 270 255 271 def test_anonymous_access(self): … … 432 448 self.assertTrue('No student found' in self.browser.contents) 433 449 return 450 451 def test_send_bulk_emails(self): 452 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 453 self.browser.open(self.manage_container_path) 454 self.browser.getLink("Add student").click() 455 self.assertEqual(self.browser.headers['Status'], '200 Ok') 456 self.assertEqual(self.browser.url, self.add_student_path) 457 self.browser.getControl(name="form.firstname").value = 'Bob' 458 self.browser.getControl(name="form.lastname").value = 'Tester' 459 self.browser.getControl(name="form.reg_number").value = '1234' 460 self.browser.getControl("Create student").click() 461 self.assertTrue('Student record created' in self.browser.contents) 462 self.browser.getLink("Manage").click() 463 self.browser.getControl(name="form.email").value = 'uli@uni.ng' 464 self.browser.getControl(name="form.sex").value = ['m'] 465 self.browser.getControl("Save").click() 466 # We can find Anna and Bob 467 self.browser.open(self.manage_container_path) 468 self.browser.getControl(name="searchtype").value = ['student_id'] 469 self.browser.getControl(name="searchterm").value = '*' 470 self.browser.getControl("Find student(s)").click() 471 self.assertTrue('Anna Tester' in self.browser.contents) 472 self.assertTrue('Bob Tester' in self.browser.contents) 473 # We can send bulk emails 474 ctrl = self.browser.getControl(name='entries') 475 ctrl.getControl(value='K1000000').selected = True 476 ctrl.getControl(value='K1000001').selected = True 477 self.browser.getControl("Send bulk", index=0).click() 478 self.assertTrue('K1000000 <aa@aa.ng>,K1000001 <uli@uni.ng>' 479 in self.browser.contents) 480 self.browser.getControl(name="form.subject").value = 'Test' 481 self.browser.getControl(name="form.body").value = 'Hello world' 482 self.browser.getControl("Send message").click() 483 self.assertTrue('Your message has been sent' in self.browser.contents) 484 self.assertMatches( 485 u'Sending email from no-reply@waeup.org to contact@waeup.org:\n' 486 u'Message:\n' 487 u'msg: MIME-Version: 1.0\n' 488 u'msg: Content-Type: text/plain; charset="us-ascii"\n' 489 u'msg: Content-Transfer-Encoding: 7bit\n' 490 u'msg: From: Manager <no-reply@waeup.org>\n' 491 u'msg: To: Manager <contact@waeup.org>\n' 492 u'msg: Bcc: K1000000 <aa@aa.ng>,K1000001 <uli@uni.ng>\n' 493 u'msg: Reply-To: Manager <contact@waeup.org>\n' 494 u'msg: Subject: Test\n' 495 u'msg: \n' 496 u'msg: Hello world\n' 497 u'msg: \n' 498 u'msg: ---\n' 499 u'msg: Manager (id: zope.mgr)\n' 500 u'msg: Sample University\n' 501 u'msg: \n', 502 self.get_fake_smtp_output() 503 ) 434 504 435 505 def test_add_graduated_students(self):
Note: See TracChangeset for help on using the changeset viewer.