Skip to content

Commit

Permalink
Validating and testing new argument
Browse files Browse the repository at this point in the history
  • Loading branch information
astronomerritt committed May 22, 2024
1 parent f97608e commit 25b53f0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
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."
)

0 comments on commit 25b53f0

Please sign in to comment.