Skip to content

Commit 28cd9e2

Browse files
author
Arjan Zijderveld
committed
Unit test versioning is correct for type registry presets
1 parent b8d36d4 commit 28cd9e2

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

test/test_type_registry.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
import copy
1617
import os
1718
import unittest
1819
from pathlib import Path
@@ -193,11 +194,29 @@ def test_valid_type_registry_presets(self):
193194
# Check requirements of JSON file
194195
self.assertIn('types', type_registry)
195196

196-
if 'runtime_id' in type_registry:
197-
self.assertTrue(isinstance(type_registry['runtime_id'], int))
198-
199197
# Try to apply type registry preset
198+
RuntimeConfiguration().clear_type_registry()
199+
RuntimeConfiguration().update_type_registry(load_type_registry_preset('default'))
200200
RuntimeConfiguration().update_type_registry(type_registry)
201201

202+
original_type_reg = copy.deepcopy(RuntimeConfiguration().type_registry)
203+
204+
if 'runtime_id' in type_registry:
205+
self.assertTrue(isinstance(type_registry['runtime_id'], int))
206+
latest_runtime_id = type_registry['runtime_id']
207+
208+
# Switch type registry versioning state
209+
RuntimeConfiguration().set_active_spec_version_id(0)
210+
RuntimeConfiguration().set_active_spec_version_id(latest_runtime_id)
211+
212+
# Test if switch resulted in identical type registry
213+
for type_string, type_definition in RuntimeConfiguration().type_registry['types'].items():
214+
if type_definition:
215+
self.assertEqual(
216+
type_definition.__name__,
217+
original_type_reg['types'][type_string].__name__,
218+
'Type string "{}" mismatch between latest state and when versioning is applied'
219+
)
220+
202221

203222

0 commit comments

Comments
 (0)