@@ -133,23 +133,37 @@ def test_design_space_limits():
133
133
# Given
134
134
session = FakeSession ()
135
135
collection = DesignSpaceCollection (uuid .uuid4 (), session )
136
+
137
+ descriptors = [RealDescriptor (f"R-{ i } " , lower_bound = 0 , upper_bound = 1 , units = "" ) for i in range (128 )]
138
+ descriptor_values = {f"R-{ i } " : str (random .random ()) for i in range (128 )}
136
139
137
- too_big = EnumeratedDesignSpace (
138
- "foo " ,
139
- description = "bar " ,
140
- descriptors = [ RealDescriptor ( "R-{}" . format ( i ), lower_bound = 0 , upper_bound = 1 , units = "" ) for i in range ( 128 )] ,
141
- data = [{ f"R- { i } " : str ( random . random ()) for i in range ( 128 )} for _ in range ( 2001 )]
140
+ just_right = EnumeratedDesignSpace (
141
+ "just right " ,
142
+ description = "just right desc " ,
143
+ descriptors = descriptors ,
144
+ data = [descriptor_values ] * 2000
142
145
)
143
146
144
- just_right = EnumeratedDesignSpace (
145
- "foo " ,
146
- description = "bar " ,
147
- descriptors = [ RealDescriptor ( "R-{}" . format ( i ), lower_bound = 0 , upper_bound = 1 , units = "" ) for i in range ( 128 )] ,
148
- data = [{ f"R- { i } " : str ( random . random ()) for i in range ( 128 )} for _ in range ( 2000 )]
147
+ too_big = EnumeratedDesignSpace (
148
+ "too big " ,
149
+ description = "too big desc " ,
150
+ descriptors = just_right . descriptors ,
151
+ data = [descriptor_values ] * 2001
149
152
)
150
153
151
- # create mock post response by setting the status
152
- mock_response = _ds_to_response (just_right , status = "READY" )
154
+ # create mock post response by setting the status.
155
+ # Deserializing that huge dict takes a long time, and it's done twice when making a call to
156
+ # register or update (the second is the automatic validation kick-off). Since we're only
157
+ # interested in checking the validation pre-request, we can specify a tiny response to speed up
158
+ # the test execution.
159
+ dummy_desc = descriptors [0 ]
160
+ dummy_resp = EnumeratedDesignSpace (
161
+ "basic" ,
162
+ description = "basic desc" ,
163
+ descriptors = [dummy_desc ],
164
+ data = [{dummy_desc .key : descriptor_values [dummy_desc .key ]}]
165
+ )
166
+ mock_response = _ds_to_response (dummy_resp , status = "READY" )
153
167
session .responses .append (mock_response )
154
168
155
169
# Then
0 commit comments