Skip to content

Commit

Permalink
Issue #74: Testing unit tests for osfclient.
Browse files Browse the repository at this point in the history
  • Loading branch information
bongjinkoo committed May 15, 2022
1 parent f0898a8 commit 4be65f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
20 changes: 16 additions & 4 deletions ioSPI/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def __init__(
def ls(self):
"""List all files in the project."""
print(f"Listing files from OSF project: {self.project_id}...")
os.system("osf ls")
# os.system("osf ls")
os.system(f"/usr/share/miniconda/envs/ioSPI/bin/osf ls")

def download(self, remote_path: str, local_path: str):
"""Download a file from an OSF project and save it locally.
Expand All @@ -79,7 +80,11 @@ def download(self, remote_path: str, local_path: str):

full_remote_path = self.storage + "/" + remote_path
print(f"Downloading {full_remote_path} to {local_path}...")
os.system(f"osf fetch {full_remote_path} {local_path}")
# os.system(f"osf fetch {full_remote_path} {local_path}")
os.system(
f"/usr/share/miniconda/envs/ioSPI/bin/osf fetch "
f"{full_remote_path} {local_path}"
)
print("Done!")

def upload(self, local_path: str, remote_path: str):
Expand Down Expand Up @@ -108,7 +113,11 @@ def upload(self, local_path: str, remote_path: str):

full_remote_path = self.storage + "/" + remote_path
print(f"Uploading {local_path} to {full_remote_path}...")
os.system(f"osf upload {local_path} {full_remote_path}")
# os.system(f"osf upload {local_path} {full_remote_path}")
os.system(
f"/usr/share/miniconda/envs/ioSPI/bin/osf upload "
f"{local_path} {full_remote_path}"
)
print("Done!")

def remove(self, remote_path: str):
Expand All @@ -128,5 +137,8 @@ def remove(self, remote_path: str):

full_remote_path = self.storage + "/" + remote_path
print(f"Removing {full_remote_path} in the project...")
os.system(f"osf remove {full_remote_path}")
# os.system(f"osf remove {full_remote_path}")
os.system(
f"/usr/share/miniconda/envs/ioSPI/bin/osf remove " f"{full_remote_path}"
)
print("Done!")
6 changes: 4 additions & 2 deletions tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def test_upload_valid(setup, set_file_path):
"""Test the upload method."""
setup.upload(set_file_path[0] + set_file_path[1], set_file_path[1])
file_exists = False
file_list = os.popen("osf ls")
# file_list = os.popen("osf ls")
file_list = os.popen("/usr/share/miniconda/envs/ioSPI/bin/osf ls")
line = file_list.readline()
while line:
file_exists = set_file_path[1] == line.split("/")[1].strip()
Expand Down Expand Up @@ -102,7 +103,8 @@ def test_remove_valid(setup, set_file_path):
"""Test the remove method."""
setup.remove(set_file_path[1])
file_exists = False
file_list = os.popen("osf ls")
# file_list = os.popen("osf ls")
file_list = os.popen("/usr/share/miniconda/envs/ioSPI/bin/osf ls")
line = file_list.readline()
while line:
file_exists = set_file_path[1] == line.split("/")[1].strip()
Expand Down

0 comments on commit 4be65f0

Please sign in to comment.