File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed 
src/models_library/api_schemas_webserver Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -109,18 +109,22 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
109109
110110    @classmethod  
111111    def  from_domain_model (cls , item : LicensedItem ) ->  Self :
112- 
113112        return  cls .model_validate (
114113            {
115-                 "licensed_item_id" : item .licensed_item_id ,
116-                 "display_name" : item .display_name ,
117-                 "licensed_resource_type" : item .licensed_resource_type ,
114+                 ** item .model_dump (
115+                     include = {
116+                         "licensed_item_id" ,
117+                         "display_name" ,
118+                         "licensed_resource_type" ,
119+                         "pricing_plan_id" ,
120+                         "created_at" ,
121+                         "modified_at" ,
122+                     },
123+                     exclude_unset = True ,
124+                 ),
118125                "licensed_resource_data" : {
119126                    ** item .licensed_resource_data ,
120127                },
121-                 "pricing_plan_id" : item .pricing_plan_id ,
122-                 "created_at" : item .created_at ,
123-                 "modified_at" : item .modified_at ,
124128            }
125129        )
126130
Original file line number Diff line number Diff line change @@ -20,12 +20,15 @@ def test_licensed_item_from_domain_model():
2020        # date is required 
2121        assert  got .licensed_resource_data .source .features ["date" ]
2222
23-         # 
23+         # id is required  
2424        assert  (
2525            got .licensed_resource_data .source .id 
2626            ==  item .licensed_resource_data ["source" ]["id" ]
2727        )
2828
29+         # checks unset fields 
30+         assert  "category_icon"  not  in   got .licensed_resource_data .model_fields_set 
31+ 
2932
3033def  test_strict_check_of_examples ():
3134    class  TestLicensedItemRestGet (LicensedItemRestGet ):
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments