TestSuite.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. """
  6. import os
  7. import shutil
  8. import zipfile
  9. import pytest
  10. from ly_test_tools.environment import file_system
  11. from ly_test_tools.o3de.editor_test import EditorTestSuite, EditorSingleTest
  12. def cleanup_test_files(workspace, test_file_names: list[str]):
  13. for test_file_name in test_file_names:
  14. file_system.delete(test_file_name, True, True)
  15. def to_meta_file(file: str):
  16. return file + ".meta"
  17. def to_material_file(file: str):
  18. return file + ".material"
  19. def original_file_set(folder: str, file: str):
  20. files = [os.path.join(folder, to_material_file(file)), os.path.join(folder, to_meta_file(to_material_file(file)))]
  21. return files
  22. def renamed_file_set(folder: str, file: str):
  23. file = file + "_renamed"
  24. files = original_file_set(folder, file)
  25. return files
  26. @pytest.mark.SUITE_periodic
  27. @pytest.mark.parametrize("launcher_platform", ['windows_editor']) # This test works on Windows editor
  28. @pytest.mark.parametrize("project", ["AutomatedTesting"]) # Use AutomatedTesting project
  29. class TestAutomation(EditorTestSuite):
  30. class Check_MetadataRename_test(EditorSingleTest):
  31. test_files: list[str] = None
  32. @classmethod
  33. def setup(self, instance, request, workspace):
  34. test_file_name = "bunny_material"
  35. original_files = original_file_set(os.path.join(os.path.dirname(os.path.realpath(__file__)), "assets"), test_file_name)
  36. renamed_files = renamed_file_set(os.path.dirname(os.path.realpath(__file__)), test_file_name)
  37. self.test_files = renamed_files
  38. cleanup_test_files(workspace, self.test_files)
  39. destination_folder = os.path.join(workspace.paths.engine_root(), "AutomatedTesting")
  40. # Move/rename both files. The point of the test is to verify references are still valid after this rename
  41. for i, val in enumerate(original_files):
  42. shutil.copyfile(val, renamed_files[i])
  43. @classmethod
  44. def teardown(self, instance, request, workspace, editor_test_results):
  45. cleanup_test_files(workspace, self.test_files)
  46. from .tests import MetadataRelocation_ReferenceValidAfterRename as test_module