Пример #1
0
    def test_echoJenkinsVars(self):
        with self.m_environ:
            env_string_io = StringIO()
            for key in os.environ:
                print(key + ' = ' + os.environ[key], file=env_string_io)

        expected_string = '''
================================================================================
Jenkins Environment Variables:
- WORKSPACE    : /dev/null/TEST_WORKSPACE

================================================================================
Environment:

  pwd = {cwd}

{environ}
================================================================================
'''.format(cwd=os.getcwd(), environ=env_string_io.getvalue())

        with mock.patch('sys.stdout', new_callable=StringIO) as m_stdout, \
            self.m_environ:
            PullRequestLinuxDriverMerge.echoJenkinsVars(
                os.path.join(os.sep, 'dev', 'null', 'TEST_WORKSPACE'))
        self.assertEqual(expected_string, m_stdout.getvalue())
Пример #2
0
    def test_echoJenkinsVars(self):
        print(
            "BEGIN:  Test PullRequestLinuxDriverMerge.py :: `echoJenkinsVars()`:"
        )
        with self.m_environ:
            env_string_io = StringIO()
            for key in os.environ:
                print(key + ' = ' + os.environ[key], file=env_string_io)

        tmp_path = os.path.join(os.sep, 'dev', 'null', 'TEST_WORKSPACE')

        with mock.patch('sys.stdout',
                        new_callable=StringIO) as m_stdout, self.m_environ:
            PRMerge.echoJenkinsVars(tmp_path)

        stdout_actual = m_stdout.getvalue()
        self.assertIn("JOB_BASE_NAME = TEST_JOB_BASE_NAME", stdout_actual)
        self.assertIn("JOB_NAME = TEST_JOB_NAME", stdout_actual)
        self.assertIn("WORKSPACE = /dev/null/TEST_WORKSPACE", stdout_actual)
        self.assertIn("NODE_NAME = TEST_NODE_NAME", stdout_actual)
        print(
            "FINISH: Test PullRequestLinuxDriverMerge.py :: `echoJenkinsVars()`:"
        )
        return