From a505f6038b6242b003a35d61c6a7607c63b8a988 Mon Sep 17 00:00:00 2001 From: Marco Miller Date: Fri, 10 Sep 2021 15:54:47 -0400 Subject: [PATCH 1/7] TestTspClient: Add complete{d} timegraph tree test Base this new test on the existing test_fetch_xy. Rename the hereby reused REQUESTED_TIME constants accordingly; no longer XY-specific. Don't redundantly assert model_type; test_fetch_timegraph_tree does so already. Now, adding this test increases test coverage (cf. README) in these specific ways: - time_graph_model.py: from 25% to 33%; - entry_model.py: from 84% to 88%; - response.py: from 86% to 89%. <=> From 59% to 60% total. More work remains then to cover tsp/ further. Signed-off-by: Marco Miller --- test_tsp.py | 55 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/test_tsp.py b/test_tsp.py index d9a709a..db922ff 100644 --- a/test_tsp.py +++ b/test_tsp.py @@ -27,11 +27,11 @@ from tsp.response import ResponseStatus from tsp.tsp_client import TspClient -REQUESTED_TIME_XY_START = 1332170682440133097 -REQUESTED_TIME_XY_END = 1332170692664579801 -REQUESTED_TIME_XY_LENGTH = 10 -REQUESTED_TIME_XY_STEP = (REQUESTED_TIME_XY_END - - REQUESTED_TIME_XY_START) / REQUESTED_TIME_XY_LENGTH +REQUESTED_TIME_START = 1332170682440133097 +REQUESTED_TIME_END = 1332170692664579801 +REQUESTED_TIME_LENGTH = 10 +REQUESTED_TIME_STEP = (REQUESTED_TIME_END - + REQUESTED_TIME_START) / REQUESTED_TIME_LENGTH class TestTspClient: @@ -279,9 +279,9 @@ def test_fetch_xy(self, kernel): parameters[TspClient.REQUESTED_ITEM_KEY] = requested_items requested_times = [] - requested_time = REQUESTED_TIME_XY_START - while len(requested_times) < REQUESTED_TIME_XY_LENGTH: - requested_time += REQUESTED_TIME_XY_STEP + requested_time = REQUESTED_TIME_START + while len(requested_times) < REQUESTED_TIME_LENGTH: + requested_time += REQUESTED_TIME_STEP requested_times.append(int(requested_time)) parameters[TspClient.REQUESTED_TIME_KEY] = requested_times @@ -292,6 +292,45 @@ def test_fetch_xy(self, kernel): self._delete_experiments() self._delete_traces() + def test_fetch_timegraph_tree_complete(self, kernel): + traces = [] + response = self.tsp_client.open_trace(os.path.basename(kernel), kernel) + traces.append(response.model.UUID) + response = self.tsp_client.open_experiment( + os.path.basename(kernel), traces) + assert response.status_code == 200 + experiment_uuid = response.model.UUID + + response = self.tsp_client.fetch_experiment_outputs(experiment_uuid) + output_id = response.model.descriptors[0].id + status = ResponseStatus.RUNNING.name + while status == ResponseStatus.RUNNING.name: + time.sleep(1) + response = self.tsp_client.fetch_timegraph_tree( + experiment_uuid, output_id) + assert response.model is not None + status = response.model.status.upper() + + parameters = {} + requested_items = [] + for entry in response.model.model.entries: + requested_items.append(entry.id) + parameters[TspClient.REQUESTED_ITEM_KEY] = requested_items + + requested_times = [] + requested_time = REQUESTED_TIME_START + while len(requested_times) < REQUESTED_TIME_LENGTH: + requested_time += REQUESTED_TIME_STEP + requested_times.append(int(requested_time)) + parameters[TspClient.REQUESTED_TIME_KEY] = requested_times + + params = {TspClient.PARAMETERS_KEY: parameters} + response = self.tsp_client.fetch_timegraph_tree( + experiment_uuid, output_id, params) + assert response.status_code == 200 + self._delete_experiments() + self._delete_traces() + def test_fetch_extensions_none(self): response = self.tsp_client.fetch_extensions() assert response.status_code == 200 From f76f46209a916e82761a137f40a09feb0fd43809 Mon Sep 17 00:00:00 2001 From: Marco Miller Date: Fri, 10 Sep 2021 16:36:04 -0400 Subject: [PATCH 2/7] TestTspClient: Remove duplication just introduced Remove the duplication introduced by test_fetch_timegraph_tree_complete, which was based on test_fetch_xy. Add the private __requested_parameters helper method for this. Signed-off-by: Marco Miller --- test_tsp.py | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/test_tsp.py b/test_tsp.py index db922ff..62afe48 100644 --- a/test_tsp.py +++ b/test_tsp.py @@ -272,20 +272,7 @@ def test_fetch_xy(self, kernel): assert response.model is not None status = response.model.status.upper() - parameters = {} - requested_items = [] - for entry in response.model.model.entries: - requested_items.append(entry.id) - parameters[TspClient.REQUESTED_ITEM_KEY] = requested_items - - requested_times = [] - requested_time = REQUESTED_TIME_START - while len(requested_times) < REQUESTED_TIME_LENGTH: - requested_time += REQUESTED_TIME_STEP - requested_times.append(int(requested_time)) - parameters[TspClient.REQUESTED_TIME_KEY] = requested_times - - params = {TspClient.PARAMETERS_KEY: parameters} + params = self.__requested_parameters(response) response = self.tsp_client.fetch_xy(experiment_uuid, output_id, params) assert response.status_code == 200 assert response.model.model_type == response.model.model_type.XY @@ -311,20 +298,7 @@ def test_fetch_timegraph_tree_complete(self, kernel): assert response.model is not None status = response.model.status.upper() - parameters = {} - requested_items = [] - for entry in response.model.model.entries: - requested_items.append(entry.id) - parameters[TspClient.REQUESTED_ITEM_KEY] = requested_items - - requested_times = [] - requested_time = REQUESTED_TIME_START - while len(requested_times) < REQUESTED_TIME_LENGTH: - requested_time += REQUESTED_TIME_STEP - requested_times.append(int(requested_time)) - parameters[TspClient.REQUESTED_TIME_KEY] = requested_times - - params = {TspClient.PARAMETERS_KEY: parameters} + params = self.__requested_parameters(response) response = self.tsp_client.fetch_timegraph_tree( experiment_uuid, output_id, params) assert response.status_code == 200 @@ -353,3 +327,18 @@ def test_posted_extension_deleted(self, extension): response = self.tsp_client.fetch_extensions() assert not response.model.extension_set + + def __requested_parameters(self, response): + parameters = {} + requested_items = [] + for entry in response.model.model.entries: + requested_items.append(entry.id) + parameters[TspClient.REQUESTED_ITEM_KEY] = requested_items + + requested_times = [] + requested_time = REQUESTED_TIME_START + while len(requested_times) < REQUESTED_TIME_LENGTH: + requested_time += REQUESTED_TIME_STEP + requested_times.append(int(requested_time)) + parameters[TspClient.REQUESTED_TIME_KEY] = requested_times + return {TspClient.PARAMETERS_KEY: parameters} From 9ed278d9a4219b61a5174fa0f813a8bfc458758e Mon Sep 17 00:00:00 2001 From: Marco Miller Date: Mon, 13 Sep 2021 17:30:58 -0400 Subject: [PATCH 3/7] Remove the unused DataType class w/ its whole file Signed-off-by: Marco Miller --- tsp/data_type.py | 35 ----------------------------------- tsp/tree_model.py | 2 -- 2 files changed, 37 deletions(-) delete mode 100644 tsp/data_type.py diff --git a/tsp/data_type.py b/tsp/data_type.py deleted file mode 100644 index bd5cf03..0000000 --- a/tsp/data_type.py +++ /dev/null @@ -1,35 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (C) 2020 - Ericsson -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from enum import Enum - - -class DataType(Enum): - ''' - Type enum to define different data descriptors - ''' - - NUMBER = "NUMBER" - BINARY_NUMBER = "BINARY_NUMBER" - TIMESTAMP = "TIMESTAMP" - DURATION = "DURATION" - STRING = "STRING" diff --git a/tsp/tree_model.py b/tsp/tree_model.py index d7681e4..8aba6d3 100644 --- a/tsp/tree_model.py +++ b/tsp/tree_model.py @@ -27,8 +27,6 @@ import pandas as pd -from tsp.data_type import DataType - class TreeModel(object): From 5fcdbc338b28846296a331a0a6e3dd3d4dc96e37 Mon Sep 17 00:00:00 2001 From: Marco Miller Date: Tue, 14 Sep 2021 14:20:56 -0400 Subject: [PATCH 4/7] Remove storing unspecified parameters in 'others' If some data is needed to be transferred between server and clients over the TSP, then it needs to properly be specified in the TSP, so that clients and server can support it. Fixes #35 Signed-off-by: Marco Miller --- tsp/column_descriptor.py | 11 +---------- tsp/entry.py | 11 +---------- tsp/entry_model.py | 7 ------- tsp/experiment.py | 7 ------- tsp/output_descriptor.py | 7 ------- tsp/output_element_style.py | 14 -------------- tsp/time_graph_model.py | 37 +------------------------------------ tsp/trace.py | 7 ------- tsp/tree_model.py | 8 ++------ tsp/xy_model.py | 27 --------------------------- 10 files changed, 5 insertions(+), 131 deletions(-) diff --git a/tsp/column_descriptor.py b/tsp/column_descriptor.py index f5cede6..da78888 100644 --- a/tsp/column_descriptor.py +++ b/tsp/column_descriptor.py @@ -31,7 +31,7 @@ class ColumnDescriptor(object): Basic entry ''' - def __init__(self, params, copy_others=True): + def __init__(self, params): ''' Text of header for the entry ''' @@ -47,12 +47,3 @@ def __init__(self, params, copy_others=True): if TOOLTIP_KEY in params: self.tooltip = params.get(TOOLTIP_KEY) del params[TOOLTIP_KEY] - - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.copy_others = copy_others - if copy_others: - self.others = {} - if params: - self.others = copy.deepcopy(params) diff --git a/tsp/entry.py b/tsp/entry.py index fcfa7e2..9142b46 100644 --- a/tsp/entry.py +++ b/tsp/entry.py @@ -50,7 +50,7 @@ class Entry(object): Basic entry ''' - def __init__(self, params, copy_others=True): + def __init__(self, params): ''' Unique Id for the entry ''' @@ -84,12 +84,3 @@ def __init__(self, params, copy_others=True): if params.get(STYLE_KEY) is not None: self.style = OutputElementStyle(params.get(STYLE_KEY)) del params[STYLE_KEY] - - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.copy_others = copy_others - if copy_others: - self.others = {} - if params: - self.others = copy.deepcopy(params) diff --git a/tsp/entry_model.py b/tsp/entry_model.py index 7417aad..0e9c8b8 100644 --- a/tsp/entry_model.py +++ b/tsp/entry_model.py @@ -69,10 +69,3 @@ def __init__(self, params, model_type=ModelType.XY_TREE): else: self.entries.append(Entry(entry)) del params[ENTRIES_KEY] - - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) diff --git a/tsp/experiment.py b/tsp/experiment.py index 9e53ab5..91bc7f9 100644 --- a/tsp/experiment.py +++ b/tsp/experiment.py @@ -105,10 +105,3 @@ def __init__(self, params): ''' if TRACES_TIME_KEY in params: self.traces = TraceSet(params.get(TRACES_TIME_KEY)) - - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) diff --git a/tsp/output_descriptor.py b/tsp/output_descriptor.py index 5082ce4..b1bcf4e 100644 --- a/tsp/output_descriptor.py +++ b/tsp/output_descriptor.py @@ -127,10 +127,3 @@ def __init__(self, params): del params[COMPATIBLE_PROVIDERS_KEY] else: self.compatible_providers = [] - - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) diff --git a/tsp/output_element_style.py b/tsp/output_element_style.py index b5bd283..fd35880 100644 --- a/tsp/output_element_style.py +++ b/tsp/output_element_style.py @@ -58,13 +58,6 @@ def __init__(self, params): else: self.style_values = {} - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) - class OutputStyleModel(object): ''' @@ -84,10 +77,3 @@ def __init__(self, params): del params[STYLES_KEY] else: self.style = None - - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) diff --git a/tsp/time_graph_model.py b/tsp/time_graph_model.py index c3cbead..763f2dd 100644 --- a/tsp/time_graph_model.py +++ b/tsp/time_graph_model.py @@ -46,7 +46,7 @@ class TimeGraphEntry(Entry): ''' def __init__(self, params): - super(TimeGraphEntry, self).__init__(params, False) + super(TimeGraphEntry, self).__init__(params) ''' Type of the entry @@ -76,13 +76,6 @@ def __init__(self, params): self.has_row_model = params.get(HAS_ROW_MODEL_KEY) del params[HAS_ROW_MODEL_KEY] - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) - class TimeGraphModel(object): ''' @@ -96,13 +89,6 @@ def __init__(self, params): self.rows.append(TimeGraphRow(row)) del params[ROWS_KEY] - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) - class TimeGraphRow(object): ''' @@ -126,13 +112,6 @@ def __init__(self, params): self.states.append(TimeGraphState(state)) del params[STATES_KEY] - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) - class TimeGraphState(object): ''' @@ -182,13 +161,6 @@ def __init__(self, params): self.style = params.get(STYLE_KEY) del params[STYLE_KEY] - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) - class TimeGraphArrow(object): ''' @@ -237,10 +209,3 @@ def __init__(self, params): if STYLE_KEY in params: self.style = params.get(STYLE_KEY) del params[STYLE_KEY] - - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) diff --git a/tsp/trace.py b/tsp/trace.py index cf5450c..a2e03d5 100644 --- a/tsp/trace.py +++ b/tsp/trace.py @@ -106,10 +106,3 @@ def __init__(self, params): del params[INDEXING_STATUS_KEY] else: self.indexin_status = 0 - - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) diff --git a/tsp/tree_model.py b/tsp/tree_model.py index 8aba6d3..2741f3f 100644 --- a/tsp/tree_model.py +++ b/tsp/tree_model.py @@ -107,13 +107,9 @@ def print(self, data, depth=0): print(" ", end="") for _ in range((int)(depth / self._indent) - 1): print("| ", end="") - other = "" - others = self._entry.others # TODO print TimeGraphEntry specific fields - for k in others: - other = ('{0} ({1}, {2})'.format(other, k, others.get(k))) - print("{0}{1} ({1}, {2}) {3} {4}".format( - prefix, self._entry.labels[0], self._entry.id, self._entry.parent_id, other)) + print("{0}{1} ({1}, {2}) {3}".format( + prefix, self._entry.labels[0], self._entry.id, self._entry.parent_id)) else: label_str = "" if(depth > 0): diff --git a/tsp/xy_model.py b/tsp/xy_model.py index 7664c14..5fb3cf2 100644 --- a/tsp/xy_model.py +++ b/tsp/xy_model.py @@ -66,13 +66,6 @@ def __init__(self, params): self.series.append(XYSeries(series)) del params[SERIES_KEY] - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) - def print(self): print(f'XY title: {self.title}') @@ -83,8 +76,6 @@ def print(self): for series in self.series: series.print() - for other_item in self.others.items(): - print(f'XY other item: {other_item}') class XYSeries(object): @@ -148,13 +139,6 @@ def __init__(self, params): self.tags.append(tag) del params[TAGS_KEY] - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) - def print(self): print(f' Series name: {self.series_name}') print(f' Series id: {self.series_id}') @@ -168,8 +152,6 @@ def print(self): print(f' Series Y-value: {value}') for tag in self.tags: print(f' Series tag: {tag}') - for other_item in self.others.items(): - print(f' Series other item: {other_item}') class XYAxis(object): @@ -199,16 +181,7 @@ def __init__(self, params): self.data_type = params.get(DATA_TYPE_KEY) del params[DATA_TYPE_KEY] - ''' - Store other key/value pairs that are not defined in the TSP in a dictionary - ''' - self.others = {} - if params: - self.others = copy.deepcopy(params) - def print(self): print(f' Axis label: {self.label}') print(f' Axis unit: {self.unit}') print(f' Axis data type: {self.data_type}') - for other_item in self.others.items(): - print(f' Axis other item: {other_item}') From 9a6279394777dd16e2d76a8020d3a1390d678442 Mon Sep 17 00:00:00 2001 From: Marco Miller Date: Tue, 14 Sep 2021 15:55:31 -0400 Subject: [PATCH 5/7] EntryModel: Remove redundant local variable Signed-off-by: Marco Miller --- tsp/entry_model.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tsp/entry_model.py b/tsp/entry_model.py index 0e9c8b8..e20cc4f 100644 --- a/tsp/entry_model.py +++ b/tsp/entry_model.py @@ -62,8 +62,7 @@ def __init__(self, params, model_type=ModelType.XY_TREE): ''' self.entries = [] if ENTRIES_KEY in params: - entries = params.get(ENTRIES_KEY) - for entry in entries: + for entry in params.get(ENTRIES_KEY): if model_type == ModelType.TIME_GRAPH_TREE: self.entries.append(TimeGraphEntry(entry)) else: From 3a73eb26ec877d10dbdf28bf1d17bdf8b5d754ba Mon Sep 17 00:00:00 2001 From: Marco Miller Date: Tue, 14 Sep 2021 16:48:35 -0400 Subject: [PATCH 6/7] Tree{Model,Item}: Move out of tsp/ package; cli's Move tree_model.py's whole content (both classes) out of the tsp/ package, as only ./tsp-cli-client uses it. Make the file a sibling of the latter, as duly expected. This move also solves the issue of tsp/ pytest coverage previously reporting that file as not covered at all. Signed-off-by: Marco Miller --- tsp/tree_model.py => tree_model.py | 0 tsp-cli-client | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename tsp/tree_model.py => tree_model.py (100%) diff --git a/tsp/tree_model.py b/tree_model.py similarity index 100% rename from tsp/tree_model.py rename to tree_model.py diff --git a/tsp-cli-client b/tsp-cli-client index 5664b66..17e6ede 100755 --- a/tsp-cli-client +++ b/tsp-cli-client @@ -34,7 +34,7 @@ from datetime import timedelta from decimal import Decimal from os.path import os -from tsp.tree_model import TreeModel +from tree_model import TreeModel from tsp.tsp_client import TspClient from tsp.xy_model import XYModel From d298b910bb0f86e87b061bba235bf516004f2a1a Mon Sep 17 00:00:00 2001 From: Marco Miller Date: Tue, 14 Sep 2021 14:04:25 -0400 Subject: [PATCH 7/7] Add pragma(s) where no pytest coverage necessary 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 --- tsp/experiment.py | 12 ++++++------ tsp/output_descriptor.py | 8 ++++---- tsp/response.py | 6 +++--- tsp/trace.py | 14 +++++++------- tsp/tsp_client.py | 30 +++++++++++++++--------------- tsp/xy_model.py | 6 +++--- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/tsp/experiment.py b/tsp/experiment.py index 91bc7f9..16a9d56 100644 --- a/tsp/experiment.py +++ b/tsp/experiment.py @@ -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 ''' @@ -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 ''' @@ -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 ''' @@ -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 ''' @@ -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 ''' @@ -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 ''' diff --git a/tsp/output_descriptor.py b/tsp/output_descriptor.py index b1bcf4e..b61736e 100644 --- a/tsp/output_descriptor.py +++ b/tsp/output_descriptor.py @@ -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 ''' @@ -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 ''' @@ -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 ''' @@ -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 ''' diff --git a/tsp/response.py b/tsp/response.py index ea69623..7375bb8 100644 --- a/tsp/response.py +++ b/tsp/response.py @@ -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: @@ -100,7 +100,7 @@ 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 ''' @@ -108,5 +108,5 @@ def __init__(self, params, model_type): ''' if STATUS_MESSAGE_KEY in params: self.status = params.get(STATUS_MESSAGE_KEY) - else: + else: # pragma: no cover self.status = "" diff --git a/tsp/trace.py b/tsp/trace.py index a2e03d5..adb082c 100644 --- a/tsp/trace.py +++ b/tsp/trace.py @@ -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 ''' @@ -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 ''' @@ -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 ''' @@ -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 ''' @@ -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 ''' @@ -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 ''' @@ -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 diff --git a/tsp/tsp_client.py b/tsp/tsp_client.py index a4f8073..d04ad45 100644 --- a/tsp/tsp_client.py +++ b/tsp/tsp_client.py @@ -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) @@ -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) @@ -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: @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/tsp/xy_model.py b/tsp/xy_model.py index 5fb3cf2..ab729d6 100644 --- a/tsp/xy_model.py +++ b/tsp/xy_model.py @@ -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 @@ -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}') @@ -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}')