test_manager_platforms_mac.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 ly_test_tools._internal.managers.platforms.mac
  6. """
  7. import unittest.mock as mock
  8. import os
  9. import pytest
  10. import ly_test_tools
  11. from ly_test_tools._internal.managers.platforms.mac import (
  12. _MacResourceLocator, MacWorkspaceManager,
  13. CACHE_DIR)
  14. from ly_test_tools import MAC
  15. pytestmark = pytest.mark.SUITE_smoke
  16. mock_engine_root = 'mock_engine_root'
  17. mock_dev_path = 'mock_dev_path'
  18. mock_build_directory = 'mock_build_directory'
  19. mock_project = 'mock_project'
  20. mock_tmp_path = 'mock_tmp_path'
  21. mock_output_path = 'mock_output_path'
  22. @mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_engine_root',
  23. mock.MagicMock(return_value=mock_engine_root))
  24. @mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_project_json',
  25. mock.MagicMock(return_value=mock_project))
  26. class TestMacResourceLocator(object):
  27. def test_PlatformCache_HasPath_ReturnsPath(self):
  28. mac_resource_locator = ly_test_tools._internal.managers.platforms.mac._MacResourceLocator(mock_build_directory,
  29. mock_project)
  30. expected = os.path.join(
  31. mac_resource_locator.project_cache(),
  32. CACHE_DIR)
  33. assert mac_resource_locator.platform_cache() == expected
  34. def test_ProjectLog_HasPath_ReturnsPath(self):
  35. mac_resource_locator = ly_test_tools._internal.managers.platforms.mac._MacResourceLocator(mock_build_directory,
  36. mock_project)
  37. expected = os.path.join(
  38. mac_resource_locator.project(),
  39. 'user',
  40. 'log')
  41. assert mac_resource_locator.project_log() == expected
  42. def test_ProjectScreenshots_HasPath_ReturnsPath(self):
  43. mac_resource_locator = ly_test_tools._internal.managers.platforms.mac._MacResourceLocator(mock_build_directory,
  44. mock_project)
  45. expected = os.path.join(
  46. mac_resource_locator.project(),
  47. 'user',
  48. 'ScreenShots')
  49. assert mac_resource_locator.project_screenshots() == expected
  50. def test_EditorLog_HasPath_ReturnsPath(self):
  51. mac_resource_locator = ly_test_tools._internal.managers.platforms.mac._MacResourceLocator(mock_build_directory,
  52. mock_project)
  53. expected = os.path.join(
  54. mac_resource_locator.project_log(),
  55. 'Editor.log')
  56. assert mac_resource_locator.editor_log() == expected
  57. @mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_engine_root',
  58. mock.MagicMock(return_value=mock_engine_root))
  59. @mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_project_json',
  60. mock.MagicMock(return_value=mock_project))
  61. class TestMacWorkspaceManager(object):
  62. def test_Init_SetDummyParams_ReturnsMacWorkspaceManager(self):
  63. mac_workspace_manager = MacWorkspaceManager(
  64. build_directory=mock_build_directory,
  65. project=mock_project,
  66. tmp_path=mock_tmp_path,
  67. output_path=mock_output_path)
  68. assert type(mac_workspace_manager) == MacWorkspaceManager
  69. assert mac_workspace_manager.paths.build_directory() == mock_build_directory
  70. assert mac_workspace_manager.paths._project == mock_project
  71. assert mac_workspace_manager.tmp_path == mock_tmp_path
  72. assert mac_workspace_manager.output_path == mock_output_path