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)))
105 class TestCase(object):
107 def __init__(self, name,
114 self.dependency = dependency
115 self.criteria = criteria
116 self.blocking = blocking
117 self.clean_flag = clean_flag
118 self.description = description
122 return item is None or item is ""
124 def is_compatible(self, ci_installer, ci_scenario):
126 if not self.is_none(ci_installer):
127 if re.search(self.dependency.get_installer(),
128 ci_installer) is None:
130 if not self.is_none(ci_scenario):
131 if re.search(self.dependency.get_scenario(),
132 ci_scenario) is None:
141 def get_criteria(self):
144 def is_blocking(self):
147 def needs_clean(self):
148 return self.clean_flag
151 lines = split_text(self.description, LINE_LENGTH - 6)
154 out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
155 out += ("| Testcase: " + self.name.ljust(LINE_LENGTH - 14) + "|\n")
156 out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
157 out += ("| Description:".ljust(LINE_LENGTH - 1) + "|\n")
159 out += ("| " + line.ljust(LINE_LENGTH - 7) + " |\n")
160 out += ("| Criteria: " +
161 self.criteria.ljust(LINE_LENGTH - 14) + "|\n")
162 out += ("| Dependencies:".ljust(LINE_LENGTH - 1) + "|\n")
163 installer = self.dependency.get_installer()
164 scenario = self.dependency.get_scenario()
165 out += ("| - Installer:" + installer.ljust(LINE_LENGTH - 17) + "|\n")
166 out += ("| - Scenario :" + scenario.ljust(LINE_LENGTH - 17) + "|\n")
167 out += ("|".ljust(LINE_LENGTH - 1) + "|\n")
168 out += ("+%s+\n" % ("-" * (LINE_LENGTH - 2)))
172 class Dependency(object):
174 def __init__(self, installer, scenario):
175 self.installer = installer
176 self.scenario = scenario
178 def get_installer(self):
179 return self.installer
181 def get_scenario(self):
185 return ("Dependency info:\n"
186 " installer: " + self.installer + "\n"
187 " scenario: " + self.scenario + "\n")