From c13b367e36faeaf4a5204626d863d54dfb15747c Mon Sep 17 00:00:00 2001 From: mathiasg Date: Mon, 17 Aug 2020 22:46:13 -0400 Subject: [PATCH] ENH: Add test for skeleton update --- templateflow/tests/test_conf.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 templateflow/tests/test_conf.py diff --git a/templateflow/tests/test_conf.py b/templateflow/tests/test_conf.py new file mode 100644 index 00000000..0c537943 --- /dev/null +++ b/templateflow/tests/test_conf.py @@ -0,0 +1,25 @@ +from pathlib import Path +from .. import conf, api + + +def test_update_s3(tmp_path): + conf.TF_HOME = tmp_path / 'templateflow' + conf.TF_HOME.mkdir(exist_ok=True) + + # replace TF_SKEL_URL with the path of a legacy skeleton + _skel_url = conf._s3.TF_SKEL_URL + conf._s3.TF_SKEL_URL = ( + "https://github.com/templateflow/python-client/raw/0.5.0/" + "templateflow/conf/templateflow-skel.{ext}".format + ) + # initialize templateflow home, making sure to pull the legacy skeleton + conf.update(local=False) + # ensure we can grab a file + assert Path(api.get('MNI152NLin2009cAsym', resolution=2, desc='brain', suffix='mask')).exists() + # and ensure we can't fetch one that doesn't yet exist + assert not api.get('Fischer344', hemi='L', desc='brain', suffix='mask') + + # refresh the skeleton using the most recent skeleton + conf._s3.TF_SKEL_URL = _skel_url + conf.update(local=True, overwrite=True) + assert Path(api.get('Fischer344', hemi='L', desc='brain', suffix='mask')).exists()