test_metrics_xml_to_csv.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. Unit tests for metrics_xml_to_csv.py
  6. """
  7. import datetime
  8. import unittest
  9. import unittest.mock as mock
  10. import os
  11. import ctest_metrics_xml_to_csv
  12. class TestMetricsXMLtoCSV(unittest.TestCase):
  13. @mock.patch('os.path.exists', mock.MagicMock(side_effect=[True, True]))
  14. @mock.patch('builtins.open')
  15. def test_GetTestXMLPath_PathExists_ReturnsCorrect(self, mock_open):
  16. mock_build_path = 'mock_build_path'
  17. mock_xml_file = 'mock_xml_file'
  18. mock_opened_file = mock.MagicMock()
  19. mock_opened_file.__enter__.return_value.readline.return_value = 'mock_folder_name'
  20. mock_open.return_value = mock_opened_file
  21. under_test = ctest_metrics_xml_to_csv._get_test_xml_path(mock_build_path, mock_xml_file)
  22. assert under_test == os.path.join(mock_build_path, ctest_metrics_xml_to_csv.TESTING_DIR, 'mock_folder_name',
  23. mock_xml_file)