| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  | from uuid import uuid4 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-21 10:43:49 +08:00
										 |  |  | from core.variables import SegmentType | 
					
						
							|  |  |  | from factories import variable_factory | 
					
						
							| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  | from models import ConversationVariable | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def test_from_variable_and_to_variable(): | 
					
						
							| 
									
										
										
										
											2024-10-21 10:43:49 +08:00
										 |  |  |     variable = variable_factory.build_variable_from_mapping( | 
					
						
							| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-08-23 23:52:25 +08:00
										 |  |  |             "id": str(uuid4()), | 
					
						
							|  |  |  |             "name": "name", | 
					
						
							|  |  |  |             "value_type": SegmentType.OBJECT, | 
					
						
							|  |  |  |             "value": { | 
					
						
							|  |  |  |                 "key": { | 
					
						
							|  |  |  |                     "key": "value", | 
					
						
							| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  |                 } | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     conversation_variable = ConversationVariable.from_variable( | 
					
						
							| 
									
										
										
										
											2024-08-23 23:52:25 +08:00
										 |  |  |         app_id="app_id", conversation_id="conversation_id", variable=variable | 
					
						
							| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     assert conversation_variable.to_variable() == variable |