@@ -144,127 +144,6 @@ def _create_simple_yaml_content(self, app_name="Test App", app_mode="chat"):
144144        }
145145        return  yaml .dump (yaml_data , allow_unicode = True )
146146
147-     def  test_import_app_yaml_content_success (self , db_session_with_containers , mock_external_service_dependencies ):
148-         """ 
149-         Test successful app import from YAML content. 
150-         """ 
151-         fake  =  Faker ()
152-         app , account  =  self ._create_test_app_and_account (db_session_with_containers , mock_external_service_dependencies )
153- 
154-         # Create YAML content 
155-         yaml_content  =  self ._create_simple_yaml_content (fake .company (), "chat" )
156- 
157-         # Import app 
158-         dsl_service  =  AppDslService (db_session_with_containers )
159-         result  =  dsl_service .import_app (
160-             account = account ,
161-             import_mode = ImportMode .YAML_CONTENT ,
162-             yaml_content = yaml_content ,
163-             name = "Imported App" ,
164-             description = "Imported app description" ,
165-         )
166- 
167-         # Verify import result 
168-         assert  result .status  ==  ImportStatus .COMPLETED 
169-         assert  result .app_id  is  not   None 
170-         assert  result .app_mode  ==  "chat" 
171-         assert  result .imported_dsl_version  ==  "0.3.0" 
172-         assert  result .error  ==  "" 
173- 
174-         # Verify app was created in database 
175-         imported_app  =  db_session_with_containers .query (App ).filter (App .id  ==  result .app_id ).first ()
176-         assert  imported_app  is  not   None 
177-         assert  imported_app .name  ==  "Imported App" 
178-         assert  imported_app .description  ==  "Imported app description" 
179-         assert  imported_app .mode  ==  "chat" 
180-         assert  imported_app .tenant_id  ==  account .current_tenant_id 
181-         assert  imported_app .created_by  ==  account .id 
182- 
183-         # Verify model config was created 
184-         model_config  =  (
185-             db_session_with_containers .query (AppModelConfig ).filter (AppModelConfig .app_id  ==  result .app_id ).first ()
186-         )
187-         assert  model_config  is  not   None 
188-         # The provider and model_id are stored in the model field as JSON 
189-         model_dict  =  model_config .model_dict 
190-         assert  model_dict ["provider" ] ==  "openai" 
191-         assert  model_dict ["name" ] ==  "gpt-3.5-turbo" 
192- 
193-     def  test_import_app_yaml_url_success (self , db_session_with_containers , mock_external_service_dependencies ):
194-         """ 
195-         Test successful app import from YAML URL. 
196-         """ 
197-         fake  =  Faker ()
198-         app , account  =  self ._create_test_app_and_account (db_session_with_containers , mock_external_service_dependencies )
199- 
200-         # Create YAML content for mock response 
201-         yaml_content  =  self ._create_simple_yaml_content (fake .company (), "chat" )
202- 
203-         # Setup mock response 
204-         mock_response  =  MagicMock ()
205-         mock_response .content  =  yaml_content .encode ("utf-8" )
206-         mock_response .raise_for_status .return_value  =  None 
207-         mock_external_service_dependencies ["ssrf_proxy" ].get .return_value  =  mock_response 
208- 
209-         # Import app from URL 
210-         dsl_service  =  AppDslService (db_session_with_containers )
211-         result  =  dsl_service .import_app (
212-             account = account ,
213-             import_mode = ImportMode .YAML_URL ,
214-             yaml_url = "https://example.com/app.yaml" ,
215-             name = "URL Imported App" ,
216-             description = "App imported from URL" ,
217-         )
218- 
219-         # Verify import result 
220-         assert  result .status  ==  ImportStatus .COMPLETED 
221-         assert  result .app_id  is  not   None 
222-         assert  result .app_mode  ==  "chat" 
223-         assert  result .imported_dsl_version  ==  "0.3.0" 
224-         assert  result .error  ==  "" 
225- 
226-         # Verify app was created in database 
227-         imported_app  =  db_session_with_containers .query (App ).filter (App .id  ==  result .app_id ).first ()
228-         assert  imported_app  is  not   None 
229-         assert  imported_app .name  ==  "URL Imported App" 
230-         assert  imported_app .description  ==  "App imported from URL" 
231-         assert  imported_app .mode  ==  "chat" 
232-         assert  imported_app .tenant_id  ==  account .current_tenant_id 
233- 
234-         # Verify ssrf_proxy was called 
235-         mock_external_service_dependencies ["ssrf_proxy" ].get .assert_called_once_with (
236-             "https://example.com/app.yaml" , follow_redirects = True , timeout = (10 , 10 )
237-         )
238- 
239-     def  test_import_app_invalid_yaml_format (self , db_session_with_containers , mock_external_service_dependencies ):
240-         """ 
241-         Test app import with invalid YAML format. 
242-         """ 
243-         fake  =  Faker ()
244-         app , account  =  self ._create_test_app_and_account (db_session_with_containers , mock_external_service_dependencies )
245- 
246-         # Create invalid YAML content 
247-         invalid_yaml  =  "invalid: yaml: content: [" 
248- 
249-         # Import app with invalid YAML 
250-         dsl_service  =  AppDslService (db_session_with_containers )
251-         result  =  dsl_service .import_app (
252-             account = account ,
253-             import_mode = ImportMode .YAML_CONTENT ,
254-             yaml_content = invalid_yaml ,
255-             name = "Invalid App" ,
256-         )
257- 
258-         # Verify import failed 
259-         assert  result .status  ==  ImportStatus .FAILED 
260-         assert  result .app_id  is  None 
261-         assert  "Invalid YAML format"  in  result .error 
262-         assert  result .imported_dsl_version  ==  "" 
263- 
264-         # Verify no app was created in database 
265-         apps_count  =  db_session_with_containers .query (App ).filter (App .tenant_id  ==  account .current_tenant_id ).count ()
266-         assert  apps_count  ==  1   # Only the original test app 
267- 
268147    def  test_import_app_missing_yaml_content (self , db_session_with_containers , mock_external_service_dependencies ):
269148        """ 
270149        Test app import with missing YAML content. 
0 commit comments