851 # doctest returns tuple (failure_count, test_count) |
851 # doctest returns tuple (failure_count, test_count) |
852 result = self.shell().process_script(testfile) |
852 result = self.shell().process_script(testfile) |
853 if result[0] and result[1]: |
853 if result[0] and result[1]: |
854 raise self.failureException("doctest file '%s' failed" |
854 raise self.failureException("doctest file '%s' failed" |
855 % testfile) |
855 % testfile) |
|
856 |
|
857 # notifications ############################################################ |
|
858 |
|
859 def assertSentEmail(self, subject, recipients=None, nb_msgs=None): |
|
860 """test recipients in system mailbox for given email subject |
|
861 |
|
862 :param subject: email subject to find in mailbox |
|
863 :param recipients: list of email recipients |
|
864 :param nb_msgs: expected number of entries |
|
865 :returns: list of matched emails |
|
866 """ |
|
867 messages = [email for email in MAILBOX |
|
868 if email.message.get('Subject') == subject] |
|
869 if recipients is not None: |
|
870 sent_to = set() |
|
871 for msg in messages: |
|
872 sent_to.update(msg.recipients) |
|
873 self.assertSetEqual(set(recipients), sent_to) |
|
874 if nb_msgs is not None: |
|
875 self.assertEqual(len(MAILBOX), nb_msgs) |
|
876 return messages |
856 |
877 |
857 # deprecated ############################################################### |
878 # deprecated ############################################################### |
858 |
879 |
859 @deprecated('[3.8] use self.execute(...).get_entity(0, 0)') |
880 @deprecated('[3.8] use self.execute(...).get_entity(0, 0)') |
860 def entity(self, rql, args=None, eidkey=None, req=None): |
881 def entity(self, rql, args=None, eidkey=None, req=None): |