summaryrefslogtreecommitdiffstats
path: root/docs/configguide/vTC
diff options
context:
space:
mode:
authorJo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>2016-01-11 11:20:55 +0100
committerJo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>2016-01-11 11:20:55 +0100
commit7766def60d167a55e4a0fbbb3d94e5bfe6241e08 (patch)
treeb8bb1a09e8078b28cd5fa566b9adf95034672a2c /docs/configguide/vTC
parent738fb0942c39e5f1ecad87ae9dd776f1019d2491 (diff)
Add missing yaml schema for TC037 and TC038
Change-Id: I299eb5a94afb8a29dee89938ff1d7b1bb7f43f3b JIRA:- Signed-off-by: Jo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>
Diffstat (limited to 'docs/configguide/vTC')
0 files changed, 0 insertions, 0 deletions
>144 145 146 147 148 149 150 151 152 153 154 155 156
#!/usr/bin/env python
#
# jose.lausuch@ericsson.com
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#


import re

LINE_LENGTH = 72


def split_text(text, max_len):
    words = text.split()
    lines = []
    line = ""
    for word in words:
        if len(line) + len(word) < max_len - 1:
            line += word + " "
        else:
            lines.append(line)
            line = word + " "
    if line != "":
        lines.append(line)
    return lines


class Tier:
    def __init__(self, name, order, ci_loop, description=""):
        self.tests_array = []
        self.name = name
        self.order = order
        self.ci_loop = ci_loop
        self.description = description

    def add_test(self, testcase):
        self.tests_array.append(testcase)

    def get_tests(self):
        array_tests = []
        for test in self.tests_array:
            array_tests.append(test)
        return array_tests

    def get_test_names(self):
        array_tests = []
        for test in self.tests_array:
            array_tests.append(test.get_name())
        return array_tests

    def get_test(self, test_name):
        if self.is_test(test_name):
            for test in self.tests_array:
                if test.get_name() == test_name:
                    return test
        return None

    def is_test(self, test_name):
        for test in self.tests_array:
            if test.get_name() == test_name:
                return True
        return False

    def get_name(self):
        return self.name

    def get_order(self):
        return self.order

    def get_ci_loop(self):
        return self.ci_loop

    def __str__(self):
        lines = split_text(self.description, LINE_LENGTH - 6)

        out = ""
        out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
        out += ("| Tier:  " + self.name.ljust(LINE_LENGTH - 10) + "|\n")
        out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
        out += ("| Order: " + str(self.order).ljust(LINE_LENGTH - 10) + "|\n")
        out += ("| CI Loop: " + str(self.ci_loop).ljust(LINE_LENGTH - 12) +
                "|\n")
        out += ("| Description:".ljust(LINE_LENGTH - 1) + "|\n")
        for line in lines:
            out += ("|    " + line.ljust(LINE_LENGTH - 7) + " |\n")
        out += ("| Test cases:".ljust(LINE_LENGTH - 1) + "|\n")
        tests = self.get_test_names()
        if len(tests) > 0:
            for i in range(len(tests)):
                out += ("|    - %s |\n" % tests[i].ljust(LINE_LENGTH - 9))
        else:
            out += ("|    (There are no supported test cases "
                    .ljust(LINE_LENGTH - 1) + "|\n")
            out += ("|    in this tier for the given scenario) "
                    .ljust(LINE_LENGTH - 1) + "|\n")
        out += ("|".ljust(LINE_LENGTH - 1) + "|\n")
        out += ("+%s+\n" % ("-" * (LINE_LENGTH - 2)))
        return out


class TestCase:
    def __init__(self, name, dependency, description=""):
        self.name = name
        self.dependency = dependency
        self.description = description

    def is_compatible(self, ci_installer, ci_scenario):
        try:
            return not (re.search(self.dependency.get_installer(),
                                  ci_installer) is None or
                        re.search(self.dependency.get_scenario(),
                                  ci_scenario) is None)
        except TypeError:
            return False

    def get_name(self):
        return self.name

    def __str__(self):
        lines = split_text(self.description, LINE_LENGTH - 6)

        out = ""
        out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
        out += ("| Testcase:  " + self.name.ljust(LINE_LENGTH - 14) + "|\n")
        out += ("+%s+\n" % ("=" * (LINE_LENGTH - 2)))
        out += ("| Description:".ljust(LINE_LENGTH - 1) + "|\n")
        for line in lines:
            out += ("|    " + line.ljust(LINE_LENGTH - 7) + " |\n")
        out += ("| Dependencies:".ljust(LINE_LENGTH - 1) + "|\n")
        installer = self.dependency.get_installer()
        scenario = self.dependency.get_scenario()
        out += ("|   - Installer:" + installer.ljust(LINE_LENGTH - 17) + "|\n")
        out += ("|   - Scenario :" + scenario.ljust(LINE_LENGTH - 17) + "|\n")
        out += ("|".ljust(LINE_LENGTH - 1) + "|\n")
        out += ("+%s+\n" % ("-" * (LINE_LENGTH - 2)))
        return out


class Dependency:
    def __init__(self, installer, scenario):
        self.installer = installer
        self.scenario = scenario

    def get_installer(self):
        return self.installer

    def get_scenario(self):
        return self.scenario

    def __str__(self):
        return ("Dependency info:\n"
                "        installer: " + self.installer + "\n"
                "        scenario:  " + self.scenario + "\n")