3 # jose.lausuch@ericsson.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
16 def split_text(text, max_len):
21 if len(line) + len(word) < max_len - 1:
32 def __init__(self, name, order, ci_loop, description=""):
36 self.ci_loop = ci_loop
37 self.description = description
39 def add_test(self, testcase):
40 self.tests_array.append(testcase)
44 for test in self.tests_array:
45 array_tests.append(test)
48 def get_test_names(self):
50 for test in self.tests_array:
51 array_tests.append(test.get_name())
54 def get_test(self, test_name):
55 if self.is_test(test_name):
56 for test in self.tests_array:
57 if test.get_name() == test_name:
61 def is_test(self, test_name):
62 for test in self.tests_array:
63 if test.get_name() == test_name:
73 def get_ci_loop(self):
77 lines = split_text(self.description, LINE_LENGTH - 6)
80 out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
81 out += ("| Tier: " + self.name.ljust(LINE_LENGTH - 10) + "|\n")
82 out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
83 out += ("| Order: " + str(self.order).ljust(LINE_LENGTH - 10) + "|\n")
84 out += ("| CI Loop: " + str(self.ci_loop).ljust(LINE_LENGTH - 12) +
86 out += ("| Description:".ljust(LINE_LENGTH - 1) + "|\n")
88 out += ("| " + line.ljust(LINE_LENGTH - 7) + " |\n")
89 out += ("| Test cases:".ljust(LINE_LENGTH - 1) + "|\n")
90 tests = self.get_test_names()
92 for i in range(len(tests)):
93 out += ("| - %s |\n" % tests[i].ljust(LINE_LENGTH - 9))
95 out += ("| (There are no supported test cases "
96 .ljust(LINE_LENGTH - 1) + "|\n")
97 out += ("| in this tier for the given scenario) "
98 .ljust(LINE_LENGTH - 1) + "|\n")
99 out += ("|".ljust(LINE_LENGTH - 1) + "|\n")
100 out += ("+%s+\n" % ("-" * (LINE_LENGTH - 2)))
105 def __init__(self, name, dependency, criteria, description=""):
107 self.dependency = dependency
108 self.description = description
109 self.criteria = criteria
111 def is_compatible(self, ci_installer, ci_scenario):
113 if ci_installer is not None:
114 if re.search(self.dependency.get_installer(),
115 ci_installer) is None:
117 if ci_scenario is not None:
118 if re.search(self.dependency.get_scenario(),
119 ci_scenario) is None:
121 return not (ci_scenario is None and ci_installer is None)
128 def get_criteria(self):
132 lines = split_text(self.description, LINE_LENGTH - 6)
135 out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
136 out += ("| Testcase: " + self.name.ljust(LINE_LENGTH - 14) + "|\n")
137 out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
138 out += ("| Description:".ljust(LINE_LENGTH - 1) + "|\n")
140 out += ("| " + line.ljust(LINE_LENGTH - 7) + " |\n")
141 out += ("| Criteria: " +
142 self.criteria.ljust(LINE_LENGTH - 14) + "|\n")
143 out += ("| Dependencies:".ljust(LINE_LENGTH - 1) + "|\n")
144 installer = self.dependency.get_installer()
145 scenario = self.dependency.get_scenario()
146 out += ("| - Installer:" + installer.ljust(LINE_LENGTH - 17) + "|\n")
147 out += ("| - Scenario :" + scenario.ljust(LINE_LENGTH - 17) + "|\n")
148 out += ("|".ljust(LINE_LENGTH - 1) + "|\n")
149 out += ("+%s+\n" % ("-" * (LINE_LENGTH - 2)))
154 def __init__(self, installer, scenario):
155 self.installer = installer
156 self.scenario = scenario
158 def get_installer(self):
159 return self.installer
161 def get_scenario(self):
165 return ("Dependency info:\n"
166 " installer: " + self.installer + "\n"
167 " scenario: " + self.scenario + "\n")