def test_no_migration(info_mock): # type: (Mock) -> None response = _load_str('response.json') requests = Model.parseArray(AssetRequest, response) assert isinstance(requests, Collection) assert requests.length() == 1 handler = connect_migration.MigrationHandler() request = handler.migrate(requests.get(0)) info_mock.assert_called_once_with('[MIGRATION::PR-5852-1608-0000] ' 'AssetRequest does not need migration.') assert request == requests.get(0)
def test_needsMigration(): # type: () -> None handler = connect_migration.MigrationHandler() # No migration needed response_no_migration = _load_str('response.json') requests_no_migration = Model.parseArray(AssetRequest, response_no_migration) assert isinstance(requests_no_migration, Collection) assert requests_no_migration.length() == 1 assert isinstance(requests_no_migration.get(0), AssetRequest) assert not requests_no_migration.get(0).needsMigration( handler.migration_key) # Migration needed response_migration = _load_str('request.migrate.valid.json') request = Model.parse(AssetRequest, response_migration) assert isinstance(request, AssetRequest) assert request.needsMigration(handler.migration_key)