diff --git a/tests/unit/test_download_from_mass_permissions.py b/tests/unit/test_download_from_mass_permissions.py new file mode 100644 index 00000000..cdefa6a8 --- /dev/null +++ b/tests/unit/test_download_from_mass_permissions.py @@ -0,0 +1,32 @@ +import os +import shutil +import stat + +from bgcval2.download_from_mass import download_from_mass as dfm + + +def test_allowed_user(): + dfm(jobID="u-xxx", + doMoo=False, + auto_download=False, + config_user="defaults" + ) + user_home = os.path.expanduser('~') + output_folder = "bgcval2/local_test/BGC_data/u-xxx/" + run_dir = os.path.join(user_home, output_folder) + assert os.stat(run_dir).st_mode == 16893 + + +def test_disallowed_user(): + user_home = os.path.expanduser('~') + output_folder = "bgcval2/local_test/BGC_data/u-xxx/" + run_dir = os.path.join(user_home, output_folder) + st = os.stat(run_dir) + os.chmod(run_dir, False) + dfm(jobID="u-xxx", + doMoo=False, + auto_download=False, + config_user="defaults" + ) + assert os.stat(run_dir).st_mode == 16384 + shutil.rmtree(run_dir, ignore_errors=True)