7 PKG =
'phm_reliability' 8 NAME =
'test_reliability_node' 12 info_dict = dict({
'D2*': {
'T2': {
'ObjectCount': 10,
'ObjectFailureRate': 10.0},
'T3': {
'ObjectCount': 3,
'ObjectFailureRate': 55555.0}},
'D3*': {
'T4': {
'ObjectCount': 5,
'ObjectFailureRate': 2.0}},
'D1*': {
'T1': {
'ObjectCount': 5,
'ObjectFailureRate': 22222.0}}})
19 'T2': {
'type':
'Serial'},
20 'T3': {
'type':
'Parallel'},
21 'unrelated': [
'T2',
'T3'],
23 'T2': {
'Serial': [],
'Parallel': []},
24 'T3': {
'Serial': [],
'Parallel': []}},
27 'T4': {
'type':
'Parallel'},
30 'T4': {
'Serial': [],
'Parallel': []}},
33 'T1': {
'type':
'Serial'},
36 'T1': {
'Serial': [],
'Parallel': []}},
43 temp_dict = dict ({
'System': {
'ModuleValue':
'',
'Reliability': 0.0,
'Type':
'',
'FailureRate':
''},
'D2': {
'ModuleValue': 1,
'Reliability': 0.0,
'Type':
'Parallel',
'FailureRate': 30402.727272727276},
'D3': {
'ModuleValue': 3,
'Reliability': 7.224174,
'Type':
'Serial',
'FailureRate': 0.8759124087591241},
'D1': {
'ModuleValue': 4,
'Reliability': 0.0,
'Type':
'Serial',
'FailureRate': 111110.0}})
49 temp_dict = dict({
'D2': {
'ObjectCount':
'',
'FailureRate': 30402.727272727276,
'Type':
'Parallel',
'ObjectFailureRate':
''},
'T2': {
'ObjectCount': 10,
'FailureRate': 100.0,
'Type':
'Serial',
'ObjectFailureRate': 10.0},
'T3': {
'ObjectCount': 3,
'FailureRate': 30302.727272727276,
'Type':
'Parallel',
'ObjectFailureRate': 55555.0}})
55 temp_list = [
'D2',
'D3',
'D1']
61 temp_list = [[
'T2',
'T3'], [
'T4'], [
'T1']]
68 module_usage_during_task_list = [1, 3, 4]
70 return module_usage_during_task_list
74 module_failure_rate = [30402.727272727276, 0.8759124087591241, 111110.0]
76 return module_failure_rate
84 reliability_module =
"D2" 86 test_temp = rn.get_select_parameter_dict(info_dict, reliability_module, component_list)
87 test_result = dict({
'ObjectCount': 3,
'ObjectFailureRate': 55555.0})
89 self.assertDictEqual(test_temp, test_result)
94 reliability_module =
"D2" 96 test_temp = rn.get_select_parameter_dict(type_dict, reliability_module, component_list)
97 test_result = dict({
'type':
'Parallel'})
99 self.assertDictEqual(test_temp, test_result)
104 reliability_module =
"D2" 105 test_temp = rn.get_select_module_type(type_dict, reliability_module)
106 test_result =
'Parallel' 108 self.assertEqual(test_temp, test_result)
112 temp_dict = dict({
'ObjectCount': 3,
'ObjectFailureRate': 55555.0})
114 test_temp = rn.object_failure_rate_calculation(temp_dict, temp_type)
115 test_result = 166665.0
117 self.assertEqual(test_temp, test_result)
120 temp_dict = dict({
'ObjectCount': 3,
'ObjectFailureRate': 55555.0})
121 temp_type =
"Parallel" 122 test_temp = rn.object_failure_rate_calculation(temp_dict, temp_type)
123 test_result = 30302.727272727276
125 self.assertEqual(test_temp, test_result)
130 temp_dict = dict({
'ObjectCount': 3,
'ObjectFailureRate': 55555.0})
131 test_temp = rn.object_parallel_failure_rate_calculation(temp_dict)
132 test_result = 30302.727272727276
134 self.assertEqual(test_temp, test_result)
138 temp_dict = dict({
'ObjectCount': 3,
'ObjectFailureRate': 55555.0})
139 test_temp = rn.object_serial_failure_rate_calculation(temp_dict)
140 test_result = 166665.0
142 self.assertEqual(test_temp, test_result)
147 temp_list = [1.00, 2.00, 3.00, 4.00, 5.00]
148 test_temp = rn.component_parallel_failure_rate_calculation(temp_list)
149 test_result = 6.569343065693431
151 self.assertEqual(test_temp, test_result)
155 test_temp = rn.component_parallel_failure_rate_calculation(temp_list)
158 self.assertEqual(test_temp, test_result)
161 temp_list = [1.00, 2.00, 3.00, 4.00, 5.00]
162 test_temp = rn.component_serial_failure_rate_calculation(temp_list)
165 self.assertEqual(test_temp, test_result)
169 test_temp = rn.component_serial_failure_rate_calculation(temp_list)
172 self.assertEqual(test_temp, test_result)
177 test_temp = rn.reliability_parallel_formula(1)
180 self.assertEqual(test_temp, test_result)
183 test_temp = rn.reliability_parallel_formula(2)
186 self.assertEqual(test_temp, test_result)
190 test_temp = rn.reliability_parallel_calculation(temp_list)
193 self.assertEqual(test_temp, test_result)
197 test_temp = rn.reliability_parallel_calculation(temp_list)
200 self.assertEqual(test_temp, test_result)
204 test_temp = rn.reliability_serial_calculation(temp_list)
207 self.assertEqual(test_temp, test_result)
211 test_temp = rn.reliability_serial_calculation(temp_list)
214 self.assertEqual(test_temp, test_result)
223 graph_control =
False 224 test_temp = rn.failure_rate_for_modules(reliability_module, component_list, info_dict, type_dict, graph_control)
225 test_result = [30402.727272727276, 0.8759124087591241, 111110.0]
227 self.assertEqual(test_temp, test_result)
232 test_temp = rn.nominal_reliability_calculate(1, 1)
233 test_result = 0.36787944117144233
235 self.assertEqual(test_temp, test_result)
240 test_temp = rn.parallel_count_calculate(0)
243 self.assertEqual(test_temp, test_result)
246 test_temp = rn.parallel_count_calculate(3)
247 test_result = 0.545454545454545501
249 self.assertEqual(test_temp, test_result)
254 test_temp = rn.percentage_calculated(80)
257 self.assertEqual(test_temp, test_result)
266 want_a_string =
False 267 graph_control =
False 268 test_temp = rn.reliability_calculation_function(type_dict, reliability_module, module_usage_during_task_list, module_failure_rate, want_a_string, graph_control)
271 self.assertEqual(test_temp, test_result)
277 module_name =
"System" 279 test_temp = rn.create_system_graph(module_name, graph_dict)
282 self.assertEqual(test_temp, test_result)
287 test_temp = rn.create_module_graph(module_name, graph_dict)
290 self.assertEqual(test_temp, test_result)
294 rn.show_value_float = 1.0
295 test_temp = rn.monitoring(
False)
298 self.assertEqual(test_temp, test_result)
302 if __name__ ==
'__main__':
304 rosunit.unitrun(PKG, NAME, TestReliabilityNode, sysargs =
"--cov", coverage_packages=[str(PKG)])
def test_percentage_calculated(self)
def test_component_serial_failure_rate_calculation_2(self)
def test_get_select_module_type(self)
def test_reliability_serial_calculation_2(self)
def test_nominal_reliability_calculate(self)
def module_usage_during_task(self)
def test_failure_rate_for_modules(self)
def test_get_select_parameter_dict_1(self)
def test_create_module_graph(self)
def test_get_select_parameter_dict_2(self)
def test_reliability_serial_calculation_1(self)
def test_reliability_parallel_formula_1(self)
def test_object_failure_rate_calculation_2(self)
def test_monitoring(self)
def info_parameters(self)
def module_graph_dict(self)
def test_reliability_parallel_calculation_1(self)
def component_array(self)
def test_parallel_count_calculate_2(self)
def test_object_serial_failure_rate_calculation(self)
def test_component_serial_failure_rate_calculation_1(self)
def test_reliability_calculation_function(self)
def test_object_failure_rate_calculation_1(self)
def failure_rate_for_modules(self)
def test_object_parallel_failure_rate_calculation(self)
def test_component_parallel_failure_rate_calculation_1(self)
def test_create_system_graph(self)
def test_reliability_parallel_formula_2(self)
def system_graph_dict(self)
def test_reliability_parallel_calculation_2(self)
def test_component_parallel_failure_rate_calculation_2(self)
def test_parallel_count_calculate_1(self)
def type_parameters(self)