6666 AsyncRPLogBatch ,
6767 AsyncRPRequestLog ,
6868 ErrorPrintingAsyncHttpRequest ,
69+ ItemUpdateRequest ,
6970 LaunchFinishRequest ,
7071 LaunchStartRequest ,
7172 RPFile ,
7273)
7374from reportportal_client .helpers import (
75+ ITEM_DESCRIPTION_LENGTH_LIMIT ,
76+ ITEM_NAME_LENGTH_LIMIT ,
77+ LAUNCH_DESCRIPTION_LENGTH_LIMIT ,
78+ LAUNCH_NAME_LENGTH_LIMIT ,
7479 LifoQueue ,
7580 agent_name_version ,
7681 await_if_necessary ,
7782 root_uri_join ,
7883 uri_join ,
79- verify_value_length ,
8084)
8185from reportportal_client .logs import MAX_LOG_BATCH_PAYLOAD_SIZE
8286from reportportal_client .steps import StepReporter
@@ -122,6 +126,12 @@ class Client:
122126 launch_uuid_print : bool
123127 print_output : OutputType
124128 truncate_attributes : bool
129+ truncate_fields : bool
130+ replace_binary_chars : bool
131+ launch_name_length_limit : int
132+ item_name_length_limit : int
133+ launch_description_length_limit : int
134+ item_description_length_limit : int
125135 _skip_analytics : Optional [str ]
126136 _session : Optional [ClientSession ]
127137 __stat_task : Optional [asyncio .Task ]
@@ -142,6 +152,12 @@ def __init__(
142152 launch_uuid_print : bool = False ,
143153 print_output : OutputType = OutputType .STDOUT ,
144154 truncate_attributes : bool = True ,
155+ truncate_fields : bool = True ,
156+ replace_binary_chars : bool = True ,
157+ launch_name_length_limit : int = LAUNCH_NAME_LENGTH_LIMIT ,
158+ item_name_length_limit : int = ITEM_NAME_LENGTH_LIMIT ,
159+ launch_description_length_limit : int = LAUNCH_DESCRIPTION_LENGTH_LIMIT ,
160+ item_description_length_limit : int = ITEM_DESCRIPTION_LENGTH_LIMIT ,
145161 # OAuth 2.0 Password Grant parameters
146162 oauth_uri : Optional [str ] = None ,
147163 oauth_username : Optional [str ] = None ,
@@ -153,27 +169,35 @@ def __init__(
153169 ) -> None :
154170 """Initialize the class instance with arguments.
155171
156- :param endpoint: Endpoint of the ReportPortal service.
157- :param project: Project name to report to.
158- :param api_key: Authorization API key.
159- :param oauth_uri: OAuth 2.0 token endpoint URI (for OAuth authentication).
160- :param oauth_username: Username for OAuth 2.0 authentication.
161- :param oauth_password: Password for OAuth 2.0 authentication.
162- :param oauth_client_id: OAuth 2.0 client ID.
163- :param oauth_client_secret: OAuth 2.0 client secret (optional).
164- :param oauth_scope: OAuth 2.0 scope (optional).
165- :param is_skipped_an_issue: Option to mark skipped tests as not 'To Investigate' items on the
166- server side.
167- :param verify_ssl: Option to skip ssl verification.
168- :param retries: Number of retry attempts to make in case of connection / server errors.
169- :param max_pool_size: Option to set the maximum number of connections to save the pool.
170- :param http_timeout: A float in seconds for connect and read timeout. Use a Tuple to
171- specific connect and read separately.
172- :param keepalive_timeout: Maximum amount of idle time in seconds before force connection closing.
173- :param mode: Launch mode, all Launches started by the client will be in that mode.
174- :param launch_uuid_print: Print Launch UUID into passed TextIO or by default to stdout.
175- :param print_output: Set output stream for Launch UUID printing.
176- :param truncate_attributes: Truncate test item attributes to default maximum length.
172+ :param endpoint: Endpoint of the ReportPortal service.
173+ :param project: Project name to report to.
174+ :param api_key: Authorization API key.
175+ :param oauth_uri: OAuth 2.0 token endpoint URI (for OAuth authentication).
176+ :param oauth_username: Username for OAuth 2.0 authentication.
177+ :param oauth_password: Password for OAuth 2.0 authentication.
178+ :param oauth_client_id: OAuth 2.0 client ID.
179+ :param oauth_client_secret: OAuth 2.0 client secret (optional).
180+ :param oauth_scope: OAuth 2.0 scope (optional).
181+ :param is_skipped_an_issue: Option to mark skipped tests as not 'To Investigate' items on the
182+ server side.
183+ :param verify_ssl: Option to skip ssl verification.
184+ :param retries: Number of retry attempts to make in case of connection / server
185+ errors.
186+ :param max_pool_size: Option to set the maximum number of connections to save the pool.
187+ :param http_timeout: A float in seconds for connect and read timeout. Use a Tuple to
188+ specific connect and read separately.
189+ :param keepalive_timeout: Maximum amount of idle time in seconds before force connection
190+ closing.
191+ :param mode: Launch mode, all Launches started by the client will be in that mode.
192+ :param launch_uuid_print: Print Launch UUID into passed TextIO or by default to stdout.
193+ :param print_output: Set output stream for Launch UUID printing.
194+ :param truncate_attributes: Truncate test item attributes to default maximum length.
195+ :param truncate_fields: Truncate request fields to configured limits.
196+ :param replace_binary_chars: Toggle replacement of basic binary characters with \ufffd char.
197+ :param launch_name_length_limit: Maximum allowed launch name length.
198+ :param item_name_length_limit: Maximum allowed test item name length.
199+ :param launch_description_length_limit: Maximum allowed launch description length.
200+ :param item_description_length_limit: Maximum allowed test item description length.
177201 """
178202 self .api_v1 , self .api_v2 = "v1" , "v2"
179203 self .endpoint = endpoint
@@ -193,6 +217,12 @@ def __init__(
193217 self ._session = None
194218 self .__stat_task = None
195219 self .truncate_attributes = truncate_attributes
220+ self .truncate_fields = truncate_fields
221+ self .replace_binary_chars = replace_binary_chars
222+ self .launch_name_length_limit = launch_name_length_limit
223+ self .item_name_length_limit = item_name_length_limit
224+ self .launch_description_length_limit = launch_description_length_limit
225+ self .item_description_length_limit = item_description_length_limit
196226
197227 self .api_key = api_key
198228 # Handle deprecated token argument
@@ -341,7 +371,12 @@ async def start_launch(
341371 request_payload = LaunchStartRequest (
342372 name = name ,
343373 start_time = start_time ,
344- attributes = verify_value_length (attributes ) if self .truncate_attributes else attributes ,
374+ attributes = attributes ,
375+ truncate_attributes_enabled = self .truncate_attributes ,
376+ truncate_fields_enabled = self .truncate_fields ,
377+ replace_binary_characters = self .replace_binary_chars ,
378+ launch_name_length_limit = self .launch_name_length_limit ,
379+ launch_description_length_limit = self .launch_description_length_limit ,
345380 description = description ,
346381 mode = self .mode ,
347382 rerun = rerun ,
@@ -414,7 +449,12 @@ async def start_test_item(
414449 start_time ,
415450 item_type ,
416451 launch_uuid ,
417- attributes = verify_value_length (attributes ) if self .truncate_attributes else attributes ,
452+ attributes = attributes ,
453+ truncate_attributes_enabled = self .truncate_attributes ,
454+ truncate_fields_enabled = self .truncate_fields ,
455+ replace_binary_characters = self .replace_binary_chars ,
456+ item_name_length_limit = self .item_name_length_limit ,
457+ item_description_length_limit = self .item_description_length_limit ,
418458 code_ref = code_ref ,
419459 description = description ,
420460 has_stats = has_stats ,
@@ -474,7 +514,11 @@ async def finish_test_item(
474514 end_time ,
475515 launch_uuid ,
476516 status ,
477- attributes = verify_value_length (attributes ) if self .truncate_attributes else attributes ,
517+ attributes = attributes ,
518+ truncate_attributes_enabled = self .truncate_attributes ,
519+ truncate_fields_enabled = self .truncate_fields ,
520+ replace_binary_characters = self .replace_binary_chars ,
521+ item_description_length_limit = self .item_description_length_limit ,
478522 description = description ,
479523 test_case_id = test_case_id ,
480524 is_skipped_an_issue = self .is_skipped_an_issue ,
@@ -514,7 +558,11 @@ async def finish_launch(
514558 request_payload = LaunchFinishRequest (
515559 end_time ,
516560 status = status ,
517- attributes = verify_value_length (attributes ) if self .truncate_attributes else attributes ,
561+ attributes = attributes ,
562+ truncate_attributes_enabled = self .truncate_attributes ,
563+ truncate_fields_enabled = self .truncate_fields ,
564+ replace_binary_characters = self .replace_binary_chars ,
565+ launch_description_length_limit = self .launch_description_length_limit ,
518566 description = kwargs .get ("description" ),
519567 ).payload
520568 response = await AsyncHttpRequest (
@@ -539,10 +587,14 @@ async def update_test_item(
539587 :param description: Test Item description.
540588 :return: Response message or None.
541589 """
542- data = {
543- "description" : description ,
544- "attributes" : verify_value_length (attributes ) if self .truncate_attributes else attributes ,
545- }
590+ data = ItemUpdateRequest (
591+ description = description ,
592+ attributes = attributes ,
593+ truncate_attributes_enabled = self .truncate_attributes ,
594+ truncate_fields_enabled = self .truncate_fields ,
595+ replace_binary_characters = self .replace_binary_chars ,
596+ item_description_length_limit = self .item_description_length_limit ,
597+ ).payload
546598 item_id = await self .get_item_id_by_uuid (item_uuid )
547599 url = root_uri_join (self .base_url_v1 , "item" , item_id , "update" )
548600 response = await AsyncHttpRequest (
@@ -670,6 +722,13 @@ def clone(self) -> "Client":
670722 mode = self .mode ,
671723 launch_uuid_print = self .launch_uuid_print ,
672724 print_output = self .print_output ,
725+ truncate_fields = self .truncate_fields ,
726+ truncate_attributes = self .truncate_attributes ,
727+ replace_binary_chars = self .replace_binary_chars ,
728+ launch_name_length_limit = self .launch_name_length_limit ,
729+ item_name_length_limit = self .item_name_length_limit ,
730+ launch_description_length_limit = self .launch_description_length_limit ,
731+ item_description_length_limit = self .item_description_length_limit ,
673732 oauth_uri = self .oauth_uri ,
674733 oauth_username = self .oauth_username ,
675734 oauth_password = self .oauth_password ,
0 commit comments