6
6
from fastapi .testclient import TestClient
7
7
from teamcity import is_running_under_teamcity
8
8
9
+ from geolib ._compat import IS_PYDANTIC_V2
9
10
from geolib .models import BaseDataClass , DSettlementModel
10
11
from geolib .models .base_model import BaseModel , BaseModelList , MetaData
11
12
from geolib .models .dfoundations .dfoundations_model import DFoundationsModel
@@ -104,6 +105,27 @@ def test_basemodellist_execute(self, model, filename, modelname):
104
105
assert len (output .errors ) == 1
105
106
assert fn in output .errors [- 1 ]
106
107
108
+ @pytest .mark .unittest
109
+ def test_serialize_modellist (self ):
110
+ # 1. Set initial test data.
111
+ a = DSettlementModel (filename = "a.txt" )
112
+ b = DSettlementModel (filename = "b.txt" )
113
+ ml = BaseModelList (models = [a , b ])
114
+
115
+ # 2. Define test action.
116
+ if IS_PYDANTIC_V2 :
117
+ _dump = ml .model_dump ()
118
+ else :
119
+ _dump = ml .dict ()
120
+
121
+ # 3. Verify final expectations.
122
+ if IS_PYDANTIC_V2 :
123
+ assert _dump .get ("models" ) == [a .model_dump (), b .model_dump ()]
124
+ else :
125
+ assert _dump .get ("models" ) == [a .dict (), b .dict ()]
126
+ for _model in _dump .get ("models" ):
127
+ assert _model ["datastructure" ]
128
+
107
129
@pytest .mark .acceptance
108
130
@only_teamcity
109
131
@mock .patch ("geolib.models.base_model.requests.post" , side_effect = client .post )
@@ -120,7 +142,6 @@ def test_basemodellist_execute(self, model, filename, modelname):
120
142
(DFoundationsModel , "bm1-1a.foi" , "dfoundations/benchmarks" ),
121
143
],
122
144
)
123
- @pytest .mark .skip (reason = "Failing after pydantic 2 update. Cause of failure should be investigated in more detail." )
124
145
def test_basemodellist_execute_remote (self , _ , __ , model , filename , modelname ):
125
146
# Setup models
126
147
a = model ()
@@ -170,6 +191,7 @@ def test_basemodel_execute_remote(self, _, __, model, filename, modelname):
170
191
model = modelinstance .execute_remote ("/" ) # no url is needed with the TestClient
171
192
assert model .output
172
193
194
+
173
195
class TestBool :
174
196
@pytest .mark .unittest
175
197
def test_init (self ):
0 commit comments