scene_scripting_tests.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. import pytest, logging, os
  9. # Import fixtures
  10. from ..ap_fixtures.asset_processor_fixture import asset_processor as asset_processor
  11. from ..ap_fixtures.ap_setup_fixture import ap_setup_fixture as ap_setup_fixture
  12. # Import LyShared
  13. import ly_test_tools.o3de.pipeline_utils as utils
  14. # Use the following logging pattern to hook all test logging together:
  15. logger = logging.getLogger(__name__)
  16. @pytest.fixture
  17. def local_resources(request, workspace, ap_setup_fixture):
  18. ap_setup_fixture["tests_dir"] = os.path.dirname(os.path.realpath(__file__))
  19. @pytest.mark.usefixtures("asset_processor")
  20. @pytest.mark.usefixtures("ap_setup_fixture")
  21. @pytest.mark.usefixtures("local_resources")
  22. @pytest.mark.parametrize("project", ["AutomatedTesting"])
  23. @pytest.mark.SUITE_sandbox
  24. class TestsSceneScripting(object):
  25. @property
  26. def asset_processor_extra_params(self):
  27. return [
  28. # Disabling Atom assets disables most products, using the debugOutput flag ensures one product is output.
  29. "--debugOutput",
  30. # By default, if job priorities are equal, jobs run in an arbitrary order. This makes sure
  31. # jobs are run by sorting on the database source name, so they run in the same order each time
  32. # when this test is run.
  33. "--sortJobsByDBSourceName",
  34. # Disabling Atom products means this asset won't need a lot of source dependencies to be processed,
  35. # keeping the scope of this test down.
  36. "--regset=\"/O3DE/SceneAPI/AssetImporter/SkipAtomOutput=true\"",
  37. # The bug this regression test happened when the same builder processed FBX files with and without Python.
  38. # This flag ensures that only one builder is launched, so that situation can be replicated.
  39. "--regset=\"/Amazon/AssetProcessor/Settings/Jobs/maxJobs=1\""]
  40. def test_DefaultBuilderScript_ScriptOnlyRunsOnExpectedAsset(self, workspace, ap_setup_fixture, asset_processor):
  41. # the AutomatedTesting/Gem/PythonTests/assetpipeline/fbx_tests/assets/default_script/default_script.py script exports
  42. # an additional product asset named 'cube_icosphere.fbx.default_script' in the temp asset test folder, so if it is found
  43. # then the default scene script file was executed as expected
  44. test_assets_source_folder, _ = asset_processor.prepare_test_environment(ap_setup_fixture["tests_dir"], "default_script")
  45. script_path = os.path.join(test_assets_source_folder, "default_script.py")
  46. extra_args = self.asset_processor_extra_params
  47. extra_args.append(f"--regset=\"/O3DE/AssetProcessor/SceneBuilder/defaultScripts/default_script*={script_path}\"")
  48. result, _ = asset_processor.batch_process(extra_params=extra_args)
  49. assert result, f"AP Batch failed with {extra_args}"
  50. expected_product_list = [
  51. 'cube_icosphere.fbx.dbgsg',
  52. 'cube_icosphere.fbx.default_script'
  53. ]
  54. missing_assets, existing_assets = utils.compare_assets_with_cache(expected_product_list, asset_processor.project_test_cache_folder())
  55. assert not missing_assets, f'The following assets were expected to be in, but not found in cache: {missing_assets} + {existing_assets}'