fbx_tests.py 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. """
  2. All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. its licensors.
  4. For complete copyright and license terms please see the LICENSE at the root of this
  5. distribution (the "License"). All use of this software is governed by the License,
  6. or, if provided, by the license below or the license accompanying this file. Do not
  7. remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. """
  10. import binascii
  11. from dataclasses import dataclass
  12. import logging
  13. import os
  14. import pytest
  15. from typing import List
  16. # Import LyTestTools
  17. import ly_test_tools.builtin.helpers as helpers
  18. from ly_test_tools.lumberyard import asset_processor as asset_processor_utils
  19. from ly_test_tools.lumberyard.asset_processor import ASSET_PROCESSOR_PLATFORM_MAP
  20. # Import fixtures
  21. from ..ap_fixtures.asset_processor_fixture import asset_processor as asset_processor
  22. from ..ap_fixtures.ap_setup_fixture import ap_setup_fixture as ap_setup_fixture
  23. from ..ap_fixtures.ap_config_backup_fixture import ap_config_backup_fixture as ap_config_backup_fixture
  24. from ..ap_fixtures.ap_config_default_platform_fixture import ap_config_default_platform_fixture as ap_config_default_platform_fixture
  25. # Import LyShared
  26. import ly_test_tools.lumberyard.pipeline_utils as utils
  27. from automatedtesting_shared import asset_database_utils as asset_db_utils
  28. logger = logging.getLogger(__name__)
  29. # Helper: variables we will use for parameter values in the test:
  30. targetProjects = ["AutomatedTesting"]
  31. @pytest.fixture
  32. def local_resources(request, workspace, ap_setup_fixture):
  33. ap_setup_fixture["tests_dir"] = os.path.dirname(os.path.realpath(__file__))
  34. @dataclass
  35. class BlackboxAssetTest:
  36. test_name: str
  37. asset_folder: str
  38. override_asset_folder: str = ""
  39. scene_debug_file: str = ""
  40. assets: List[asset_db_utils.DBSourceAsset] = ()
  41. override_assets: List[asset_db_utils.DBSourceAsset] = ()
  42. blackbox_fbx_tests = [
  43. pytest.param(
  44. BlackboxAssetTest(
  45. test_name= "OneMeshOneMaterial_RunAP_SuccessWithMatchingProducts",
  46. asset_folder= "OneMeshOneMaterial",
  47. scene_debug_file="onemeshonematerial.dbgsg",
  48. assets = [
  49. asset_db_utils.DBSourceAsset(
  50. source_file_name = "OneMeshOneMaterial.fbx",
  51. uuid = b"8a9164adb84859be893e18aa819438e1",
  52. jobs = [
  53. asset_db_utils.DBJob(
  54. job_key= "fbx",
  55. builder_guid=b"0bbfc8c191374404bd9464c0364efbfb",
  56. status=4,
  57. error_count=0,
  58. warning_count=2,
  59. products = [
  60. asset_db_utils.DBProduct(
  61. product_name="onemeshonematerial/onemeshonematerial.cgf",
  62. sub_id=-1588558583,
  63. asset_type=b"c2869e3bdda04e018fe36770d788866b"
  64. ),
  65. asset_db_utils.DBProduct(
  66. product_name="onemeshonematerial/onemeshonematerial.dccmtl",
  67. sub_id=382053982,
  68. asset_type=b"c88469cf21e741eb96fdbf14fbb05edc"
  69. ),
  70. ],
  71. ),
  72. asset_db_utils.DBJob(
  73. job_key= "Scene compilation",
  74. builder_guid=b"bd8bf65894854fe3830e8ec3a23c35f3",
  75. status=4,
  76. error_count=0,
  77. warning_count=0,
  78. products = [
  79. asset_db_utils.DBProduct(
  80. product_name='onemeshonematerial/onemeshonematerial.dbgsg',
  81. sub_id=1918494907,
  82. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b')
  83. ]
  84. ),
  85. ]
  86. )
  87. ]
  88. ),
  89. id="32250017",
  90. marks=pytest.mark.test_case_id("C32250017"),
  91. ),
  92. pytest.param(
  93. BlackboxAssetTest(
  94. # Verifies that the soft naming convention feature with level of detail meshes works.
  95. # https://docs.aws.amazon.com/lumberyard/latest/userguide/char-fbx-importer-soft-naming.html
  96. test_name= "SoftNamingLOD_RunAP_SuccessWithMatchingProducts",
  97. asset_folder= "SoftNamingLOD",
  98. scene_debug_file="lodtest.dbgsg",
  99. assets = [
  100. asset_db_utils.DBSourceAsset(
  101. source_file_name = "lodtest.fbx",
  102. uuid = b"44c8627fe2c25aae91fe3ff9547be3b9",
  103. jobs = [
  104. asset_db_utils.DBJob(
  105. job_key= "fbx",
  106. builder_guid=b"0bbfc8c191374404bd9464c0364efbfb",
  107. status=4,
  108. error_count=0,
  109. warning_count=2,
  110. products = [
  111. asset_db_utils.DBProduct(
  112. product_name= "softnaminglod/lodtest.cgf",
  113. sub_id=1091612206,
  114. asset_type=b"c2869e3bdda04e018fe36770d788866b"
  115. ),
  116. asset_db_utils.DBProduct(
  117. product_name="softnaminglod/lodtest.dccmtl",
  118. sub_id=1960621672,
  119. asset_type=b"c88469cf21e741eb96fdbf14fbb05edc"
  120. ),
  121. asset_db_utils.DBProduct(
  122. product_name="softnaminglod/lodtest_lod1.cgf",
  123. sub_id=1091677742,
  124. asset_type=b"9aae4926cb6a4c609948a1a22f51db23"
  125. ),
  126. asset_db_utils.DBProduct(
  127. product_name="softnaminglod/lodtest_lod2.cgf",
  128. sub_id=1091743278,
  129. asset_type=b"9aae4926cb6a4c609948a1a22f51db23"
  130. ),
  131. asset_db_utils.DBProduct(
  132. product_name="softnaminglod/lodtest_lod3.cgf",
  133. sub_id=1091808814,
  134. asset_type=b"9aae4926cb6a4c609948a1a22f51db23"
  135. ),
  136. ],
  137. ),
  138. asset_db_utils.DBJob(
  139. job_key= "Scene compilation",
  140. builder_guid=b"bd8bf65894854fe3830e8ec3a23c35f3",
  141. status=4,
  142. error_count=0,
  143. warning_count=0,
  144. products = [
  145. asset_db_utils.DBProduct(
  146. product_name='softnaminglod/lodtest.dbgsg',
  147. sub_id=-632012261,
  148. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b')
  149. ]
  150. ),
  151. ]
  152. )
  153. ]
  154. ),
  155. id="33887870",
  156. marks=pytest.mark.test_case_id("33887870"),
  157. ),
  158. pytest.param(
  159. BlackboxAssetTest(
  160. # Verifies that the soft naming convention feature with physics proxies works.
  161. # https://docs.aws.amazon.com/lumberyard/latest/userguide/char-fbx-importer-soft-naming.html
  162. test_name= "SoftNamingPhysics_RunAP_SuccessWithMatchingProducts",
  163. asset_folder= "SoftNamingPhysics",
  164. scene_debug_file="physicstest.dbgsg",
  165. assets = [
  166. asset_db_utils.DBSourceAsset(
  167. source_file_name = "physicstest.fbx",
  168. uuid = b"df957b7918cf5b029806c73f630fa1c8",
  169. jobs = [
  170. asset_db_utils.DBJob(
  171. job_key= "fbx",
  172. builder_guid=b"0bbfc8c191374404bd9464c0364efbfb",
  173. status=4,
  174. error_count=0,
  175. warning_count=2,
  176. products = [
  177. asset_db_utils.DBProduct(
  178. product_name= "softnamingphysics/physicstest.cgf",
  179. sub_id=653314392,
  180. asset_type=b"c2869e3bdda04e018fe36770d788866b"
  181. ),
  182. ],
  183. ),
  184. asset_db_utils.DBJob(
  185. job_key= "Scene compilation",
  186. builder_guid=b"bd8bf65894854fe3830e8ec3a23c35f3",
  187. status=4,
  188. error_count=0,
  189. warning_count=1,
  190. products = [
  191. asset_db_utils.DBProduct(
  192. product_name='softnamingphysics/physicstest.dbgsg',
  193. sub_id=-740411732,
  194. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'
  195. ),
  196. asset_db_utils.DBProduct(
  197. product_name="softnamingphysics/physicstest.pxmesh",
  198. sub_id=640975857,
  199. asset_type=b"7a2871b95eab4de0a901b0d2c6920ddb"
  200. ),
  201. ]
  202. ),
  203. ]
  204. )
  205. ]
  206. ),
  207. ),
  208. pytest.param(
  209. BlackboxAssetTest(
  210. test_name= "MultipleMeshOneMaterial_RunAP_SuccessWithMatchingProducts",
  211. asset_folder= "TwoMeshOneMaterial",
  212. scene_debug_file="multiple_mesh_one_material.dbgsg",
  213. assets = [
  214. asset_db_utils.DBSourceAsset(
  215. source_file_name = "multiple_mesh_one_material.fbx",
  216. uuid = b"597618fd497659a1b197a015fe47aa95",
  217. jobs = [
  218. asset_db_utils.DBJob(
  219. job_key= "fbx",
  220. builder_guid=b"0bbfc8c191374404bd9464c0364efbfb",
  221. status=4,
  222. error_count=0,
  223. warning_count=2,
  224. products = [
  225. asset_db_utils.DBProduct(
  226. product_name="twomeshonematerial/multiple_mesh_one_material.dccmtl",
  227. sub_id=-1706078587,
  228. asset_type=b"c88469cf21e741eb96fdbf14fbb05edc"
  229. ),
  230. asset_db_utils.DBProduct(
  231. product_name="twomeshonematerial/test_cube.cgf",
  232. sub_id=-112145915,
  233. asset_type=b"c2869e3bdda04e018fe36770d788866b"
  234. ),
  235. asset_db_utils.DBProduct(
  236. product_name="twomeshonematerial/test_cylinder.cgf",
  237. sub_id=2087742249,
  238. asset_type=b"c2869e3bdda04e018fe36770d788866b"
  239. ),
  240. ],
  241. ),
  242. asset_db_utils.DBJob(
  243. job_key= "Scene compilation",
  244. builder_guid=b"bd8bf65894854fe3830e8ec3a23c35f3",
  245. status=4,
  246. error_count=0,
  247. warning_count=0,
  248. products = [
  249. asset_db_utils.DBProduct(
  250. product_name='twomeshonematerial/multiple_mesh_one_material.dbgsg',
  251. sub_id=2077268018,
  252. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b')
  253. ]
  254. ),
  255. ]
  256. )
  257. ]
  258. ),
  259. id="34448178",
  260. marks=pytest.mark.test_case_id("C34448178"),
  261. ),
  262. pytest.param(
  263. BlackboxAssetTest(
  264. # Verifies whether multiple meshes can share linked materials
  265. test_name= "MultipleMeshLinkedMaterials_RunAP_SuccessWithMatchingProducts",
  266. asset_folder= "TwoMeshLinkedMaterials",
  267. scene_debug_file= "multiple_mesh_linked_materials.dbgsg",
  268. assets = [
  269. asset_db_utils.DBSourceAsset(
  270. source_file_name = "multiple_mesh_linked_materials.fbx",
  271. uuid = b"25d8301c2eef5dc7bded310db8ea608d",
  272. jobs = [
  273. asset_db_utils.DBJob(
  274. job_key= "fbx",
  275. builder_guid=b"0bbfc8c191374404bd9464c0364efbfb",
  276. status=4,
  277. error_count=0,
  278. warning_count=2,
  279. products = [
  280. asset_db_utils.DBProduct(
  281. product_name='twomeshlinkedmaterials/multiple_mesh_linked_materials.cgf',
  282. sub_id=1259347154,
  283. asset_type=b'c2869e3bdda04e018fe36770d788866b'
  284. ),
  285. asset_db_utils.DBProduct(
  286. product_name='twomeshlinkedmaterials/multiple_mesh_linked_materials.dccmtl',
  287. sub_id=1829742731,
  288. asset_type=b'c88469cf21e741eb96fdbf14fbb05edc'
  289. ),
  290. ],
  291. ),
  292. asset_db_utils.DBJob(
  293. job_key= "Scene compilation",
  294. platform= "pc",
  295. builder_guid=b"bd8bf65894854fe3830e8ec3a23c35f3",
  296. status=4,
  297. error_count=0,
  298. warning_count=0,
  299. products= [
  300. asset_db_utils.DBProduct(
  301. product_name='twomeshlinkedmaterials/multiple_mesh_linked_materials.dbgsg',
  302. sub_id=-1898461950,
  303. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'
  304. )
  305. ]
  306. ),
  307. ]
  308. )
  309. ]
  310. ),
  311. id="32250018",
  312. marks=pytest.mark.test_case_id("C32250018"),
  313. ),
  314. pytest.param(
  315. BlackboxAssetTest(
  316. # Verifies a mesh with multiple materials
  317. test_name= "SingleMeshMultipleMaterials_RunAP_SuccessWithMatchingProducts",
  318. asset_folder= "OneMeshMultipleMaterials",
  319. scene_debug_file="single_mesh_multiple_materials.dbgsg",
  320. assets = [
  321. asset_db_utils.DBSourceAsset(
  322. source_file_name = "single_mesh_multiple_materials.fbx",
  323. uuid = b"f08fd585dfa35881b4bf86637da5e858",
  324. jobs = [
  325. asset_db_utils.DBJob(
  326. job_key= "fbx",
  327. builder_guid=b"0bbfc8c191374404bd9464c0364efbfb",
  328. status=4,
  329. error_count=0,
  330. warning_count=2,
  331. products = [
  332. asset_db_utils.DBProduct(
  333. product_name='onemeshmultiplematerials/single_mesh_multiple_materials.cgf',
  334. sub_id=1296081148,
  335. asset_type=b'c2869e3bdda04e018fe36770d788866b'
  336. ),
  337. asset_db_utils.DBProduct(
  338. product_name='onemeshmultiplematerials/single_mesh_multiple_materials.dccmtl',
  339. sub_id=-229825489,
  340. asset_type=b'c88469cf21e741eb96fdbf14fbb05edc'
  341. ),
  342. ],
  343. ),
  344. asset_db_utils.DBJob(
  345. job_key= "Scene compilation",
  346. platform= "pc",
  347. builder_guid=b"bd8bf65894854fe3830e8ec3a23c35f3",
  348. status=4,
  349. error_count=0,
  350. warning_count=0,
  351. products = [
  352. asset_db_utils.DBProduct(
  353. product_name='onemeshmultiplematerials/single_mesh_multiple_materials.dbgsg',
  354. sub_id=-262822238,
  355. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b')
  356. ]
  357. ),
  358. ]
  359. )
  360. ]
  361. ),
  362. id="32250020",
  363. marks=pytest.mark.test_case_id("C32250020"),
  364. ),
  365. pytest.param(
  366. BlackboxAssetTest(
  367. test_name="MeshWithVertexColors_RunAP_SuccessWithMatchingProducts",
  368. asset_folder="VertexColor",
  369. scene_debug_file="vertexcolor.dbgsg",
  370. assets=[
  371. asset_db_utils.DBSourceAsset(
  372. source_file_name="VertexColor.fbx",
  373. uuid=b"207e7e1540785a26b064e9be67361cdf",
  374. jobs=[
  375. asset_db_utils.DBJob(
  376. job_key="fbx",
  377. builder_guid=b"0bbfc8c191374404bd9464c0364efbfb",
  378. status=4,
  379. error_count=0,
  380. warning_count=2,
  381. products=[
  382. asset_db_utils.DBProduct(
  383. product_name="vertexcolor/vertexcolor.cgf",
  384. sub_id=-427774918,
  385. asset_type=b"c2869e3bdda04e018fe36770d788866b"
  386. ),
  387. ],
  388. ),
  389. asset_db_utils.DBJob(
  390. job_key="Scene compilation",
  391. builder_guid=b"bd8bf65894854fe3830e8ec3a23c35f3",
  392. status=4,
  393. error_count=0,
  394. warning_count=0,
  395. products=[
  396. asset_db_utils.DBProduct(
  397. product_name='vertexcolor/vertexcolor.dbgsg',
  398. sub_id=-1543877170,
  399. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b')
  400. ]
  401. ),
  402. ]
  403. )
  404. ]
  405. ),
  406. id="35796285",
  407. marks=pytest.mark.test_case_id("C35796285"),
  408. ),
  409. ]
  410. blackbox_fbx_special_tests = [
  411. pytest.param(
  412. BlackboxAssetTest(
  413. test_name= "MultipleMeshMultipleMaterial_MultipleAssetInfo_RunAP_SuccessWithMatchingProducts",
  414. asset_folder= "TwoMeshTwoMaterial",
  415. override_asset_folder = "OverrideAssetInfoForTwoMeshTwoMaterial",
  416. scene_debug_file="multiple_mesh_multiple_material.dbgsg",
  417. assets = [
  418. asset_db_utils.DBSourceAsset(
  419. source_file_name = "multiple_mesh_multiple_material.fbx",
  420. uuid = b"b5915fb874af5c8a866ccabbddb57595",
  421. jobs = [
  422. asset_db_utils.DBJob(
  423. job_key= "fbx",
  424. builder_guid=b"0bbfc8c191374404bd9464c0364efbfb",
  425. status=4,
  426. error_count=0,
  427. warning_count=2,
  428. products = [
  429. asset_db_utils.DBProduct(
  430. product_name="twomeshtwomaterial/multiple_mesh_multiple_material.dccmtl",
  431. sub_id=-1035023097,
  432. asset_type=b"c88469cf21e741eb96fdbf14fbb05edc"
  433. ),
  434. asset_db_utils.DBProduct(
  435. product_name="twomeshtwomaterial/test_cube_mesh.cgf",
  436. sub_id=-1822360172,
  437. asset_type=b"c2869e3bdda04e018fe36770d788866b"
  438. ),
  439. asset_db_utils.DBProduct(
  440. product_name="twomeshtwomaterial/test_cylinder_mesh.cgf",
  441. sub_id=-1885293549,
  442. asset_type=b"c2869e3bdda04e018fe36770d788866b"
  443. ),
  444. ],
  445. ),
  446. asset_db_utils.DBJob(
  447. job_key="Scene compilation",
  448. builder_guid=b"bd8bf65894854fe3830e8ec3a23c35f3",
  449. status=4,
  450. error_count=0,
  451. warning_count=0,
  452. products = [
  453. asset_db_utils.DBProduct(
  454. product_name='twomeshtwomaterial/multiple_mesh_multiple_material.dbgsg',
  455. sub_id=896980093,
  456. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b')
  457. ]
  458. ),
  459. ]
  460. )
  461. ],
  462. override_assets=[
  463. asset_db_utils.DBSourceAsset(
  464. source_file_name = "multiple_mesh_multiple_material.fbx",
  465. uuid = b"b5915fb874af5c8a866ccabbddb57595",
  466. jobs = [
  467. asset_db_utils.DBJob(
  468. job_key= "fbx",
  469. builder_guid=b"0bbfc8c191374404bd9464c0364efbfb",
  470. status=4,
  471. error_count=0,
  472. warning_count=2,
  473. products = [
  474. asset_db_utils.DBProduct(
  475. product_name="twomeshtwomaterial/multiple_mesh_multiple_material.dccmtl",
  476. sub_id=-1035023097,
  477. asset_type=b"c88469cf21e741eb96fdbf14fbb05edc"
  478. ),
  479. asset_db_utils.DBProduct(
  480. product_name="twomeshtwomaterial/test_cube_mesh.cgf",
  481. sub_id=-1822360172,
  482. asset_type=b"c2869e3bdda04e018fe36770d788866b"
  483. ),
  484. ],
  485. ),
  486. asset_db_utils.DBJob(
  487. job_key= "Scene compilation",
  488. builder_guid=b"bd8bf65894854fe3830e8ec3a23c35f3",
  489. status=4,
  490. error_count=0,
  491. warning_count=0,
  492. products = [
  493. asset_db_utils.DBProduct(
  494. product_name='twomeshtwomaterial/multiple_mesh_multiple_material.dbgsg',
  495. sub_id=896980093,
  496. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b')
  497. ]
  498. ),
  499. ]
  500. )
  501. ]
  502. ),
  503. id="34389075",
  504. marks=pytest.mark.test_case_id("C34389075"),
  505. ),
  506. ]
  507. @pytest.mark.usefixtures("asset_processor")
  508. @pytest.mark.usefixtures("ap_setup_fixture")
  509. @pytest.mark.usefixtures("local_resources")
  510. @pytest.mark.parametrize("project", targetProjects)
  511. @pytest.mark.assetpipeline
  512. class TestsFBX_AllPlatforms(object):
  513. @pytest.mark.BAT
  514. @pytest.mark.parametrize("blackbox_param", blackbox_fbx_tests)
  515. def test_FBXBlackboxTest_SourceFiles_Processed_ResultInExpectedProducts(self, workspace,
  516. ap_setup_fixture, asset_processor, project,
  517. blackbox_param):
  518. if blackbox_param == None:
  519. return
  520. self.run_fbx_test(workspace, ap_setup_fixture,
  521. asset_processor, project, blackbox_param)
  522. @pytest.mark.BAT
  523. @pytest.mark.parametrize("blackbox_param", blackbox_fbx_special_tests)
  524. def test_FBXBlackboxTest_AssetInfoModified_AssetReprocessed_ResultInExpectedProducts(self,
  525. workspace, ap_setup_fixture,
  526. asset_processor, project,
  527. blackbox_param):
  528. if blackbox_param == None:
  529. return
  530. self.run_fbx_test(workspace, ap_setup_fixture,
  531. asset_processor, project, blackbox_param)
  532. # Run the test again and validate the information in the override assets
  533. self.run_fbx_test(workspace, ap_setup_fixture,
  534. asset_processor, project, blackbox_param, True)
  535. def populateAssetInfo(self, workspace, project, assets):
  536. # Check that each given source asset resulted in the expected jobs and products.
  537. for expected_source in assets:
  538. for job in expected_source.jobs:
  539. job.platform = ASSET_PROCESSOR_PLATFORM_MAP[workspace.asset_processor_platform]
  540. for product in job.products:
  541. product.product_name = job.platform + "/" + project.lower() + "/" \
  542. + product.product_name
  543. def run_fbx_test(self, workspace, ap_setup_fixture, asset_processor,
  544. project, blackbox_params: BlackboxAssetTest, overrideAsset = False):
  545. test_assets_folder = blackbox_params.override_asset_folder if overrideAsset else blackbox_params.asset_folder
  546. logger.info(f"{blackbox_params.test_name}: Processing assets in folder '"
  547. f"{test_assets_folder}' and verifying they match expected output.")
  548. # Prepare test environment and process assets
  549. if not overrideAsset:
  550. asset_processor.prepare_test_environment(ap_setup_fixture['tests_dir'], test_assets_folder)
  551. else:
  552. asset_processor.prepare_test_environment(ap_setup_fixture['tests_dir'], test_assets_folder,
  553. use_current_root=True, add_scan_folder=False,
  554. existing_function_name=blackbox_params.asset_folder)
  555. asset_processor.batch_process(extra_params="--debugOutput")
  556. logger.info(f"Validating assets.")
  557. assetsToValidate = blackbox_params.override_assets if overrideAsset else blackbox_params.assets
  558. expected_product_list = []
  559. for expected_source in assetsToValidate:
  560. for expected_job in expected_source.jobs:
  561. for expected_product in expected_job.products:
  562. expected_product_list.append(expected_product.product_name)
  563. missing_assets, _ = utils.compare_assets_with_cache(expected_product_list,
  564. asset_processor.project_test_cache_folder())
  565. assert not missing_assets, f'The following assets were expected to be in, but not found in cache: {str(missing_assets)}'
  566. # Load the asset database.
  567. db_path = os.path.join(asset_processor.temp_asset_root(), "Cache",
  568. "assetdb.sqlite")
  569. cache_root = os.path.dirname(os.path.join(asset_processor.temp_asset_root(), "Cache",
  570. ASSET_PROCESSOR_PLATFORM_MAP[workspace.asset_processor_platform]))
  571. if blackbox_params.scene_debug_file:
  572. debug_graph_path = os.path.join(asset_processor.project_test_cache_folder(), blackbox_params.scene_debug_file)
  573. expected_debug_graph_path = os.path.join(asset_processor.project_test_source_folder(), blackbox_params.scene_debug_file)
  574. logger.info(f"Parsing scene graph: {debug_graph_path}")
  575. with open(debug_graph_path, "r") as scene_file:
  576. actual_lines = scene_file.readlines()
  577. logger.info(f"Parsing scene graph: {expected_debug_graph_path}")
  578. with open(expected_debug_graph_path, "r") as scene_file:
  579. expected_lines = scene_file.readlines()
  580. assert utils.compare_lists(actual_lines, expected_lines), "Scene mismatch"
  581. # Check that each given source asset resulted in the expected jobs and products.
  582. self.populateAssetInfo(workspace, project, assetsToValidate)
  583. for expected_source in assetsToValidate:
  584. for job in expected_source.jobs:
  585. for product in job.products:
  586. asset_db_utils.compare_expected_asset_to_actual_asset(db_path,
  587. expected_source,
  588. f"{blackbox_params.asset_folder}/"
  589. f"{expected_source.source_file_name}",
  590. cache_root)