def setUp(self):

        os.environ[TEST_MACHINE_IP_ENV_VARIABLE] = '15.126.205.73'

        if TEST_MACHINE_IP_ENV_VARIABLE not in os.environ:
            raise RuntimeError('TEST_MACHINE_IP environment variable must '
                               'be set and point to an existing server with '
                               'WinRM configured properly')

        self.runner = WinRMRunner(
            session_config=WinRMRunnerTest._create_session()
        )
    def test_full_lifecycle(self):
        tasks.install(ctx=self._create_context('install'))
        tasks.start(ctx=self._create_context('start'))

        def _create_session():
            return {
                'host': os.environ[TEST_MACHINE_IP_ENV_VARIABLE],
                'user': '******',
                'password': '******'
            }

        # Retrieve registered plugins
        from windows_agent_installer.winrm_runner import WinRMRunner
        from windows_agent_installer.tasks import RUNTIME_AGENT_PATH
        from windows_agent_installer.tasks import AGENT_EXEC_FILE_NAME
        runner = WinRMRunner(session_config=_create_session())
        response = runner.run(
            '{0}\Scripts\celery.exe inspect registered'
            .format(RUNTIME_AGENT_PATH))

        # Assert agent has necessary includes
        self.assertTrue(AGENT_INCLUDES in response.std_out)

        # Restart the service
        tasks.restart(ctx=self._create_context('restart'))

        # Stop the service
        tasks.stop(ctx=self._create_context('stop'))

        # Uninstall, delete the files
        tasks.uninstall(ctx=self._create_context('uninstall'))

        # Assert files are gone
        self.assertFalse(runner.exists(path=RUNTIME_AGENT_PATH))
        self.assertFalse(
            runner.exists(
                path='C:\{0}'.format(AGENT_EXEC_FILE_NAME)))