🎥 Make videos programmatically with React
add more tests
alex fernandez97d94ed7ecc1
diff --git a/packages/lambda-python/remotion_lambda/remotionclient.py b/packages/lambda-python/remotion_lambda/remotionclient.pyindex c4afe5f316..c2ed2bd57f 100644--- a/packages/lambda-python/remotion_lambda/remotionclient.py+++ b/packages/lambda-python/remotion_lambda/remotionclient.py@@ -8,8 +8,7 @@ from math import ceilfrom typing import Optional, Union, List, Dict, Anyfrom enum import Enumimport warnings-import boto3-from boto3.session import Session as Boto3Session # Explicitly import Session+from boto3.session import Session # Explicitly import Sessionfrom botocore.config import Configfrom botocore.exceptions import ClientError, ParamValidationErrorfrom botocore.response import StreamingBody # For Lambda payload@@ -50,8 +49,8 @@ class RemotionClient:access_key: Optional[str] = None,secret_key: Optional[str] = None,force_path_style: bool = False,- botocore_config: Optional[Config] = None,- boto_session: Optional[Boto3Session] = None,+ session: Optional[Session] = None,+ config: Optional[Config] = None,):"""Initialize the RemotionClient.@@ -65,16 +64,16 @@ class RemotionClient:function_name : strName of the AWS Lambda function to invokeaccess_key : Optional[str], deprecated- **DEPRECATED** - AWS access key ID. Use `boto_session` instead.+ **DEPRECATED** - AWS access key ID. Use `session` instead.Will be removed in version 5.0.0.secret_key : Optional[str], deprecated- **DEPRECATED** - AWS secret access key. Use `boto_session` instead.+ **DEPRECATED** - AWS secret access key. Use `session` instead.Will be removed in version 5.0.0.force_path_style : bool, default=FalseForce path-style S3 URLs instead of virtual-hosted-style- botocore_config : Optional[Config]+ config : Optional[Config]Custom botocore configuration object- boto_session : Optional[Boto3Session]+ session : Optional[Session]Pre-configured boto3 Session object (recommended for authentication)Raises@@ -86,11 +85,11 @@ class RemotionClient:--------.. deprecated:: 4.0.377Parameters `access_key` and `secret_key` are deprecated.- Use `boto_session` instead for improved security and flexibility.+ Use `session` instead for improved security and flexibility.Examples--------- Recommended usage with boto_session:+ Recommended usage with session:>>> import boto3>>> session = boto3.Session(profile_name='production')@@ -98,7 +97,59 @@ class RemotionClient:... region='us-east-1',... serve_url='https://api.example.com',... function_name='my-function',- ... boto_session=session+ ... session=session+ ... )++ Using STS AssumeRole for cross-account or temporary credentials:++ >>> import boto3+ >>>+ >>> # Create STS client using your base credentials+ >>> sts_client = boto3.client('sts')+ >>>+ >>> # Assume a role (cross-account or for temporary elevated permissions)+ >>> assumed_role = sts_client.assume_role(+ ... RoleArn='arn:aws:iam::123456789012:role/RemotionRenderRole',+ ... RoleSessionName='remotion-render-session',+ ... DurationSeconds=3600 # Optional: 1 hour (default is 1 hour, max depends on role)+ ... )+ >>>+ >>> # Extract temporary credentials from the response+ >>> credentials = assumed_role['Credentials']+ >>>+ >>> # Create a session with the temporary credentials+ >>> session = boto3.Session(+ ... aws_access_key_id=credentials['AccessKeyId'],+ ... aws_secret_access_key=credentials['SecretAccessKey'],+ ... aws_session_token=credentials['SessionToken'],+ ... region_name='us-east-1'+ ... )+ >>>+ >>> # Use the session with RemotionClient+ >>> client = RemotionClient(+ ... region='us-east-1',+ ... serve_url='https://api.example.com',+ ... function_name='my-function',+ ... session=session+ ... )++ Using custom config with timeouts and retries:++ >>> from botocore.config import Config+ >>> import boto3+ >>>+ >>> config = Config(+ ... connect_timeout=5,+ ... read_timeout=30,+ ... retries={'max_attempts': 3, 'mode': 'adaptive'}+ ... )+ >>> session = boto3.Session(profile_name='production')+ >>> client = RemotionClient(+ ... region='us-east-1',+ ... serve_url='https://api.example.com',+ ... function_name='my-function',+ ... session=session,+ ... config=config... )Legacy usage (deprecated):@@ -111,7 +162,7 @@ class RemotionClient:... secret_key='secret...'... )"""- # Validate required parameters+ # Validate required parameters at construction timeif not region or not region.strip():raise RemotionInvalidArgumentException("'region' parameter is required and cannot be empty or whitespace")if not serve_url or not serve_url.strip():@@ -121,10 +172,10 @@ class RemotionClient:# Check for conflicting authentication methods- if boto_session and (access_key or secret_key):+ if session and (access_key or secret_key):raise ValueError(- "Cannot specify both 'boto_session' and explicit credentials "- "('access_key'/'secret_key'). Please use only 'boto_session'."+ "Cannot specify both 'session' and explicit credentials "+ "('access_key'/'secret_key'). Please use only 'session'.")# Handle deprecated credential parameters@@ -132,7 +183,7 @@ class RemotionClient:warnings.warn("Parameters 'access_key' and 'secret_key' are deprecated ""as of version 4.0.376 and will be removed in version 5.0.0. "- "Please migrate to using 'boto_session' for improved security. "+ "Please migrate to using 'session' for improved security. ""See: https://docs.remotion.dev/migration-guide",DeprecationWarning,stacklevel=2,@@ -144,24 +195,24 @@ class RemotionClient:raise RemotionInvalidArgumentException("'access_key' must be provided when 'secret_key' is specified")# Create session from deprecated credentials- self.boto_session = Boto3Session(+ self.session = Session(aws_access_key_id=access_key,aws_secret_access_key=secret_key,region_name=region,)- elif boto_session:+ elif session:# Use provided session- self.boto_session = boto_session+ self.session = sessionelse:# Create default session (uses credential chain)- self.boto_session = Boto3Session(region_name=region)+ self.session = Session(region_name=region)# Store configurationself.region = region.strip()self.serve_url = serve_url.strip().rstrip('/')self.function_name = function_name.strip()self.force_path_style = force_path_style- self.botocore_config = botocore_config or Config() # Provide default empty config+ self.config = config or Config() # Provide default empty configdef _generate_hash(self, payload: str) -> str: # Added type hints"""Generate a hash for the payload."""@@ -192,22 +243,21 @@ class RemotionClient:client_kwargs: Dict[str, Any] = {'region_name': self.region}# Handle config- current_config = self.botocore_config+ current_config = self.config+if service_name == 's3' and self.force_path_style:s3_config = Config(s3={'addressing_style': 'path'})if current_config:current_config = current_config.merge(s3_config)else:current_config = s3_config++# Add config only if it's not Noneif current_config:client_kwargs['config'] = current_config- if self.boto_session:- # Pass the prepared kwargs to the session's client method- return self.boto_session.client(service_name, **client_kwargs) # type: ignore[call-overload]- # Use default boto3 client- return boto3.client(service_name, **client_kwargs) # type: ignore[call-overload]+ return self.session.client(service_name, **client_kwargs) # type: ignore[call-overload]def _create_s3_client(self) -> Any: # Returns an S3 client type"""Creates and returns a boto3 S3 client."""@@ -344,7 +394,7 @@ class RemotionClient:return Truereturn False- def _serialize_input_props(self, input_props: Dict[str, Any] | None, render_type: RenderType) -> Dict[str, Any] : # Added type hints+ def _serialize_input_props(self, input_props: Optional[Dict[str, Any]], render_type: RenderType) -> Dict[str, Any] : # Added type hints"""Serialize inputProps to a format compatible with Lambda.diff --git a/packages/lambda-python/testclient_render_media.py b/packages/lambda-python/testclient_render_media.pyindex 6643a8234b..91c933dd33 100644--- a/packages/lambda-python/testclient_render_media.py+++ b/packages/lambda-python/testclient_render_media.py@@ -1,9 +1,10 @@-from remotion_lambda import RenderMediaParams, Privacy, ValidStillImageFormats+from remotion_lambda import RenderMediaParams, Privacy, ValidStillImageFormats, Webhookfrom remotion_lambda import RemotionClientimport osfrom dotenv import load_dotenv-+import boto3+from botocore.config import Configload_dotenv()@@ -20,14 +21,56 @@ REMOTION_APP_SERVE_URL = os.getenv('REMOTION_APP_SERVE_URL')if not REMOTION_APP_SERVE_URL:raise Exception("REMOTION_APP_SERVE_URL is not set")-# Construct client++# --- NEW: Create a custom botocore Config for timeouts ---+# This configuration will apply to both S3 and Lambda clients created by RemotionClient+# if passed via the botocore_config parameter.+custom_botocore_config = Config(+ connect_timeout=30, # Max 30 seconds to establish a connection+ read_timeout=60, # Max 60 seconds to receive data after connection+ retries={'max_attempts': 3, 'mode': 'adaptive'}, # Retry up to 3 times on certain errors+ # You can add more settings here, e.g., proxies+ # proxies={+ # 'http': 'http://proxy.example.com:8080',+ # 'https': 'https://proxy.example.com:8080'+# }+)+print(f"Created custom botocore config: {custom_botocore_config.retries}")+++# --- NEW: Create a custom boto3 session ---+# This session can be configured independently, for example,+# if you need to specify a different profile or assumed role.+# If you don't need a custom session, you can omit this and+# RemotionClient will use boto3's default session.+custom_boto_session = boto3.Session(+ #region_name=REMOTION_APP_REGION,+ # profile_name='your_aws_profile', # Uncomment if you use AWS profiles+ # If you provide aws_access_key_id, aws_secret_access_key here,+ # it will override the ones passed to RemotionClient directly.+ # aws_access_key_id='YOUR_ACCESS_KEY',+ # aws_secret_access_key='YOUR_SECRET_KEY',+)+print(f"Created custom boto3 session with region: {custom_boto_session.region_name}")+++# Construct client using custom sessionclient = RemotionClient(region=REMOTION_APP_REGION,serve_url=REMOTION_APP_SERVE_URL,- function_name=REMOTION_APP_FUNCTION_NAME)+ function_name=REMOTION_APP_FUNCTION_NAME,+ config=custom_botocore_config,+ session=custom_boto_session # if you omit this existing functionality will still work+ )++# You can still use the previous approach+# client = RemotionClient(region=REMOTION_APP_REGION,+# serve_url=REMOTION_APP_SERVE_URL,+# function_name=REMOTION_APP_FUNCTION_NAME)+## Set render requestrender_params = RenderMediaParams(- composition="print-props",+ composition="spring-with-duration",privacy=Privacy.PUBLIC,image_format=ValidStillImageFormats.JPEG,input_props={@@ -35,20 +78,6 @@ render_params = RenderMediaParams(},)-# Test with large payload to verify S3 compression works-# Create large input props that exceed the 200KB limit for video-or-audio renders-large_data = {- 'largeArray': ['x' * 1000] * 250, # This creates ~250KB of data- 'description': 'This is a test with large input props to verify S3 compression functionality'-}--large_render_params = RenderMediaParams(- composition="print-props",- privacy=Privacy.PUBLIC,- image_format=ValidStillImageFormats.JPEG,- input_props=large_data,-)-print("Testing normal payload size...")render_response = client.render_media_on_lambda(render_params)@@ -68,12 +97,27 @@ if render_response:print("Render done!", progress_response.outputFile)print("Testing large payload compression...")+# Test with large payload to verify S3 compression works+# Create large input props that exceed the 200KB limit for video-or-audio renders+large_data = {+ 'largeArray': ['x' * 1000] * 250, # This creates ~250KB of data+ 'description': 'This is a test with large input props to verify S3 compression functionality'+}++large_render_params = RenderMediaParams(+ composition="print-props",+ privacy=Privacy.PUBLIC,+ image_format=ValidStillImageFormats.JPEG,+ input_props=large_data,+)++# For testing large payloads, we would need valid AWS credentials# This will demonstrate the compression logictry:large_render_response = client.render_media_on_lambda(large_render_params)print("Large payload render succeeded!")-+if large_render_response:print("Large Render ID:", large_render_response.render_id)print("Large Bucket name:", large_render_response.bucket_name)diff --git a/packages/lambda-python/testclient_render_media_session.py b/packages/lambda-python/testclient_render_media_session.pydeleted file mode 100644index 990710b27d..0000000000--- a/packages/lambda-python/testclient_render_media_session.py+++ /dev/null@@ -1,90 +0,0 @@--from remotion_lambda import RenderMediaParams, Privacy, ValidStillImageFormats, Webhook-from remotion_lambda import RemotionClient-import os-from dotenv import load_dotenv-import boto3-from botocore.config import Config--load_dotenv()--# Load env variables-REMOTION_APP_REGION = os.getenv('REMOTION_APP_REGION')-if not REMOTION_APP_REGION:- raise Exception("REMOTION_APP_REGION is not set")--REMOTION_APP_FUNCTION_NAME = os.getenv('REMOTION_APP_FUNCTION_NAME')-if not REMOTION_APP_FUNCTION_NAME:- raise Exception("REMOTION_APP_FUNCTION_NAME is not set")--REMOTION_APP_SERVE_URL = os.getenv('REMOTION_APP_SERVE_URL')-if not REMOTION_APP_SERVE_URL:- raise Exception("REMOTION_APP_SERVE_URL is not set")--- # --- NEW: Create a custom botocore Config for timeouts ----# This configuration will apply to both S3 and Lambda clients created by RemotionClient-# if passed via the botocore_config parameter.-custom_botocore_config = Config(- connect_timeout=10, # Max 10 seconds to establish a connection- read_timeout=60, # Max 60 seconds to receive data after connection- retries={'max_attempts': 3, 'mode': 'adaptive'}, # Retry up to 3 times on certain errors- # You can add more settings here, e.g., proxies- # proxies={- # 'http': 'http://proxy.example.com:8080',- # 'https': 'https://proxy.example.com:8080'-# }-)-print(f"Created custom botocore config: {custom_botocore_config.retries}")---# --- NEW: Create a custom boto3 session ----# This session can be configured independently, for example,-# if you need to specify a different profile or assumed role.-# If you don't need a custom session, you can omit this and-# RemotionClient will use boto3's default session.-custom_boto_session = boto3.Session(- region_name=REMOTION_APP_REGION,- # profile_name='your_aws_profile', # Uncomment if you use AWS profiles- # If you provide aws_access_key_id, aws_secret_access_key here,- # it will override the ones passed to RemotionClient directly.- # aws_access_key_id='YOUR_ACCESS_KEY',- # aws_secret_access_key='YOUR_SECRET_KEY',-)-print(f"Created custom boto3 session with region: {custom_boto_session.region_name}")---# Construct client-client = RemotionClient(region=REMOTION_APP_REGION,- serve_url=REMOTION_APP_SERVE_URL,- function_name=REMOTION_APP_FUNCTION_NAME,- botocore_config=custom_botocore_config,- boto_session=custom_boto_session)--# Set render request-render_params = RenderMediaParams(- composition="spring-with-duration",- privacy=Privacy.PUBLIC,- image_format=ValidStillImageFormats.JPEG,- input_props={- 'hi': 'there'- },-)--print("Testing normal payload size...")-render_response = client.render_media_on_lambda(render_params)--if render_response:- print("Render ID:", render_response.render_id)- print("Bucket name:", render_response.bucket_name)-- # Execute progress request- progress_response = client.get_render_progress(- render_id=render_response.render_id, bucket_name=render_response.bucket_name)-- while progress_response and not progress_response.done:- print("Overall progress")- print(str(progress_response.overallProgress * 100) + "%")- progress_response = client.get_render_progress(- render_id=render_response.render_id, bucket_name=render_response.bucket_name)- print("Render done!", progress_response.outputFile)diff --git a/packages/lambda-python/tests/conftest.py b/packages/lambda-python/tests/conftest.pyindex 408330f00a..faab37e695 100644--- a/packages/lambda-python/tests/conftest.py+++ b/packages/lambda-python/tests/conftest.py@@ -36,4 +36,10 @@ def mock_s3_client():@pytest.fixturedef mock_lambda_client():"""Fixture for a mocked boto3 Lambda client."""- return Mock()\ No newline at end of file+ return Mock()+++def mock_boto_client():+ """Fixture for a mocked boto3 Lambda client."""+ return Mock()diff --git a/packages/lambda-python/tests/test_large_payload_compression.py b/packages/lambda-python/tests/test_large_payload_compression.pyindex 8707f3c384..6ef6b1d92c 100644--- a/packages/lambda-python/tests/test_large_payload_compression.py+++ b/packages/lambda-python/tests/test_large_payload_compression.py@@ -1,6 +1,5 @@import unittest-from unittest.mock import patch, MagicMock-from remotion_lambda.models import RenderMediaParams+from unittest.mock import patchfrom remotion_lambda.remotionclient import RemotionClient, RemotionExceptiondiff --git a/packages/lambda-python/tests/test_remotion_client.py b/packages/lambda-python/tests/test_remotion_client.pyindex 914561c0bc..e898340707 100644--- a/packages/lambda-python/tests/test_remotion_client.py+++ b/packages/lambda-python/tests/test_remotion_client.py@@ -17,7 +17,7 @@ from tests.constants import (TEST_AWS_SECRET_KEY,TEST_AWS_ACCESS_KEY,)-from unittest.mock import MagicMock, patch, Mock+from unittest.mock import patch, Mockfrom botocore.config import Config@@ -30,8 +30,7 @@ def test_client_config(remotion_client: RemotionClient):assert remotion_client.function_name == TEST_FUNCTION_NAMEassert remotion_client.region == TEST_REGIONassert remotion_client.serve_url == TEST_SERVE_URL- assert not remotion_client.access_key- assert not remotion_client.secret_key+ assert remotion_client.sessionassert not remotion_client.force_path_style@@ -40,8 +39,10 @@ def test_client_config_with_creds(remotion_client_with_creds: RemotionClient):assert remotion_client.function_name == TEST_FUNCTION_NAMEassert remotion_client.region == TEST_REGIONassert remotion_client.serve_url == TEST_SERVE_URL- assert remotion_client.access_key == TEST_AWS_ACCESS_KEY- assert remotion_client.secret_key == TEST_AWS_SECRET_KEY++ credentials = remotion_client.session.get_credentials()+ assert credentials.access_key == TEST_AWS_ACCESS_KEY+ assert credentials.secret_key == TEST_AWS_SECRET_KEYassert not remotion_client.force_path_style@@ -68,63 +69,58 @@ def test_generate_hash_basic_string(remotion_client: RemotionClient):assert all(c in '0123456789abcdef' for c in result)-@patch('boto3.client')-def test_create_s3_client_default(- mock_boto_client, mock_s3_client, remotion_client: RemotionClient-):- mock_boto_client.return_value = mock_s3_client- result = remotion_client._create_s3_client()- mock_boto_client.assert_called_once_with('s3', region_name=TEST_REGION)- assert result == mock_s3_client+@patch('remotion_lambda.remotionclient.Session')+def test_create_s3_client_partial_creds(mock_session_class):+ with pytest.raises(RemotionInvalidArgumentException):+ RemotionClient(+ region=TEST_REGION,+ serve_url=TEST_SERVE_URL,+ function_name=TEST_FUNCTION_NAME,+ secret_key=TEST_AWS_SECRET_KEY,+ )-@patch('boto3.client')-def test_create_s3_client_partial_creds(mock_boto_client, mock_s3_client):- remotion_client = RemotionClient(+@patch('remotion_lambda.remotionclient.Session')+def test_session_created_with_creds(mock_session_class):+ RemotionClient(region=TEST_REGION,- serve_url=TEST_SERVE_URL,- function_name=TEST_FUNCTION_NAME,+ serve_url="https://test.com",+ function_name="test-func",+ access_key=TEST_AWS_ACCESS_KEY,secret_key=TEST_AWS_SECRET_KEY,)- mock_boto_client.return_value = mock_s3_client- result = remotion_client._create_s3_client()-- mock_boto_client.assert_called_once_with('s3', region_name=TEST_REGION)- assert result == mock_s3_client---@patch('boto3.client')-def test_create_s3_client_creds(- mock_boto_client, mock_s3_client, remotion_client_with_creds-):- mock_boto_client.return_value = mock_s3_client- result = remotion_client_with_creds._create_s3_client()-- mock_boto_client.assert_called_once_with(- 's3',- region_name=TEST_REGION,+ mock_session_class.assert_called_once_with(aws_access_key_id=TEST_AWS_ACCESS_KEY,aws_secret_access_key=TEST_AWS_SECRET_KEY,+ region_name=TEST_REGION,)- assert result == mock_s3_client--@patch('boto3.client')-def test_create_s3_client_with_path_style(mock_boto_client, mock_s3_client):+@patch('remotion_lambda.remotionclient.Session')+def test_create_s3_client_with_path_style(mock_session_class, mock_s3_client, ):+ # Create the client (this creates a mock session instance)remotion_client = RemotionClient(region=TEST_REGION,serve_url=TEST_SERVE_URL,function_name=TEST_FUNCTION_NAME,force_path_style=True,)- mock_boto_client.return_value = mock_s3_client++ # Get the mock session instance that was created+ mock_session_instance = mock_session_class.return_value+ mock_session_instance.client.return_value = mock_s3_client++ # Call the methodresult = remotion_client._create_s3_client()- mock_boto_client.assert_called_once()+ # Check the .client() call on the session instance+ mock_session_instance.client.assert_called_once()- call_args = mock_boto_client.call_args+ call_args = mock_session_instance.client.call_args+ print(call_args)++ assert call_args[0][0] == 's3' # First positional arg is service nameassert 'config' in call_args[1]config = call_args[1]['config']assert isinstance(config, Config)@@ -236,7 +232,7 @@ def test_get_or_create_bucket_remotion_exception_on_multiple_buckets(with pytest.raises(RemotionException) as excinfo:remotion_client._get_or_create_bucket()-+assert excinfo.type == RemotionExceptionassert "You have multiple buckets" in str(excinfo.value)mock_get_remotion_buckets.assert_called_once()@@ -258,7 +254,7 @@ def test_invoke_lambda_unexpected_response_format(with pytest.raises(RemotionRenderingOutputError) as excinfo:remotion_client._invoke_lambda("my-function", "{}")-+assert excinfo.type == RemotionRenderingOutputErrorassert "Unexpected Lambda response format" in str(excinfo.value)mock_lambda_client.invoke.assert_called_once()@@ -278,7 +274,7 @@ def test_invoke_lambda_invalid_json_decode(with pytest.raises(RemotionRenderingOutputError) as excinfo:remotion_client._invoke_lambda("my-function", "{}")-+assert excinfo.type == RemotionRenderingOutputErrormock_lambda_client.invoke.assert_called_once()@@ -297,10 +293,10 @@ def test_construct_render_request_client_error_from_serialize_input_props(mock_render_params = Mock()mock_render_params.input_props = {"dummy": "data"}mock_render_params.serialize_params.return_value = {"serialized": "params"}-+with pytest.raises(RemotionInvalidArgumentException) as excinfo:remotion_client.construct_render_request(mock_render_params, "still")-+assert excinfo.type == RemotionInvalidArgumentExceptionassert "Failed to serialize input properties for rendering" in str(excinfo.value)assert "AccessDenied" in str(excinfo.value) # Ensure the original ClientError info is present@@ -311,21 +307,23 @@ def test_construct_render_request_client_error_from_serialize_input_props(@patch('boto3.client')-def test_create_s3_client_with_boto_session(mock_boto3_client_func):+def test_create_s3_client_with_session(mock_boto3_client_func):"""- Test that _create_s3_client uses the provided boto_session+ Test that _create_s3_client uses the provided sessioninstead of boto3.client directly."""# Arrange- mock_session = MagicMock()- mock_s3_client_from_session = MagicMock()+ mock_session = Mock()+ mock_s3_client_from_session = Mock()mock_session.client.return_value = mock_s3_client_from_session+ config = Config()client = RemotionClient(region=TEST_REGION,serve_url=TEST_SERVE_URL,function_name=TEST_FUNCTION_NAME,- boto_session=mock_session,+ session=mock_session,+ config=config)# Act@@ -333,40 +331,67 @@ def test_create_s3_client_with_boto_session(mock_boto3_client_func):# Assertassert s3_client == mock_s3_client_from_session- mock_session.client.assert_called_once_with('s3', region_name=TEST_REGION)- mock_boto3_client_func.assert_not_called() # Ensure boto3.client was not used+ mock_session.client.assert_called_once_with('s3', region_name=TEST_REGION, config=config)-@patch('boto3.client')-def test_create_s3_client_with_custom_timeout_config(mock_boto3_client_func, mock_s3_client):+@patch('remotion_lambda.remotionclient.Session')+def test_create_s3_client_with_custom_timeout_config(mock_session_class, mock_s3_client):"""Test that _create_s3_client correctly applies custom timeout settings- provided via botocore_config.+ provided via config."""# Arrangecustom_timeout = 10 # secondscustom_config = Config(connect_timeout=custom_timeout, read_timeout=custom_timeout)+ # Set up mock BEFORE creating RemotionClient+ mock_session_instance = mock_session_class.return_value+ mock_session_instance.client.return_value = mock_s3_client+client = RemotionClient(region=TEST_REGION,serve_url=TEST_SERVE_URL,function_name=TEST_FUNCTION_NAME,- botocore_config=custom_config,+ config=custom_config,)- mock_boto3_client_func.return_value = mock_s3_client# Acts3_client = client._create_s3_client()# Assertassert s3_client == mock_s3_client- mock_boto3_client_func.assert_called_once()-- # Extract the config argument passed to boto3.client- call_args, call_kwargs = mock_boto3_client_func.call_args- passed_config = call_kwargs.get('config')+ mock_session_instance.client.assert_called_once()+ # Extract the config argument passed to session.client+ call_args, call_kwargs = mock_session_instance.client.call_args++ assert call_args[0] == 's3'+ assert call_kwargs['region_name'] == TEST_REGION++ passed_config = call_kwargs.get('config')assert isinstance(passed_config, Config)assert passed_config.connect_timeout == custom_timeoutassert passed_config.read_timeout == custom_timeout- assert passed_config.s3 is None # No s3 addressing_style if not forced\ No newline at end of file+ assert passed_config.s3 is None++[email protected](RemotionClient, '_create_lambda_client')+def test_invoke_lambda_Invalid_argument(+ mock_create_lambda_client, mock_lambda_client, remotion_client+):+ """+ Test that _invoke_lambda raises RemotionRenderingOutputError for unexpected response types.+ """+ unexpected_payload = json.dumps([+ {'type': 'log', 'level': 'info', 'message': 'Still running'},+ {'status': 'pending', 'progress': 0.5} # Not 'success' or 'error'+ ])+ mock_lambda_client.invoke.return_value = {'Payload': Mock(read=lambda: unexpected_payload.encode('utf-8'))}+ mock_create_lambda_client.return_value = mock_lambda_client++ with pytest.raises(RemotionRenderingOutputError) as excinfo:+ remotion_client._invoke_lambda("my-function", "{}")++ assert excinfo.type == RemotionRenderingOutputError+ assert "Unexpected Lambda response format" in str(excinfo.value)+ mock_lambda_client.invoke.assert_called_once()diff --git a/packages/lambda-python/tests/test_render_client_render_media.py b/packages/lambda-python/tests/test_render_client_render_media.pyindex 1ac8cfa3e6..7283673c26 100644--- a/packages/lambda-python/tests/test_render_client_render_media.py+++ b/packages/lambda-python/tests/test_render_client_render_media.py@@ -2,7 +2,7 @@ from unittest import TestCasefrom remotion_lambda.models import RenderMediaParams, ShouldDownload, Webhookfrom remotion_lambda.remotionclient import RemotionClient-+from remotion_lambda.exception import RemotionInvalidArgumentExceptionclass TestRemotionClient(TestCase):def test_remotion_construct_request(self):@@ -27,3 +27,9 @@ class TestRemotionClient(TestCase):render_params=render_params, render_type="video-or-audio"))++ def test_remotion_construct_request_illegal_argument(self):+ with self.assertRaises(RemotionInvalidArgumentException):+ client = RemotionClient(+ region="us-east-1", serve_url="", function_name=""+ )