@@ -101,3 +101,77 @@ async def test_process_with_cancellation() -> None:
101101 "cancel_token" : cancel_token ,
102102 }
103103 )
104+
105+
106+ @pytest .mark .asyncio
107+ async def test_process_includes_user_agent_header () -> None :
108+ """Test that User-Agent header is included in requests."""
109+ client = DecartClient (api_key = "test-key" )
110+
111+ with patch ("aiohttp.ClientSession" ) as mock_session_cls :
112+ mock_response = MagicMock ()
113+ mock_response .ok = True
114+ mock_response .read = AsyncMock (return_value = b"fake video data" )
115+
116+ mock_session = MagicMock ()
117+ mock_session .__aenter__ = AsyncMock (return_value = mock_session )
118+ mock_session .__aexit__ = AsyncMock (return_value = None )
119+ mock_session .post = MagicMock ()
120+ mock_session .post .return_value .__aenter__ = AsyncMock (return_value = mock_response )
121+ mock_session .post .return_value .__aexit__ = AsyncMock (return_value = None )
122+
123+ mock_session_cls .return_value = mock_session
124+
125+ await client .process (
126+ {
127+ "model" : models .video ("lucy-pro-t2v" ),
128+ "prompt" : "Test prompt" ,
129+ }
130+ )
131+
132+ # Verify post was called with User-Agent header
133+ mock_session .post .assert_called_once ()
134+ call_kwargs = mock_session .post .call_args [1 ]
135+ headers = call_kwargs .get ("headers" , {})
136+
137+ assert "User-Agent" in headers
138+ assert headers ["User-Agent" ].startswith ("decart-python-sdk/" )
139+ assert "lang/py" in headers ["User-Agent" ]
140+
141+
142+ @pytest .mark .asyncio
143+ async def test_process_includes_integration_in_user_agent () -> None :
144+ """Test that integration parameter is included in User-Agent header."""
145+ client = DecartClient (api_key = "test-key" , integration = "langchain/0.1.0" )
146+
147+ with patch ("aiohttp.ClientSession" ) as mock_session_cls :
148+ mock_response = MagicMock ()
149+ mock_response .ok = True
150+ mock_response .read = AsyncMock (return_value = b"fake video data" )
151+
152+ mock_session = MagicMock ()
153+ mock_session .__aenter__ = AsyncMock (return_value = mock_session )
154+ mock_session .__aexit__ = AsyncMock (return_value = None )
155+ mock_session .post = MagicMock ()
156+ mock_session .post .return_value .__aenter__ = AsyncMock (return_value = mock_response )
157+ mock_session .post .return_value .__aexit__ = AsyncMock (return_value = None )
158+
159+ mock_session_cls .return_value = mock_session
160+
161+ await client .process (
162+ {
163+ "model" : models .video ("lucy-pro-t2v" ),
164+ "prompt" : "Test prompt" ,
165+ }
166+ )
167+
168+ # Verify post was called with User-Agent header including integration
169+ mock_session .post .assert_called_once ()
170+ call_kwargs = mock_session .post .call_args [1 ]
171+ headers = call_kwargs .get ("headers" , {})
172+
173+ assert "User-Agent" in headers
174+ assert headers ["User-Agent" ].startswith ("decart-python-sdk/" )
175+ assert "lang/py" in headers ["User-Agent" ]
176+ assert "langchain/0.1.0" in headers ["User-Agent" ]
177+ assert headers ["User-Agent" ].endswith (" langchain/0.1.0" )
0 commit comments