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:
33 def __init__(self, name, order, ci_loop, description=""):
37 self.ci_loop = ci_loop
38 self.description = description
40 def add_test(self, testcase):
41 self.tests_array.append(testcase)
45 for test in self.tests_array:
46 array_tests.append(test)
49 def get_test_names(self):
51 for test in self.tests_array:
52 array_tests.append(test.get_name())
55 def get_test(self, test_name):
56 if self.is_test(test_name):
57 for test in self.tests_array:
58 if test.get_name() == test_name:
62 def is_test(self, test_name):
63 for test in self.tests_array:
64 if test.get_name() == test_name:
74 def get_ci_loop(self):
78 lines = split_text(self.description, LINE_LENGTH - 6)
81 out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
82 out += ("| Tier: " + self.name.ljust(LINE_LENGTH - 10) + "|\n")
83 out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
84 out += ("| Order: " + str(self.order).ljust(LINE_LENGTH - 10) + "|\n")
85 out += ("| CI Loop: " + str(self.ci_loop).ljust(LINE_LENGTH - 12) +
87 out += ("| Description:".ljust(LINE_LENGTH - 1) + "|\n")
89 out += ("| " + line.ljust(LINE_LENGTH - 7) + " |\n")
90 out += ("| Test cases:".ljust(LINE_LENGTH - 1) + "|\n")
91 tests = self.get_test_names()
93 for i in range(len(tests)):
94 out += ("| - %s |\n" % tests[i].ljust(LINE_LENGTH - 9))
96 out += ("| (There are no supported test cases "
97 .ljust(LINE_LENGTH - 1) + "|\n")
98 out += ("| in this tier for the given scenario) "
99 .ljust(LINE_LENGTH - 1) + "|\n")
100 out += ("|".ljust(LINE_LENGTH - 1) + "|\n")
101 out += ("+%s+\n" % ("-" * (LINE_LENGTH - 2)))
107 def __init__(self, name, dependency, criteria, blocking, description=""):
109 self.dependency = dependency
110 self.description = description
111 self.criteria = criteria
112 self.blocking = blocking
116 return item is None or item is ""
118 def is_compatible(self, ci_installer, ci_scenario):
120 if not self.is_none(ci_installer):
121 if re.search(self.dependency.get_installer(),
122 ci_installer) is None:
124 if not self.is_none(ci_scenario):
125 if re.search(self.dependency.get_scenario(),
126 ci_scenario) is None:
135 def get_criteria(self):
138 def is_blocking(self):
142 lines = split_text(self.description, LINE_LENGTH - 6)
145 out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
146 out += ("| Testcase: " + self.name.ljust(LINE_LENGTH - 14) + "|\n")
147 out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
148 out += ("| Description:".ljust(LINE_LENGTH - 1) + "|\n")
150 out += ("| " + line.ljust(LINE_LENGTH - 7) + " |\n")
151 out += ("| Criteria: " +
152 self.criteria.ljust(LINE_LENGTH - 14) + "|\n")
153 out += ("| Dependencies:".ljust(LINE_LENGTH - 1) + "|\n")
154 installer = self.dependency.get_installer()
155 scenario = self.dependency.get_scenario()
156 out += ("| - Installer:" + installer.ljust(LINE_LENGTH - 17) + "|\n")
157 out += ("| - Scenario :" + scenario.ljust(LINE_LENGTH - 17) + "|\n")
158 out += ("|".ljust(LINE_LENGTH - 1) + "|\n")
159 out += ("+%s+\n" % ("-" * (LINE_LENGTH - 2)))
165 def __init__(self, installer, scenario):
166 self.installer = installer
167 self.scenario = scenario
169 def get_installer(self):
170 return self.installer
172 def get_scenario(self):
176 return ("Dependency info:\n"
177 " installer: " + self.installer + "\n"
178 " scenario: " + self.scenario + "\n")