CreatePrefab_WithSingleEntity.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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. def CreatePrefab_WithSingleEntity():
  7. from pathlib import Path
  8. from editor_python_test_tools.editor_entity_utils import EditorEntity
  9. from editor_python_test_tools.prefab_utils import Prefab
  10. import Prefab.tests.PrefabTestUtils as prefab_test_utils
  11. CAR_PREFAB_FILE_NAME = Path(__file__).stem + 'car_prefab'
  12. prefab_test_utils.open_base_tests_level()
  13. # Creates a new entity at the root level
  14. car_entity = EditorEntity.create_editor_entity()
  15. car_entity_parent = car_entity.get_parent_id()
  16. car_prefab_entities = [car_entity]
  17. # Creates a prefab from the new entity
  18. _, car_instance = Prefab.create_prefab(car_prefab_entities, CAR_PREFAB_FILE_NAME)
  19. # Test undo/redo on prefab creation
  20. prefab_test_utils.validate_undo_redo_on_prefab_creation(car_instance, car_entity_parent)
  21. if __name__ == "__main__":
  22. from editor_python_test_tools.utils import Report
  23. Report.start_test(CreatePrefab_WithSingleEntity)