def test_add_application_cleanups_does_nothing_when_app_failed(self):
     state = {
         'status': UpstartApplicationLauncher.Failed,
     }
     launcher = UpstartApplicationLauncher(Mock())
     launcher.setUp()
     launcher._maybe_add_application_cleanups(state)
     self.assertThat(launcher._cleanups._cleanups, HasLength(0))
 def test_add_application_cleanups_adds_both_cleanup_actions(self):
     token = self.getUniqueString()
     state = {
         'status': UpstartApplicationLauncher.Started,
         'expected_app_id': token,
     }
     launcher = UpstartApplicationLauncher(Mock())
     launcher.setUp()
     launcher._maybe_add_application_cleanups(state)
     self.assertThat(
         launcher._cleanups._cleanups,
         Contains((launcher._attach_application_log, (token, ), {})))
     self.assertThat(launcher._cleanups._cleanups,
                     Contains((launcher._stop_application, (token, ), {})))