test_migrate_utils.py 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. # Copyright 2021-2025 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. import json
  12. from taipy.core._entity._migrate._utils import _migrate
  13. def test_migrate_entities_from_version_2(mocker):
  14. mocker.patch("taipy.core._entity._migrate._utils.version", return_value="3.1.0")
  15. with open("tests/core/_entity/data_to_migrate.json") as file:
  16. data = json.load(file)
  17. with open("tests/core/_entity/expected_data.json") as file:
  18. expected_data = json.load(file)
  19. migrated_data, _ = _migrate(data)
  20. assert expected_data == migrated_data
  21. # Execute again on the migrated data to ensure that the migration works on latest versions
  22. migrated_data, _ = _migrate(data)
  23. assert expected_data == migrated_data