Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

136 Validating and testing new argument #141

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/adler/utilities/AdlerCLIArguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def validate_arguments(self):
if self.ssObjectId_list:
self._validate_ssObjectId_list()

if self.sql_filename:
self._validate_sql_filename()

def _validate_filter_list(self):
expected_filters = ["u", "g", "r", "i", "z", "y"]

Expand Down Expand Up @@ -93,3 +96,12 @@ def _validate_ssObjectId_list(self):
raise ValueError(
"The file supplied for the command-line argument --ssObjectId_list cannot be found."
)

def _validate_sql_filename(self):
self.sql_filename = os.path.abspath(self.sql_filename)

if not os.path.exists(self.sql_filename):
logging.error("The file supplied for the command-line argument --sql_filename cannot be found.")
raise ValueError(
"The file supplied for the command-line argument --sql_filename cannot be found."
)
26 changes: 23 additions & 3 deletions tests/adler/utilities/test_AdlerCLIArguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,35 @@ def test_AdlerCLIArguments_badlist():
"./fake_input/here.txt",
["g", "r", "i"],
[60000.0, 67300.0],
"./definitely_fake_folder/",
"./",
"output",
None,
"./",
)

with pytest.raises(ValueError) as bad_list_error:
bad_list_object = AdlerCLIArguments(bad_list_arguments)

assert (
bad_list_error.value.args[0]
== "The output path for the command-line argument --outpath cannot be found."
== "The file supplied for the command-line argument --ssObjectId_list cannot be found."
)


def test_AdlerCLIArguments_badsql():
bad_sql_arguments = args(
"666",
None,
["g", "r", "i"],
[60000.0, 67300.0],
"./",
"output",
"./dummy_database.db",
)

with pytest.raises(ValueError) as bad_sql_error:
bad_sql_object = AdlerCLIArguments(bad_sql_arguments)

assert (
bad_sql_error.value.args[0]
== "The file supplied for the command-line argument --sql_filename cannot be found."
)
Loading