def test_loan_return_event_error(self, mock_logging): self.enroll_test_device(loanertest.TEST_DIR_DEVICE_DEFAULT) self.testbed.mock_raiseevent.side_effect = events.EventActionsError( 'Failed.') self.test_device._loan_return(loanertest.USER_EMAIL) self.assertEqual(mock_logging.call_count, 1)
def test_remind_one(self, mock_logging): """Tests that one device should be reminded.""" self.setup_events() self.setup_devices() # pylint: disable=no-value-for-parameter # Remindable. self.device1.due_date = _NOW + datetime.timedelta(hours=23) self.device1.next_reminder = device_model.Reminder( time=_NOW - datetime.timedelta(minutes=1), level=0) self.device1.put() # Not yet remindable. self.device2.due_date = _NOW + datetime.timedelta(hours=25) self.device2.next_reminder = device_model.Reminder( time=_NOW + datetime.timedelta(hours=2), level=0) self.device1.put() self.device2.put() self.testbed.mock_raiseevent.reset_mock() self.testbed.mock_raiseevent.side_effect = events.EventActionsError( 'Failed.') response = self.testapp.get( r'/_cron/run_reminder_events?remind_for_devices=true') self.assertEqual(response.status_int, 200) mock_logging.info.assert_any_call( run_reminder_events._DEVICE_REMINDING_NOW_MSG, self.device1.identifier, 0) self.assertEqual(mock_logging.error.call_count, 1) self.testbed.mock_raiseevent.assert_called_once_with( event_name='reminder_level_0', device=self.device1)