Skip to content

Commit

Permalink
Issue #74: Update errors from ValueError to TypeError in datasets.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bongjinkoo committed May 13, 2022
1 parent 39344f7 commit f7e9e8f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions ioSPI/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def __init__(
storage: str = "osfstorage",
) -> None:
if username is None:
raise ValueError("username must be provided.")
raise TypeError("username must be provided.")
self.username = username

if token is None:
raise ValueError("token must be provided.")
raise TypeError("token must be provided.")
self.token = token

self.project_id = project_id
Expand Down Expand Up @@ -74,9 +74,9 @@ def download(self, remote_path: str, local_path: str):
E.g. 4v6x_randomrot_copy6_defocus3.0_yes_noise.txt
"""
if remote_path is None:
raise ValueError("remote_path must be provided.")
raise TypeError("remote_path must be provided.")
if local_path is None:
raise ValueError("local_path must be provided.")
raise TypeError("local_path must be provided.")

full_remote_path = self.storage + "/" + remote_path
print(f"Downloading {full_remote_path} to {local_path}...")
Expand All @@ -103,9 +103,9 @@ def upload(self, local_path: str, remote_path: str):
4v6x_randomrot_copy6_defocus3.0_yes_noise.txt
"""
if local_path is None:
raise ValueError("local_path must be provided.")
raise TypeError("local_path must be provided.")
if remote_path is None:
raise ValueError("remote_path must be provided.")
raise TypeError("remote_path must be provided.")

full_remote_path = self.storage + "/" + remote_path
print(f"Uploading {local_path} to {full_remote_path}...")
Expand All @@ -125,7 +125,7 @@ def remove(self, remote_path: str):
4v6x_randomrot_copy6_defocus3.0_yes_noise.txt
"""
if remote_path is None:
raise ValueError("remote_path must be provided.")
raise TypeError("remote_path must be provided.")

full_remote_path = self.storage + "/" + remote_path
print(f"Removing {full_remote_path} in the project...")
Expand Down
16 changes: 8 additions & 8 deletions tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def test_constructor_valid():

def test_constructor_invalid_because_no_username():
"""Test if an error is raised when no username is provided to the constructor."""
with pytest.raises(ValueError):
_ = datasets.OSFProject(token="token")
with pytest.raises(TypeError):
datasets.OSFProject(token="token")


def test_constructor_invalid_because_no_token():
"""Test if an error is raised when no token is provided to the constructor."""
with pytest.raises(ValueError):
with pytest.raises(TypeError):
datasets.OSFProject(username="username")


Expand All @@ -63,13 +63,13 @@ def test_upload_valid(setup, create_upload_file):

def test_upload_invalid_because_no_local_path(setup):
"""Test if an error is raised when no local_path is provided."""
with pytest.raises(ValueError):
with pytest.raises(TypeError):
setup.upload(remote_path="remote_path")


def test_upload_invalid_because_no_remote_path(setup):
"""Test if an error is raised when no remote_path is provided."""
with pytest.raises(ValueError):
with pytest.raises(TypeError):
setup.upload(local_path="local_path")


Expand All @@ -81,13 +81,13 @@ def test_download_valid(setup, create_upload_file):

def test_download_invalid_because_no_remote_path(setup):
"""Test if an error is raised when no remote_path is provided."""
with pytest.raises(ValueError):
with pytest.raises(TypeError):
setup.download(local_path="local_path")


def test_download_invalid_because_no_local_path(setup):
"""Test if an error is raised when no local_path is provided."""
with pytest.raises(ValueError):
with pytest.raises(TypeError):
setup.download(remote_path="remote_path")


Expand All @@ -104,5 +104,5 @@ def test_remove_valid(setup, create_upload_file):

def test_remove_invalid_because_no_remote_path(setup):
"""Test if an error is raised when no remote_path is provided."""
with pytest.raises(ValueError):
with pytest.raises(TypeError):
setup.remove()

0 comments on commit f7e9e8f

Please sign in to comment.