import pytest import constants LAMBDA_NAME = constants.LAMBDA_VECTOR_FIND_ASSETS_TO_DOWNLOAD STEP_FUNCTION_NAME = constants.WORKFLOW_TRANSFER_ASSETS UPC = 44003199682 PRODUCT_ID = 3840746 @pytest.mark.parametrize('alchemy_db', ['dd'], indirect=True) @pytest.mark.parametrize('step_function_handler', [STEP_FUNCTION_NAME], indirect=True) def test_vector_find_assets_to_download(lambda_client, cloudwatch_log_handler, alchemy_db, step_function_handler): """Test lambda-vector-find-assets-to-download lambda starts state machine \n https://www.notion.so/VECTOR-fe346add2b484d6fa9da91969dee0bde""" alchemy_db.assets.remove_assets_if_exists(UPC) step_function_handler.set_last_execution() lambda_event = { "Records": [ { "body": { "product_id": PRODUCT_ID, "upc": UPC, "physical_location_id": 9, "overwrite": "true", "v1_bypass": "true" } } ] } lambda_client.invoke(LAMBDA_NAME, lambda_event) cloudwatch_log_handler.assert_lambda_logs_message( LAMBDA_NAME, "Start state machine") assert step_function_handler.assert_machine_ran() def test_vector_did_not_find_assets(lambda_client, cloudwatch_log_handler): """Test lambda-vector-find-assets-to-download lambda did not find assets \n https://www.notion.so/VECTOR-fe346add2b484d6fa9da91969dee0bde""" lambda_event = { "Records": [ { "body": { "product_id": 1010101010, # incorrect id "upc": UPC, "physical_location_id": 7, "overwrite": "true", "v1_bypass": "true" } } ] } lambda_client.invoke(LAMBDA_NAME, lambda_event) cloudwatch_log_handler.assert_lambda_logs_message( LAMBDA_NAME, f'Did not find assets for {UPC} to download.')