def test_max_autoresponses_per_day(self): # The last one we sent was the last one we should send today. Instead # of sending an automatic response, send them the "no more today" # message. config.push('max-1', """ [mta] max_autoresponses_per_day: 1 """) # Simulate a response having been sent to an address already. anne = getUtility(IUserManager).create_address('*****@*****.**') response_set = IAutoResponseSet(self._mlist) response_set.response_sent(anne, Response.hold) # Trigger the sending of a "last response for today" using the default # language (i.e. the mailing list's preferred language). autorespond_to_sender(self._mlist, '*****@*****.**') # So first, there should be one more hold response sent to the user. self.assertEqual(response_set.todays_count(anne, Response.hold), 2) # And the virgin queue should have the message in it. messages = get_queue_messages('virgin') self.assertEqual(len(messages), 1) # Remove the variable headers. message = messages[0].msg self.assertTrue('message-id' in message) del message['message-id'] self.assertTrue('date' in message) del message['date'] self.eq(messages[0].msg.as_string(), """\ MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Subject: Last autoresponse notification for today From: [email protected] To: [email protected] Precedence: bulk We have received a message from your address <*****@*****.**> requesting an automated response from the [email protected] mailing list. The number we have seen today: 1. In order to avoid problems such as mail loops between email robots, we will not be sending you any further responses today. Please try again tomorrow. If you believe this message is in error, or if you have any questions, please contact the list owner at [email protected].""")
def test_max_autoresponses_per_day(self): # The last one we sent was the last one we should send today. Instead # of sending an automatic response, send them the "no more today" # message. Start by simulating a response having been sent to an # address already. anne = getUtility(IUserManager).create_address('*****@*****.**') response_set = IAutoResponseSet(self._mlist) response_set.response_sent(anne, Response.hold) # Trigger the sending of a "last response for today" using the default # language (i.e. the mailing list's preferred language). autorespond_to_sender(self._mlist, '*****@*****.**') # So first, there should be one more hold response sent to the user. self.assertEqual(response_set.todays_count(anne, Response.hold), 2) # And the virgin queue should have the message in it. messages = get_queue_messages('virgin') self.assertEqual(len(messages), 1) # Remove the variable headers. message = messages[0].msg self.assertIn('message-id', message) del message['message-id'] self.assertIn('date', message) del message['date'] self.assertMultiLineEqual( messages[0].msg.as_string(), """\ MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Subject: Last autoresponse notification for today From: [email protected] To: [email protected] Precedence: bulk We have received a message from your address <*****@*****.**> requesting an automated response from the [email protected] mailing list. The number we have seen today: 1. In order to avoid problems such as mail loops between email robots, we will not be sending you any further responses today. Please try again tomorrow. If you believe this message is in error, or if you have any questions, please contact the list owner at [email protected].""")