def testAlertEmailIsSentWhenClientKilledDuringHunt(self):
    self.email_messages = []

    def SendEmail(address, sender, title, message, **_):
      self.email_messages.append(dict(address=address, sender=sender,
                                      title=title, message=message))

    with hunts.GRRHunt.StartHunt(
        hunt_name="GenericHunt",
        flow_runner_args=flow_runner.FlowRunnerArgs(
            flow_name="FlowWithOneClientRequest"),
        client_rate=0, crash_alert_email="crashes@example.com",
        token=self.token) as hunt:
      hunt.Run()
      hunt.StartClients(hunt.session_id, self.client_id)

    with utils.Stubber(email_alerts.EMAIL_ALERTER, "SendEmail", SendEmail):
      client = test_lib.CrashClientMock(self.client_id, self.token)
      test_lib.TestHuntHelper(
          client, [self.client_id],
          token=self.token, check_flow_errors=False)

    self.assertEqual(len(self.email_messages), 2)
    self.assertListEqual([self.email_messages[0]["address"],
                          self.email_messages[1]["address"]],
                         ["crashes@example.com",
                          config_lib.CONFIG["Monitoring.alert_email"]])
Puts the transaction manager into a manual state: managed transactions have
dataset/ETHPy150Open google/grr/grr/lib/flows/general/administrative_test.py/TestAdministrativeFlows.testAlertEmailIsSentWhenClientKilledDuringHunt--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.4/django/db/backends/__init__.py/BaseDatabaseWrapper.managed