Skip to content

Commit

Permalink
run black
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-a-a committed Nov 1, 2024
1 parent 0e10833 commit faf0d10
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
22 changes: 12 additions & 10 deletions watertap/tools/oli_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, credential_manager, interactive_mode=True, debug_level="INFO"
_logger.setLevel(logging.INFO)
else:
_logger.setLevel(logging.DEBUG)

# TODO: unknown bug where only "liquid1" phase is found in Flash analysis
self.valid_phases = ["liquid1", "vapor", "solid", "liquid2"]

Expand All @@ -105,7 +105,9 @@ def __enter__(self):
# return False if no exceptions raised
def __exit__(self, exc_type=None, exc_value=None, traceback=None):
# delete all .dbs files created during session
_logger.info(f"Exiting: deleting {len(self.session_dbs_files)} remaining DBS files created during the session that were not marked by keep_file=True.")
_logger.info(
f"Exiting: deleting {len(self.session_dbs_files)} remaining DBS files created during the session that were not marked by keep_file=True."
)
self.dbs_file_cleanup(self.session_dbs_files)
return False

Expand Down Expand Up @@ -292,15 +294,15 @@ def dbs_file_cleanup(self, dbs_file_ids=None):
"""

if dbs_file_ids is None:
_logger.info("No DBS file IDs were provided to the dbs_file_cleanup method. Checking user's cloud account for DBS file IDs.")
_logger.info(

Check warning on line 297 in watertap/tools/oli_api/client.py

View check run for this annotation

Codecov / codecov/patch

watertap/tools/oli_api/client.py#L297

Added line #L297 was not covered by tests
"No DBS file IDs were provided to the dbs_file_cleanup method. Checking user's cloud account for DBS file IDs."
)
dbs_file_ids = self.get_user_dbs_file_ids()
if not len(dbs_file_ids):
_logger.info("No DBS file IDs were found on the user's cloud account.")
return

Check warning on line 303 in watertap/tools/oli_api/client.py

View check run for this annotation

Codecov / codecov/patch

watertap/tools/oli_api/client.py#L301-L303

Added lines #L301 - L303 were not covered by tests

r = self._prompt(
f"WaterTAP will delete {len(dbs_file_ids)} DBS files. ", "y"
)
r = self._prompt(f"WaterTAP will delete {len(dbs_file_ids)} DBS files. ", "y")
if (r.lower() == "y") or (r == ""):
for dbs_file_id in dbs_file_ids:
_logger.info(f"Deleting {dbs_file_id} ...")
Expand All @@ -319,9 +321,7 @@ def dbs_file_cleanup(self, dbs_file_ids=None):
f"File {dbs_file_id} deleted and removed from session_dbs_files list."
)
else:
_logger.info(
f"File {dbs_file_id} deleted."
)
_logger.info(f"File {dbs_file_id} deleted.")

Check warning on line 324 in watertap/tools/oli_api/client.py

View check run for this annotation

Codecov / codecov/patch

watertap/tools/oli_api/client.py#L324

Added line #L324 was not covered by tests

def get_corrosion_contact_surfaces(self, dbs_file_id):
"""
Expand Down Expand Up @@ -496,7 +496,9 @@ def _request_status_test(req, target_keys):
return req_json
else:
return req_json
raise RuntimeError(f"Failure in {func_name}. Response: {req_json}. Status Code: {req.status_code}.")
raise RuntimeError(

Check warning on line 499 in watertap/tools/oli_api/client.py

View check run for this annotation

Codecov / codecov/patch

watertap/tools/oli_api/client.py#L499

Added line #L499 was not covered by tests
f"Failure in {func_name}. Response: {req_json}. Status Code: {req.status_code}."
)


def _poll_result_link(result_link, headers, max_request, poll_time):
Expand Down
12 changes: 10 additions & 2 deletions watertap/tools/oli_api/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,23 @@
def test_dbs_file_available_for_testing(local_dbs_file: Path):
assert local_dbs_file.is_file()


@pytest.mark.unit
def test_generate_dbs_file(oliapi_instance: OLIApi, local_dbs_file: Path, source_water: dict):
def test_generate_dbs_file(
oliapi_instance: OLIApi, local_dbs_file: Path, source_water: dict
):
dbs_file_id = oliapi_instance.generate_dbs_file(source_water)
assert len(dbs_file_id) > 0


@pytest.mark.unit
def test_upload_dbs_file(oliapi_instance: OLIApi, local_dbs_file: Path, source_water: dict):
def test_upload_dbs_file(
oliapi_instance: OLIApi, local_dbs_file: Path, source_water: dict
):
dbs_file_id = oliapi_instance.upload_dbs_file(str(local_dbs_file))
assert len(dbs_file_id) > 0


@pytest.mark.unit
def test_dbs_file_cleanup(oliapi_instance: OLIApi, local_dbs_file: Path):
# This test checks both the upload_dbs_file method and dbs_file_cleanup method
Expand All @@ -86,6 +93,7 @@ def test_valid_phases(oliapi_instance: OLIApi):
for v in oliapi_instance.valid_phases:
assert v in valid_phases


@pytest.mark.unit
def test_invalid_phases(oliapi_instance_with_invalid_phase: OLIApi):
oliapi_instance_with_invalid_phase

0 comments on commit faf0d10

Please sign in to comment.