Skip to content

Commit

Permalink
Add pragma(s) where no pytest coverage necessary
Browse files Browse the repository at this point in the history
The pytest(s) coverage and its reporting is not meant to cover all
paths. Add no-cover pragma directives to uncovered paths that may be
safely ignored by pytest reporting. Do so as the scope of these tests is
mainly integration and main coverage of client paths towards the server.

Ignore paths such as negative or corner (thus less likely) cases. Ignore
paths also that are either TODO code or manual cli printouts and cases.

The remaining uncovered lines are backlogged to be covered further, yet
through larger efforts. README has the pytest command showing the
report, which currently shows 80% coverage (round number a coincidence).

Some no-cover pragmas might be removed as some more paths end up being
covered, through potential pytest or code amends.

Signed-off-by: Marco Miller <[email protected]>
  • Loading branch information
marco-miller committed Sep 21, 2021
1 parent ae2047d commit 702bef9
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
12 changes: 6 additions & 6 deletions tsp/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, params):
if UUID_KEY in params:
self.UUID = params.get(UUID_KEY)
del params[UUID_KEY]
else:
else: # pragma: no cover
self.UUID = NA

'''
Expand All @@ -60,7 +60,7 @@ def __init__(self, params):
if NAME_KEY in params:
self.name = params.get(NAME_KEY)
del params[NAME_KEY]
else:
else: # pragma: no cover
self.name = NA

'''
Expand All @@ -69,7 +69,7 @@ def __init__(self, params):
if START_TIME_KEY in params:
self.start = params.get(START_TIME_KEY)
del params[START_TIME_KEY]
else:
else: # pragma: no cover
self.start = -1

'''
Expand All @@ -78,7 +78,7 @@ def __init__(self, params):
if END_TIME_KEY in params:
self.end = params.get(END_TIME_KEY)
del params[END_TIME_KEY]
else:
else: # pragma: no cover
self.end = -1

'''
Expand All @@ -87,7 +87,7 @@ def __init__(self, params):
if NB_EVENT_KEY in params:
self.number_of_events = params.get(NB_EVENT_KEY)
del params[NB_EVENT_KEY]
else:
else: # pragma: no cover
self.number_of_events = 0

'''
Expand All @@ -97,7 +97,7 @@ def __init__(self, params):
if INDEXING_STATUS_KEY in params:
self.indexin_status = params.get(INDEXING_STATUS_KEY)
del params[INDEXING_STATUS_KEY]
else:
else: # pragma: no cover
self.indexin_status = 0

'''
Expand Down
8 changes: 4 additions & 4 deletions tsp/output_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, params):
if ID_KEY in params:
self.id = params.get(ID_KEY)
del params[ID_KEY]
else:
else: # pragma: no cover
self.id = None

'''
Expand All @@ -60,7 +60,7 @@ def __init__(self, params):
if NAME_KEY in params:
self.name = params.get(NAME_KEY)
del params[NAME_KEY]
else:
else: # pragma: no cover
self.name = UNKOWN

'''
Expand All @@ -69,7 +69,7 @@ def __init__(self, params):
if DESCRIPTION_KEY in params:
self.description = params.get(DESCRIPTION_KEY)
del params[DESCRIPTION_KEY]
else:
else: # pragma: no cover
self.description = UNKOWN

'''
Expand All @@ -79,7 +79,7 @@ def __init__(self, params):
if TYPE_KEY in params:
self.type = params.get(TYPE_KEY)
del params[TYPE_KEY]
else:
else: # pragma: no cover
self.type = UNKOWN

'''
Expand Down
6 changes: 3 additions & 3 deletions tsp/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self, params, model_type):
self.model = EntryModel(params.get(MODEL_KEY), self.model_type)
elif self.model_type == ModelType.XY_TREE:
self.model = EntryModel(params.get(MODEL_KEY))
elif self.model_type == ModelType.STATES:
elif self.model_type == ModelType.STATES: # pragma: no cover
# TODO
print("not implemented")
elif self.model_type == ModelType.XY:
Expand All @@ -100,13 +100,13 @@ def __init__(self, params, model_type):
'''
if RESPONSE_STATUS_KEY in params:
self.status = ResponseStatus(params.get(RESPONSE_STATUS_KEY))
else:
else: # pragma: no cover
self.status = ResponseStatus.FAILED

'''
Message associated with the response
'''
if STATUS_MESSAGE_KEY in params:
self.status = params.get(STATUS_MESSAGE_KEY)
else:
else: # pragma: no cover
self.status = ""
14 changes: 7 additions & 7 deletions tsp/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, params):
if UUID_KEY in params:
self.UUID = params.get(UUID_KEY)
del params[UUID_KEY]
else:
else: # pragma: no cover
self.UUID = NA

'''
Expand All @@ -58,7 +58,7 @@ def __init__(self, params):
if NAME_KEY in params:
self.name = params.get(NAME_KEY)
del params[NAME_KEY]
else:
else: # pragma: no cover
self.name = NA

'''
Expand All @@ -67,7 +67,7 @@ def __init__(self, params):
if START_TIME_KEY in params:
self.start = params.get(START_TIME_KEY)
del params[START_TIME_KEY]
else:
else: # pragma: no cover
self.start = -1

'''
Expand All @@ -76,7 +76,7 @@ def __init__(self, params):
if END_TIME_KEY in params:
self.end = params.get(END_TIME_KEY)
del params[END_TIME_KEY]
else:
else: # pragma: no cover
self.end = -1

'''
Expand All @@ -85,7 +85,7 @@ def __init__(self, params):
if PATH_TIME_KEY in params:
self.path = params.get(PATH_TIME_KEY)
del params[PATH_TIME_KEY]
else:
else: # pragma: no cover
self.path = -1

'''
Expand All @@ -94,7 +94,7 @@ def __init__(self, params):
if NB_EVENT_KEY in params:
self.number_of_events = params.get(NB_EVENT_KEY)
del params[NB_EVENT_KEY]
else:
else: # pragma: no cover
self.number_of_events = 0

'''
Expand All @@ -104,5 +104,5 @@ def __init__(self, params):
if INDEXING_STATUS_KEY in params:
self.indexin_status = params.get(INDEXING_STATUS_KEY)
del params[INDEXING_STATUS_KEY]
else:
else: # pragma: no cover
self.indexin_status = 0
30 changes: 15 additions & 15 deletions tsp/tsp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def fetch_traces(self):
response = requests.get(api_url, headers=headers)
if response.status_code == 200:
return TspClientResponse(TraceSet(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
else:
else: # pragma: no cover
print("get traces failed: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand Down Expand Up @@ -98,7 +98,7 @@ def open_trace(self, name, path):

if response.status_code == 200:
return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
else:
else: # pragma: no cover
print("post trace failed: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand All @@ -113,7 +113,7 @@ def delete_trace(self, uuid, delete_trace, remove_cache=False):
'''
api_url = '{0}traces/{1}'.format(self.base_url, uuid)
parameters = {}
if delete_trace:
if delete_trace: # pragma: no cover
parameters['deleteTrace'] = "true"

if remove_cache:
Expand All @@ -122,7 +122,7 @@ def delete_trace(self, uuid, delete_trace, remove_cache=False):
response = requests.delete(api_url, json=parameters, headers=headers)
if response.status_code == 200:
return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
else:
else: # pragma: no cover
print("delete trace failed: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand All @@ -136,7 +136,7 @@ def fetch_experiments(self):
response = requests.get(api_url, headers=headers)
if response.status_code == 200:
return TspClientResponse(ExperimentSet(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
else:
else: # pragma: no cover
print("get experiments failed: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand Down Expand Up @@ -166,7 +166,7 @@ def delete_experiment(self, uuid):
response = requests.delete(api_url, headers=headers)
if response.status_code == 200:
return TspClientResponse(Experiment(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
else:
else: # pragma: no cover
print("delete experiment failed: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand All @@ -185,7 +185,7 @@ def open_experiment(self, name, traces):

if response.status_code == 200:
return TspClientResponse(Experiment(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
else:
else: # pragma: no cover
print("post experiment failed: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand All @@ -202,7 +202,7 @@ def fetch_experiment_outputs(self, exp_uuid):

if response.status_code == 200:
return TspClientResponse(OutputDescriptorSet(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
else:
else: # pragma: no cover
print("get output descriptors failed: {0}".format(
response.status_code))
return TspClientResponse(None, response.status_code, response.text)
Expand All @@ -223,7 +223,7 @@ def fetch_experiment_output(self, exp_uuid, output_id):

if response.status_code == 200:
return TspClientResponse(OutputDescriptor(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
else:
else: # pragma: no cover
print("failed to get tree: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand All @@ -247,7 +247,7 @@ def fetch_timegraph_tree(self, exp_uuid, output_id, parameters=None):

if response.status_code == 200:
return TspClientResponse(GenericResponse(json.loads(response.content.decode('utf-8')), ModelType.TIME_GRAPH_TREE), response.status_code, response.text)
else:
else: # pragma: no cover
print("failed to get tree: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand All @@ -271,7 +271,7 @@ def fetch_xy_tree(self, exp_uuid, output_id, parameters=None):

if response.status_code == 200:
return TspClientResponse(GenericResponse(json.loads(response.content.decode('utf-8')), ModelType.XY_TREE), response.status_code, response.text)
else:
else: # pragma: no cover
print("failed to get tree: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand All @@ -291,7 +291,7 @@ def fetch_xy(self, exp_uuid, output_id, parameters):

if response.status_code == 200:
return TspClientResponse(GenericResponse(json.loads(response.content.decode('utf-8')), ModelType.XY), response.status_code, response.text)
else:
else: # pragma: no cover
print("failed to get xy: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand All @@ -305,7 +305,7 @@ def fetch_extensions(self):

if response.status_code == 200:
return TspClientResponse(ExtensionSet(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
else:
else: # pragma: no cover
print("failed to get extensions: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand All @@ -320,7 +320,7 @@ def post_extension(self, mypath):

if response.status_code == 200:
return TspClientResponse("Loaded", response.status_code, response.text)
else:
else: # pragma: no cover
print("post extension failed: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)

Expand All @@ -334,6 +334,6 @@ def delete_extension(self, name):

if response.status_code == 200:
return TspClientResponse("Deleted", response.status_code, response.text)
else:
else: # pragma: no cover
print("post extension failed: {0}".format(response.status_code))
return TspClientResponse(None, response.status_code, response.text)
6 changes: 3 additions & 3 deletions tsp/xy_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, params):
self.series.append(XYSeries(series))
del params[SERIES_KEY]

def print(self):
def print(self): # pragma: no cover
print(f'XY title: {self.title}')

common_x_axis = False
Expand Down Expand Up @@ -139,7 +139,7 @@ def __init__(self, params):
self.tags.append(tag)
del params[TAGS_KEY]

def print(self):
def print(self): # pragma: no cover
print(f' Series name: {self.series_name}')
print(f' Series id: {self.series_id}')

Expand Down Expand Up @@ -181,7 +181,7 @@ def __init__(self, params):
self.data_type = params.get(DATA_TYPE_KEY)
del params[DATA_TYPE_KEY]

def print(self):
def print(self): # pragma: no cover
print(f' Axis label: {self.label}')
print(f' Axis unit: {self.unit}')
print(f' Axis data type: {self.data_type}')

0 comments on commit 702bef9

Please sign in to comment.