Skip to content

Commit

Permalink
Remove pylint disable comments from tests
Browse files Browse the repository at this point in the history
Now that we're using Ruff, these don't apply anyways.
  • Loading branch information
ian-noaa committed Dec 21, 2023
1 parent fb11d22 commit f6fb395
Show file tree
Hide file tree
Showing 16 changed files with 132 additions and 149 deletions.
1 change: 0 additions & 1 deletion tests/vxingest/builder_common/test_bc_builder_utilities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=missing-module-docstring
import pytest
from vxingest.builder_common.builder_utilities import (
convert_to_iso,
Expand Down
14 changes: 6 additions & 8 deletions tests/vxingest/builder_common/test_unit_queries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=missing-module-docstring
import os
from datetime import timedelta
from pathlib import Path
Expand All @@ -13,10 +12,9 @@ def connect_cb():
"""
create a couchbase connection and maintain the collection and cluster objects.
"""
# noinspection PyBroadException
try:
try:
cb_connection # pylint: disable=used-before-assignment
cb_connection
except NameError:
credentials_file = os.environ["CREDENTIALS"]
assert (
Expand Down Expand Up @@ -49,7 +47,7 @@ def connect_cb():
.collection(cb_connection["collection"])
)
return cb_connection
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"test_unit_queries Exception failure connecting: {_e}"


Expand All @@ -72,7 +70,7 @@ def test_stations_fcst_valid_epoch(request):
assert (
elapsed_time < _expected_time
), f"{_name}: elasped_time greater than {_expected_time} {elapsed_time}"
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"{_name} Exception failure: {_e}"


Expand All @@ -95,7 +93,7 @@ def test_stations_get_file_list_grib2(request):
assert (
elapsed_time < _expected_time
), f"{_name}: elasped_time greater than {_expected_time} {elapsed_time}"
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"{_name} Exception failure: {_e}"


Expand All @@ -118,7 +116,7 @@ def test_stations_get_file_list_netcdf(request):
assert (
elapsed_time < _expected_time
), f"{_name}: elasped_time greater than {_expected_time} {elapsed_time}"
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"{_name} Exception failure: {_e}"


Expand All @@ -139,5 +137,5 @@ def test_metar_count(request):
assert (
elapsed_time < _expected_time
), f"{_name}: elasped_time greater than {_expected_time} {elapsed_time}"
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"{_name} Exception failure: {_e}"
57 changes: 28 additions & 29 deletions tests/vxingest/ctc_to_cb/test_int_metar_ctc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=too-many-lines
"""
test for VxIngest CTC builders
"""
Expand Down Expand Up @@ -82,7 +81,7 @@ def test_check_fcst_valid_epoch_fcst_valid_iso():
fve == epoch_time
), "fcstValidEpoch and fcstValidIso are not the same time"
assert (fve % 3600) == 0, "fcstValidEpoch is not at top of hour"
except Exception as _e: # pylint: disable=broad-except, disable=broad-except
except Exception as _e:
assert False, f"TestGsdIngestManager.test_check_fcstValidEpoch_fcstValidIso Exception failure: {_e}"


Expand Down Expand Up @@ -148,7 +147,7 @@ def test_get_stations_geo_search():
)
for row in result:
# use the builder geosearch to get the station list - just use current epoch
stations = sorted( # pylint: disable=redefined-outer-name
stations = sorted(
# builder.get_stations_for_region_by_geosearch(row["name"],round(time.time()))
builder.get_stations_for_region_by_sort(row["name"], round(time.time()))
)
Expand All @@ -173,11 +172,11 @@ def test_get_stations_geo_search():
assert (
len(stations_difference) < 1000
), "difference between expected and actual greater than 100"
except Exception as _e: # pylint: disable=broad-except
except Exception as _e:
assert False, f"TestGsdIngestManager Exception failure: {_e}"


def calculate_cb_ctc( # pylint: disable=dangerous-default-value,missing-function-docstring
def calculate_cb_ctc(
epoch,
fcst_len,
threshold,
Expand All @@ -187,8 +186,8 @@ def calculate_cb_ctc( # pylint: disable=dangerous-default-value,missing-functio
doc_sub_type,
reject_stations=[],
):
global cb_model_obs_data # pylint: disable=global-statement
global stations # pylint: disable=global-statement
global cb_model_obs_data
global stations

credentials_file = os.environ["CREDENTIALS"]
assert Path(credentials_file).is_file(), "credentials_file Does not exist"
Expand Down Expand Up @@ -230,20 +229,20 @@ def calculate_cb_ctc( # pylint: disable=dangerous-default-value,missing-functio
builder.get_stations_for_region_by_sort(region, epoch)
)
obs_id = f"DD:V01:{subset}:obs:{epoch}"
stations = sorted( # pylint: disable=redefined-outer-name
stations = sorted(
[station for station in legacy_stations if station not in reject_stations]
)
model_id = f"DD:V01:{subset}:{model}:{epoch}:{fcst_len}"
print("cb_ctc model_id:", model_id, " obs_id:", obs_id)
try:
full_model_data = load_spec["collection"].get(model_id).content_as[dict]
except: # pylint: disable=bare-except
except:
time.sleep(0.25)
full_model_data = load_spec["collection"].get(model_id).content_as[dict]
cb_model_obs_data = [] # pylint: disable=redefined-outer-name
cb_model_obs_data = []
try:
full_obs_data = load_spec["collection"].get(obs_id).content_as[dict]
except: # pylint: disable=bare-except
except:
time.sleep(0.25)
full_obs_data = load_spec["collection"].get(obs_id).content_as[dict]
for station in stations:
Expand Down Expand Up @@ -299,7 +298,7 @@ def calculate_cb_ctc( # pylint: disable=dangerous-default-value,missing-functio
return ctc


def test_ctc_builder_ceiling_hrrr_ops_all_hrrr(): # pylint: disable=too-many-locals
def test_ctc_builder_ceiling_hrrr_ops_all_hrrr():
"""
This test verifies that data is returned for each fcstLen and each threshold.
It can be used to debug the builder by putting a specific epoch for first_epoch.
Expand All @@ -309,9 +308,9 @@ def test_ctc_builder_ceiling_hrrr_ops_all_hrrr(): # pylint: disable=too-many-lo
It calculates the CTC using couchbase data for input.
Then the couchbase CTC fcstValidEpochs are compared and asserted against the derived CTC.
"""
# noinspection PyBroadException
global cb_model_obs_data # pylint: disable=global-variable-not-assigned
global stations # pylint: disable=global-variable-not-assigned

global cb_model_obs_data
global stations

try:
credentials_file = os.environ["CREDENTIALS"]
Expand Down Expand Up @@ -371,7 +370,7 @@ def test_ctc_builder_ceiling_hrrr_ops_all_hrrr(): # pylint: disable=too-many-lo
for _elem in docs:
fcst_lens.append(_elem["fcstLen"])
output_file.close()
except Exception as _e: # pylint: disable=broad-except
except Exception as _e:
assert False, f"TestCTCBuilderV01 Exception failure opening output: {_e}"
for _i in fcst_lens:
_elem = None
Expand All @@ -396,11 +395,11 @@ def test_ctc_builder_ceiling_hrrr_ops_all_hrrr(): # pylint: disable=too-many-lo
if cb_ctc is None:
print(f"cb_ctc is None for threshold {str(_t)}- contunuing")
continue
except Exception as _e: # pylint: disable=broad-except
except Exception as _e:
assert False, f"TestCTCBuilderV01 Exception failure: {_e}"


def test_ctc_builder_visibility_hrrr_ops_all_hrrr(): # pylint: disable=too-many-locals
def test_ctc_builder_visibility_hrrr_ops_all_hrrr():
"""
This test verifies that data is returned for each fcstLen and each threshold.
It can be used to debug the builder by putting a specific epoch for first_epoch.
Expand All @@ -410,9 +409,9 @@ def test_ctc_builder_visibility_hrrr_ops_all_hrrr(): # pylint: disable=too-many
It calculates the CTC using couchbase data for input.
Then the couchbase CTC fcstValidEpochs are compared and asserted against the derived CTC.
"""
# noinspection PyBroadException
global cb_model_obs_data # pylint: disable=global-variable-not-assigned
global stations # pylint: disable=global-variable-not-assigned

global cb_model_obs_data
global stations

try:
credentials_file = os.environ["CREDENTIALS"]
Expand Down Expand Up @@ -473,7 +472,7 @@ def test_ctc_builder_visibility_hrrr_ops_all_hrrr(): # pylint: disable=too-many
for _elem in docs:
fcst_lens.append(_elem["fcstLen"])
output_file.close()
except Exception as _e: # pylint: disable=broad-except
except Exception as _e:
assert False, f"TestCTCBuilderV01 Exception failure opening output: {_e}"
for _i in fcst_lens:
_elem = None
Expand All @@ -498,12 +497,12 @@ def test_ctc_builder_visibility_hrrr_ops_all_hrrr(): # pylint: disable=too-many
if cb_ctc is None:
print(f"cb_ctc is None for threshold {str(_threshold)}- contunuing")
continue
except Exception as _e: # pylint: disable=broad-except
except Exception as _e:
assert False, f"TestCTCBuilderV01 Exception failure: {_e}"


def test_ctc_ceiling_data_hrrr_ops_all_hrrr(): # pylint: disable=too-many-locals
# noinspection PyBroadException
def test_ctc_ceiling_data_hrrr_ops_all_hrrr():

"""
This test is a comprehensive test of the ctcBuilder data. It will retrieve CTC documents
for a specific fcstValidEpoch from couchbase and calculate the CTC's for the same fcstValidEpoch.
Expand Down Expand Up @@ -635,13 +634,13 @@ def test_ctc_ceiling_data_hrrr_ops_all_hrrr(): # pylint: disable=too-many-local
and fstLen: {_ctc['fcst_len']}
and threshold: {_threshold}
the derived CTC {field}: {_ctc_value} and caclulated CTC {field}: {_cb_ctc_value} values do not match"""
except Exception as _e: # pylint: disable=broad-except
except Exception as _e:
assert False, f"TestCTCBuilderV01 Exception failure: {_e}"
return


def test_ctc_visibiltiy_data_hrrr_ops_all_hrrr(): # pylint: disable=too-many-locals
# noinspection PyBroadException
def test_ctc_visibiltiy_data_hrrr_ops_all_hrrr():

"""
This test is a comprehensive test of the ctcBuilder data. It will retrieve CTC documents
for a specific fcstValidEpoch from couchbase and calculate the CTC's for the same fcstValidEpoch.
Expand Down Expand Up @@ -772,6 +771,6 @@ def test_ctc_visibiltiy_data_hrrr_ops_all_hrrr(): # pylint: disable=too-many-lo
and fstLen: {_ctc['fcst_len']}
and threshold: {_threshold}
the derived CTC {field}: {_ctc_value} and caclulated CTC {field}: {_cb_ctc_value} values do not match"""
except Exception as _e: # pylint: disable=broad-except
except Exception as _e:
assert False, f"TestCTCBuilderV01 Exception failure: {_e}"
return
11 changes: 5 additions & 6 deletions tests/vxingest/ctc_to_cb/test_unit_metar_ctc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=missing-module-docstring
import os
from multiprocessing import JoinableQueue

Expand Down Expand Up @@ -32,7 +31,7 @@ def setup_ingest():
vx_ingest_manager is not None
), "vx_ingest_manager is None and should not be"
return _vx_ingest, vx_ingest_manager
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"test_credentials_and_load_spec Exception failure: {_e}"


Expand All @@ -47,7 +46,7 @@ def test_cb_connect_disconnect():
assert vx_ingest is not None, "vx_ingest is None"
assert local_time is not None, "local_time from CB should not be None"
vx_ingest_manager.close_cb()
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"test_cb_connect_disconnect Exception failure: {_e}"
finally:
if vx_ingest_manager is not None:
Expand All @@ -61,7 +60,7 @@ def test_credentials_and_load_spec():
vx_ingest, vx_ingest_manager = setup_ingest()
assert vx_ingest.load_spec["cb_connection"]["user"] == "avid"
vx_ingest_manager.close_cb()
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"test_credentials_and_load_spec Exception failure: {_e}"
finally:
if vx_ingest_manager is not None:
Expand All @@ -78,7 +77,7 @@ def test_write_load_job_to_files():
vx_ingest.load_spec["load_job_doc"] = {"test": "a line of text"}
vx_ingest.write_load_job_to_files()
os.remove("/tmp/test_id.json")
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"test_write_load_job_to_files Exception failure: {_e}"
finally:
if vx_ingest_manager is not None:
Expand All @@ -99,7 +98,7 @@ def test_build_load_job_doc():
].startswith(
"LJ:METAR:vxingest.ctc_to_cb.run_ingest_threads:VXIngest"
), f"load_job ID is wrong: {ljd['id']} does not start with 'LJ:METAR:ctc_to_cb.run_ingest_threads:VXIngest'"
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"test_build_load_job_doc Exception failure: {_e}"
finally:
if vx_ingest_manager is not None:
Expand Down
19 changes: 9 additions & 10 deletions tests/vxingest/ctc_to_cb/test_unit_queries_ctc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=missing-module-docstring
import os
from datetime import timedelta
from pathlib import Path
Expand All @@ -13,10 +12,10 @@ def connect_cb():
"""
create a couchbase connection and maintain the collection and cluster objects.
"""
# noinspection PyBroadException

try:
try:
cb_connection # is it defined pylint:disable=used-before-assignment
cb_connection
except NameError:
credentials_file = os.environ["CREDENTIALS"]
assert (
Expand Down Expand Up @@ -49,7 +48,7 @@ def connect_cb():
.collection(cb_connection["collection"])
)
return cb_connection
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"test_unit_queries Exception failure connecting: {_e}"


Expand All @@ -72,7 +71,7 @@ def test_epoch_fcstlen_model(request):
assert (
elapsed_time < _expected_time
), f"{_name}: elasped_time greater than {_expected_time} {elapsed_time}"
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"{_name} Exception failure: {_e}"


Expand All @@ -93,7 +92,7 @@ def test_epoch_fcstlen_obs(request):
assert (
elapsed_time < _expected_time
), f"{_name}: elasped_time greater than {_expected_time} {elapsed_time}"
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"{_name} Exception failure: {_e}"


Expand All @@ -116,7 +115,7 @@ def test_forecast_valid_epoch(request):
assert (
elapsed_time < _expected_time
), f"{_name}: elasped_time greater than {_expected_time} {elapsed_time}"
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"{_name} Exception failure: {_e}"


Expand All @@ -139,7 +138,7 @@ def test_get_region_lat_lon(request):
assert (
elapsed_time < _expected_time
), f"{_name}: elasped_time greater than {_expected_time} {elapsed_time}"
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"{_name} Exception failure: {_e}"


Expand All @@ -160,7 +159,7 @@ def test_get_stations(request):
assert (
elapsed_time < _expected_time
), f"{_name}: elasped_time greater than {_expected_time} {elapsed_time}"
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"{_name} Exception failure: {_e}"


Expand All @@ -183,7 +182,7 @@ def test_get_threshold_descriptions(request):
assert (
elapsed_time < _expected_time
), f"{_name}: elasped_time greater than {_expected_time} {elapsed_time}"
except Exception as _e: # pylint:disable=broad-except
except Exception as _e:
assert False, f"{_name} Exception failure: {_e}"


Expand Down
Loading

0 comments on commit f6fb395

Please sign in to comment.