|
| 1 | +from pathlib import Path |
| 2 | +import pytest |
| 3 | +from .. import conf, api |
| 4 | + |
| 5 | + |
| 6 | +@pytest.mark.skipif(conf.TF_USE_DATALAD, reason="S3 only") |
| 7 | +def test_update_s3(tmp_path): |
| 8 | + conf.TF_HOME = tmp_path / 'templateflow' |
| 9 | + conf.TF_HOME.mkdir(exist_ok=True) |
| 10 | + |
| 11 | + # replace TF_SKEL_URL with the path of a legacy skeleton |
| 12 | + _skel_url = conf._s3.TF_SKEL_URL |
| 13 | + conf._s3.TF_SKEL_URL = ( |
| 14 | + "https://github.com/templateflow/python-client/raw/0.5.0/" |
| 15 | + "templateflow/conf/templateflow-skel.{ext}".format |
| 16 | + ) |
| 17 | + # initialize templateflow home, making sure to pull the legacy skeleton |
| 18 | + conf.update(local=False) |
| 19 | + # ensure we can grab a file |
| 20 | + assert Path(api.get('MNI152NLin2009cAsym', resolution=2, desc='brain', suffix='mask')).exists() |
| 21 | + # and ensure we can't fetch one that doesn't yet exist |
| 22 | + assert not api.get('Fischer344', hemi='L', desc='brain', suffix='mask') |
| 23 | + |
| 24 | + # refresh the skeleton using the most recent skeleton |
| 25 | + conf._s3.TF_SKEL_URL = _skel_url |
| 26 | + conf.update(local=True, overwrite=True) |
| 27 | + assert Path(api.get('Fischer344', hemi='L', desc='brain', suffix='mask')).exists() |
0 commit comments