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
20 def split_text(text, max_len):
25 if len(line) + len(word) < max_len - 1:
37 def __init__(self, name, order, ci_loop, description=""):
39 self.skipped_tests_array = []
42 self.ci_loop = ci_loop
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:
85 def get_ci_loop(self):
89 msg = prettytable.PrettyTable(
90 header_style='upper', padding_width=5,
91 field_names=['tiers', 'order', 'CI Loop', 'description',
94 [self.name, self.order, self.ci_loop,
95 textwrap.fill(self.description, width=40),
96 textwrap.fill(' '.join([str(x.get_name(
97 )) for x in self.get_tests()]), width=40)])
98 return msg.get_string()
101 class TestCase(object):
103 def __init__(self, name,
111 self.enabled = enabled
112 self.dependency = dependency
113 self.criteria = criteria
114 self.blocking = blocking
115 self.description = description
116 self.project = project
120 return item is None or item is ""
122 def is_compatible(self, ci_installer, ci_scenario):
124 if not self.is_none(ci_installer):
125 if re.search(self.dependency.get_installer(),
126 ci_installer) is None:
128 if not self.is_none(ci_scenario):
129 if re.search(self.dependency.get_scenario(),
130 ci_scenario) is None:
139 def is_enabled(self):
142 def get_criteria(self):
145 def is_blocking(self):
148 def get_project(self):
152 msg = prettytable.PrettyTable(
153 header_style='upper', padding_width=5,
154 field_names=['test case', 'description', 'criteria', 'dependency'])
155 msg.add_row([self.name, textwrap.fill(self.description, width=40),
156 self.criteria, self.dependency])
157 return msg.get_string()
160 class Dependency(object):
162 def __init__(self, installer, scenario):
163 self.installer = installer
164 self.scenario = scenario
166 def get_installer(self):
167 return self.installer
169 def get_scenario(self):
173 delimitator = "\n" if self.get_installer(
174 ) and self.get_scenario() else ""
175 return "{}{}{}".format(self.get_installer(), delimitator,