|
13 | 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 | 14 | # See the License for the specific language governing permissions and
|
15 | 15 | # limitations under the License.
|
| 16 | +import copy |
16 | 17 | import os
|
17 | 18 | import unittest
|
18 | 19 | from pathlib import Path
|
@@ -193,11 +194,29 @@ def test_valid_type_registry_presets(self):
|
193 | 194 | # Check requirements of JSON file
|
194 | 195 | self.assertIn('types', type_registry)
|
195 | 196 |
|
196 |
| - if 'runtime_id' in type_registry: |
197 |
| - self.assertTrue(isinstance(type_registry['runtime_id'], int)) |
198 |
| - |
199 | 197 | # Try to apply type registry preset
|
| 198 | + RuntimeConfiguration().clear_type_registry() |
| 199 | + RuntimeConfiguration().update_type_registry(load_type_registry_preset('default')) |
200 | 200 | RuntimeConfiguration().update_type_registry(type_registry)
|
201 | 201 |
|
| 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 | + |
202 | 221 |
|
203 | 222 |
|
0 commit comments