3 # Copyright (c) 2016 Ericsson AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 """Tier and TestCase classes to wrap the testcases config file"""
11 # pylint: disable=missing-docstring
21 def split_text(text, max_len):
26 if len(line) + len(word) < max_len - 1:
38 def __init__(self, name, order, description=""):
40 self.skipped_tests_array = []
43 self.description = description
45 def add_test(self, testcase):
46 self.tests_array.append(testcase)
48 def skip_test(self, testcase):
49 self.skipped_tests_array.append(testcase)
53 for test in self.tests_array:
54 array_tests.append(test)
57 def get_skipped_test(self):
58 return self.skipped_tests_array
60 def get_test_names(self):
62 for test in self.tests_array:
63 array_tests.append(test.get_name())
66 def get_test(self, test_name):
67 if self.is_test(test_name):
68 for test in self.tests_array:
69 if test.get_name() == test_name:
73 def is_test(self, test_name):
74 for test in self.tests_array:
75 if test.get_name() == test_name:
86 msg = prettytable.PrettyTable(
87 header_style='upper', padding_width=5,
88 field_names=['tiers', 'order', 'description',
91 [self.name, self.order,
92 textwrap.fill(self.description, width=40),
93 textwrap.fill(' '.join([str(x.get_name(
94 )) for x in self.get_tests()]), width=40)])
95 return msg.get_string()
98 class TestCase(object):
100 def __init__(self, name, enabled, criteria, blocking,
101 description="", project=""):
102 # pylint: disable=too-many-arguments
104 self.enabled = enabled
105 self.criteria = criteria
106 self.blocking = blocking
107 self.description = description
108 self.project = project
113 def is_enabled(self):
116 def get_criteria(self):
119 def is_blocking(self):
122 def get_project(self):
126 msg = prettytable.PrettyTable(
127 header_style='upper', padding_width=5,
128 field_names=['test case', 'description', 'criteria'])
129 msg.add_row([self.name, textwrap.fill(self.description, width=40),
131 return msg.get_string()