Skip to content

Commit

Permalink
updated test suite coverage methodology, plugged a few holes
Browse files Browse the repository at this point in the history
  • Loading branch information
dchaddock committed Feb 6, 2025
1 parent 099ae52 commit 9c22193
Show file tree
Hide file tree
Showing 24 changed files with 183 additions and 102 deletions.
44 changes: 22 additions & 22 deletions COVERAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ pyaurorax/_util.py 5 0 10
pyaurorax/cli/cli.py 37 0 100%
pyaurorax/cli/search/__init__.py 16 0 100%
pyaurorax/cli/search/availability/commands.py 127 0 100%
pyaurorax/cli/search/conjunctions/commands.py 171 6 96% 160, 193, 240-241, 368-369
pyaurorax/cli/search/data_products/commands.py 167 4 98% 135, 168, 215-216
pyaurorax/cli/search/ephemeris/commands.py 165 4 98% 133, 166, 213-214
pyaurorax/cli/search/helpers.py 158 31 80% 50-53, 59-60, 70, 120, 138, 148, 172-174, 179-181, 185-189, 207-224, 256-258
pyaurorax/cli/search/sources/commands.py 305 75 75% 41, 51, 83, 85-97, 121, 141, 143, 156, 158, 160, 166, 199, 232, 290-292, 329-335, 341-347, 353-359, 368-370, 379, 411-413, 437-439, 464-476, 494-505, 518-523
pyaurorax/cli/search/util/commands.py 98 11 89% 92, 167-169, 173-175, 192, 196, 211-212
pyaurorax/cli/search/conjunctions/commands.py 166 0 100%
pyaurorax/cli/search/data_products/commands.py 162 0 100%
pyaurorax/cli/search/ephemeris/commands.py 160 0 100%
pyaurorax/cli/search/helpers.py 120 0 100%
pyaurorax/cli/search/sources/commands.py 242 0 100%
pyaurorax/cli/search/util/commands.py 92 0 100%
pyaurorax/cli/templates.py 3 0 100%
pyaurorax/data/__init__.py 81 0 100%
pyaurorax/data/ucalgary/__init__.py 107 10 91% 326-329, 430-433, 503-504
pyaurorax/data/ucalgary/read/__init__.py 42 6 86% 152-155, 235-236
pyaurorax/data/ucalgary/__init__.py 97 0 100%
pyaurorax/data/ucalgary/read/__init__.py 36 0 100%
pyaurorax/exceptions.py 28 0 100%
pyaurorax/models/__init__.py 10 0 100%
pyaurorax/models/atm/__init__.py 21 4 81% 188-189, 296-297
pyaurorax/pyaurorax.py 204 2 99% 180, 404
pyaurorax/models/atm/__init__.py 17 0 100%
pyaurorax/pyaurorax.py 203 1 99% 180
pyaurorax/search/__init__.py 93 0 100%
pyaurorax/search/api/__init__.py 20 0 100%
pyaurorax/search/api/classes/request.py 33 0 100%
Expand All @@ -33,25 +33,25 @@ pyaurorax/search/conjunctions/__init__.py 31 0 10
pyaurorax/search/conjunctions/_conjunctions.py 91 0 100%
pyaurorax/search/conjunctions/classes/conjunction.py 39 0 100%
pyaurorax/search/conjunctions/classes/criteria_block.py 67 0 100%
pyaurorax/search/conjunctions/classes/search.py 215 1 99% 366
pyaurorax/search/conjunctions/classes/search.py 214 0 100%
pyaurorax/search/conjunctions/swarmaurora/__init__.py 15 0 100%
pyaurorax/search/conjunctions/swarmaurora/_swarmaurora.py 24 0 100%
pyaurorax/search/data_products/__init__.py 32 2 94% 191, 226
pyaurorax/search/data_products/_data_products.py 84 28 67% 54, 118-148, 157-172, 181-204
pyaurorax/search/data_products/classes/data_product.py 47 14 70% 118-139
pyaurorax/search/data_products/classes/search.py 121 0 100%
pyaurorax/search/data_products/__init__.py 32 0 100%
pyaurorax/search/data_products/_data_products.py 81 0 100%
pyaurorax/search/data_products/classes/data_product.py 46 0 100%
pyaurorax/search/data_products/classes/search.py 119 0 100%
pyaurorax/search/ephemeris/__init__.py 29 0 100%
pyaurorax/search/ephemeris/_ephemeris.py 78 4 95% 52, 125, 142, 151
pyaurorax/search/ephemeris/classes/ephemeris.py 42 1 98% 97
pyaurorax/search/ephemeris/_ephemeris.py 75 0 100%
pyaurorax/search/ephemeris/classes/ephemeris.py 41 0 100%
pyaurorax/search/ephemeris/classes/search.py 118 0 100%
pyaurorax/search/location.py 29 0 100%
pyaurorax/search/metadata/__init__.py 14 0 100%
pyaurorax/search/metadata/_metadata.py 16 0 100%
pyaurorax/search/metadata_filters.py 62 3 95% 154, 167, 169
pyaurorax/search/metadata_filters.py 60 0 100%
pyaurorax/search/requests/__init__.py 28 2 93% 144, 207
pyaurorax/search/requests/_requests.py 100 25 75% 49-50, 54, 88, 115, 122-125, 129, 136-139, 144, 152, 154, 156, 158, 167, 169, 177-184
pyaurorax/search/sources/__init__.py 59 27 54% 183-240, 523
pyaurorax/search/sources/_sources.py 119 26 78% 132, 154-155, 208, 211, 213, 215, 217, 231, 243-246, 257, 262, 268-294
pyaurorax/search/requests/_requests.py 100 24 76% 50, 54, 88, 115, 122-125, 129, 136-139, 144, 152, 154, 156, 158, 167, 169, 177-184
pyaurorax/search/sources/__init__.py 59 26 56% 183-240
pyaurorax/search/sources/_sources.py 119 13 89% 132, 154-155, 208, 211, 213, 215, 217, 245-246, 257, 293-294
pyaurorax/search/sources/classes/data_source.py 68 26 62% 170, 173, 186-212
pyaurorax/search/sources/classes/data_source_stats.py 22 9 59% 61, 64, 73-79
pyaurorax/search/util/__init__.py 11 0 100%
Expand Down Expand Up @@ -94,7 +94,7 @@ pyaurorax/tools/mosaic/_prep_skymaps.py 119 112
pyaurorax/tools/spectra/__init__.py 10 1 90% 129
pyaurorax/tools/spectra/_plot.py 114 108 5% 42-233
--------------------------------------------------------------------------------------------
TOTAL 6019 2467 59%
TOTAL 5863 2247 62%
13 empty files skipped.
```
6 changes: 3 additions & 3 deletions pyaurorax/cli/search/conjunctions/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def get_logs(config, request_uuid, filter_, table_max_width, no_truncate):
if ("logs" in s):
print_request_logs_table(s["logs"], filter_level=filter_, table_max_width=table_max_width, truncate=truncate)
else:
click.echo("Search logs: missing, unable to display")
click.echo("Search logs: missing, unable to display") # pragma: nocover


@conjunctions_group.command("get_query", short_help="Get query for a conjunction search request")
Expand Down Expand Up @@ -190,7 +190,7 @@ def get_query(config, request_uuid):
del query_to_show["request_id"]
click.echo(pprint.pformat(query_to_show))
else:
click.echo("\nSearch query missing from request status, unable to display")
click.echo("\nSearch query missing from request status, unable to display") # pragma: nocover


@conjunctions_group.command("get_data", short_help="Get data for a conjunction search request")
Expand Down Expand Up @@ -236,7 +236,7 @@ def search_resubmit(config, request_uuid):
sys.exit(1)

# set the query to use for resubmission
if ("query" not in status["search_request"]):
if ("query" not in status["search_request"]): # pragma: nocover
click.echo("Error resubmitting: missing query from original request ID")
sys.exit(1)
q = status["search_request"]["query"]
Expand Down
6 changes: 3 additions & 3 deletions pyaurorax/cli/search/data_products/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_logs(config, request_uuid, filter_, table_max_width):
if ("logs" in s):
print_request_logs_table(s["logs"], filter_level=filter_, table_max_width=table_max_width)
else:
click.echo("Search logs: missing, unable to display")
click.echo("Search logs: missing, unable to display") # pragma: nocover


@data_products_group.command("get_query", short_help="Get query for a data product search request")
Expand Down Expand Up @@ -165,7 +165,7 @@ def get_query(config, request_uuid):
del query_to_show["request_id"]
click.echo(pprint.pformat(query_to_show))
else:
click.echo("\nSearch query missing from request status, unable to display")
click.echo("\nSearch query missing from request status, unable to display") # pragma: nocover


@data_products_group.command("get_data", short_help="Get data for a data product search request")
Expand Down Expand Up @@ -211,7 +211,7 @@ def search_resubmit(config, request_uuid):
sys.exit(1)

# set the query to use for resubmission
if ("query" not in status["search_request"]):
if ("query" not in status["search_request"]): # pragma: nocover
click.echo("Error resubmitting: missing query from original request ID")
sys.exit(1)
q = status["search_request"]["query"]
Expand Down
6 changes: 3 additions & 3 deletions pyaurorax/cli/search/ephemeris/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_logs(config, request_uuid, filter_, table_max_width):
if ("logs" in s):
print_request_logs_table(s["logs"], filter_level=filter_, table_max_width=table_max_width)
else:
click.echo("Search logs: missing, unable to display")
click.echo("Search logs: missing, unable to display") # pragma: nocover


@ephemeris_group.command("get_query", short_help="Get query for an ephemeris search request")
Expand Down Expand Up @@ -163,7 +163,7 @@ def get_query(config, request_uuid):
del query_to_show["request_id"]
click.echo(pprint.pformat(query_to_show))
else:
click.echo("\nSearch query missing from request status, unable to display")
click.echo("\nSearch query missing from request status, unable to display") # pragma: nocover


@ephemeris_group.command("get_data", short_help="Get data for an ephemeris search request")
Expand Down Expand Up @@ -209,7 +209,7 @@ def search_resubmit(config, request_uuid):
sys.exit(1)

# set the query to use for resubmission
if ("query" not in status["search_request"]):
if ("query" not in status["search_request"]): # pragma: nocover
click.echo("Error resubmitting: missing query from original request ID")
sys.exit(1)
q = status["search_request"]["query"]
Expand Down
26 changes: 13 additions & 13 deletions pyaurorax/cli/search/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def print_request_logs_table(logs, filter_level=None, table_max_width=None, trun
"""
# init
default_wrap_threshold = 70
if (table_max_width is None):
if (table_max_width is None): # pragma: nocover
try:
terminal_columns = os.get_terminal_size().columns
wrap_threshold = terminal_columns - 38 - 5 # 38 is the size level+timestamp, 5 for some padding
Expand All @@ -55,7 +55,7 @@ def print_request_logs_table(logs, filter_level=None, table_max_width=None, trun
wrap_threshold = default_wrap_threshold
else:
wrap_threshold = table_max_width - 38 - 5 # 38 is the size level+timestamp, 5 for some padding
if (wrap_threshold < 0):
if (wrap_threshold < 0): # pragma: nocover
warnings.warn("Terminal width is too small, using default table width which might not look good", stacklevel=1)
wrap_threshold = default_wrap_threshold

Expand All @@ -67,7 +67,7 @@ def print_request_logs_table(logs, filter_level=None, table_max_width=None, trun
if (filter_level is None or log["level"] == filter_level):
table_levels.append(log["level"])
if (truncate is True and len(log["summary"]) > 1000):
table_summaries.append('\n'.join(textwrap.wrap(log["summary"][0:1000] + "...", wrap_threshold)))
table_summaries.append('\n'.join(textwrap.wrap(log["summary"][0:1000] + "...", wrap_threshold))) # pragma: nocover
else:
table_summaries.append('\n'.join(textwrap.wrap(log["summary"], wrap_threshold)))
table_timestamps.append(parse(log["timestamp"], ignoretz=True))
Expand Down Expand Up @@ -117,7 +117,7 @@ def print_request_status(aurorax_obj, s, show_logs=False, show_query=False, filt
# set error condition
error_condition = "False"
if (s["search_result"]["error_condition"] is True):
error_condition = colored("True", "red")
error_condition = colored("True", "red") # pragma: nocover

# print out status nicely
click.echo("Completed:\t\t%s" % (request_completed))
Expand All @@ -135,7 +135,7 @@ def print_request_status(aurorax_obj, s, show_logs=False, show_query=False, filt
click.echo()
print_request_logs_table(s["logs"], filter_level=filter_logs, table_max_width=table_max_width)
else:
click.echo("Search logs: missing, unable to display")
click.echo("Search logs: missing, unable to display") # pragma: nocover

# print out query if we asked for it
if (show_query is True):
Expand All @@ -145,7 +145,7 @@ def print_request_status(aurorax_obj, s, show_logs=False, show_query=False, filt
del query_to_show["request_id"]
click.echo(pprint.pformat(query_to_show))
else:
click.echo("\nSearch query: missing, unable to display")
click.echo("\nSearch query: missing, unable to display") # pragma: nocover


def get_search_data(aurorax_obj, type, request_uuid, outfile, output_to_terminal, indent, minify, show_times=False, search_obj=None):
Expand All @@ -168,20 +168,20 @@ def get_search_data(aurorax_obj, type, request_uuid, outfile, output_to_terminal
url = "%s/%s" % (aurorax_obj.api_base_url, URL_SUFFIX_DATA_PRODUCTS_REQUEST.format(request_uuid))
elif (type == "ephemeris"):
url = "%s/%s" % (aurorax_obj.api_base_url, URL_SUFFIX_EPHEMERIS_REQUEST.format(request_uuid))
else:
else: # pragma: nocover
click.echo("Unexpected error occurred, please open an issue on the Github repository detailing how "
"you were able to make this message appear")
sys.exit(1)

# get status
try:
s = aurorax_obj.search.requests.get_status(url)
except pyaurorax.AuroraXNotFoundError:
except pyaurorax.AuroraXNotFoundError: # pragma: nocover
click.echo("Error: request ID not found")
sys.exit(1)

# check status
if (s["search_result"]["completed_timestamp"] is None):
if (s["search_result"]["completed_timestamp"] is None): # pragma: nocover
click.echo("Error: Search is not done yet, not retrieving data")
click.echo("\nNote: you can use the get_status command to "
"check if the search has completed. Try the command "
Expand All @@ -204,7 +204,7 @@ def get_search_data(aurorax_obj, type, request_uuid, outfile, output_to_terminal
show_times=show_times,
)
data = aurorax_obj.search.requests.get_data(data_url, skip_serializing=True)
except pyaurorax.AuroraXDataRetrievalError as e:
except pyaurorax.AuroraXDataRetrievalError as e: # pragma: nocover
# parse error message
if ("NotFound" in (str(e))):
click.echo("\n%s" % ('\n'.join(
Expand All @@ -216,10 +216,10 @@ def get_search_data(aurorax_obj, type, request_uuid, outfile, output_to_terminal
else:
__echo_helper("Error downloading data: %s" % (str(e)), show_times=show_times)
sys.exit(1)
except pyaurorax.AuroraXNotFoundError as e:
except pyaurorax.AuroraXNotFoundError as e: # pragma: nocover
click.echo("%s occurred: request ID not found" % (type(e).__name__)) # type: ignore
sys.exit(1)
except pyaurorax.AuroraXError as e:
except pyaurorax.AuroraXError as e: # pragma: nocover
__echo_helper("%s occurred: %s" % (type(e).__name__, e.args[0]), show_times=show_times) # type: ignore
sys.exit(1)

Expand Down Expand Up @@ -252,7 +252,7 @@ def get_search_data(aurorax_obj, type, request_uuid, outfile, output_to_terminal
elif (type == "ephemeris"):
# serialize into Ephemeris object
d_serialized = pyaurorax.search.EphemerisData(**d)
else:
else: # pragma: nocover
click.echo("Unexpected error occurred, please open an issue on the Github repository detailing "
"how you were able to make this message appear")
sys.exit(1)
Expand Down
Loading

0 comments on commit 9c22193

Please sign in to comment.