Skip to content

Commit

Permalink
Merge branch '29-increase-unit-test-coverage-on-telemetrytestsuite-cl…
Browse files Browse the repository at this point in the history
…ass-aka-telemetry_test_suite-py-to-100' into 'main'

Updates for testing telemetry_test_suite.py

Closes nasa#29

See merge request cFS_lab/raisr_nos3/raisr-2.0!15
  • Loading branch information
asgibson committed Jan 6, 2023
2 parents 0e3dfd1 + 1336e57 commit efb1efc
Show file tree
Hide file tree
Showing 2 changed files with 1,302 additions and 222 deletions.
46 changes: 23 additions & 23 deletions src/systems/telemetry_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, headers=[], tests=[]):
'ROTATIONAL' : self.rotational,
'STATE' : self.state,
'FEASIBILITY' : self.feasibility,
'NOOP': self.noop}
'NOOP' : self.noop}

################################################
################ Running Tests ###############
Expand All @@ -46,7 +46,7 @@ def run_tests(self, header_index, test_val, sync_data):
status.append(stat) # tuple

bayesian = self.calc_single_status(status)
# Add all mass assignments?
# TODO: Add all mass assignments?
return Status(self.dataFields[header_index], bayesian[0], bayesian[1])


Expand All @@ -61,17 +61,17 @@ def get_latest_result(self, fieldName):

def sync(self, val, test_params, epsilon):
return 'GREEN', [({'GREEN'}, 1.0)]
mass_assignments = [] # list of tuples
if len(test_params) == 0:
stat = 'RED'
mass_assignments.append(({stat}, 1.0))
return stat, mass_assignments
if val == test_params[0]:
stat = 'GREEN'
mass_assignments.append(({stat}, 1.0))
return stat, mass_assignments

return '---', mass_assignments
# mass_assignments = [] # list of tuples
# if len(test_params) == 0:
# stat = 'RED'
# mass_assignments.append(({stat}, 1.0))
# return stat, mass_assignments
# if val == test_params[0]:
# stat = 'GREEN'
# mass_assignments.append(({stat}, 1.0))
# return stat, mass_assignments

# return '---', mass_assignments

def rotational(self, val, test_params, epsilon):
stat = 'YELLOW'
Expand Down Expand Up @@ -110,7 +110,7 @@ def feasibility(self, val, test_params, epsilon):
# between [0] - [1] is yellow
# between [1] - [2] is green
# between [2] - [3] is yellow
# after [3] is green
# after [3] is red
# if len(test_params == 2) then the thresholds are as follows:
# before [0] is red
Expand Down Expand Up @@ -216,24 +216,24 @@ def noop(self, val, test_params, epsilon):
################################################
############## Combining statuses ##############
def calc_single_status(self, status_list, mode='strict'):
occurences = Counter(status_list)
max_occurence = occurences.most_common(1)[0][0]
occurrences = Counter(status_list)
max_occurrence = occurrences.most_common(1)[0][0]

if mode == 'strict':
if occurences['RED'] > 0:
conf = occurences['RED']/len(status_list)
if occurrences['RED'] > 0:
conf = occurrences['RED']/len(status_list)
return 'RED', conf
else:
return max_occurence, 1.0 # return max
return max_occurrence, 1.0 # return max

if mode == 'distr':
conf = occurences[max_occurence]/len(status_list)
return max_occurence, conf
conf = occurrences[max_occurrence]/len(status_list)
return max_occurrence, conf

elif mode == 'max':
return max_occurence, 1.0
return max_occurrence, 1.0
else:
return max_occurence, 1.0 # return max
return max_occurrence, 1.0 # return max

def get_suite_status(self):
status_strings = [res.get_status() for res in self.latest_results]
Expand Down
Loading

0 comments on commit efb1efc

Please sign in to comment.