Skip to content

Commit

Permalink
add unit test dir
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriupredoi committed Oct 23, 2023
1 parent ba7738c commit 17c01dd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/unit/test_download_from_mass_permissions.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 17c01dd

Please sign in to comment.