aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/tests/TestFunctestUtils.py
blob: e1f81ecdfe2927e58fb2e8ff8350d68a9e10cdac (plain)
1
2
3
4
5

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 
#!/usr/bin/python

import os
import unittest
import yaml
from functest_utils import getTestEnv, isTestRunnable, generateTestcaseList


class TestFunctestUtils(unittest.TestCase):

    def setUp(self):
        os.environ["INSTALLER_TYPE"] = "fuel"
        os.environ["DEPLOY_SCENARIO"] = "os-odl_l3-ovs-ha"

        global functest_yaml

        with open("../config_functest.yaml") as f:
            functest_yaml = yaml.safe_load(f)
            f.close()

    def test_getTestEnv(self):

        env_test = getTestEnv('ovno', functest_yaml)
        self.assertEqual(env_test, {'scenario': 'ocl'})

        env_test = getTestEnv('doctor', functest_yaml)
        self.assertEqual(env_test, {'installer': 'fuel'})

        env_test = getTestEnv('promise', functest_yaml)
        self.assertEqual(env_test, {'installer': '(fuel)|(joid)'})

        env_test = getTestEnv('functest/tempest', functest_yaml)
        self.assertEqual(env_test, None)

        env_test = getTestEnv('functest/vims', functest_yaml)
        self.assertEqual(env_test, None)

        env_test = getTestEnv('functest/odl', functest_yaml)
        self.assertEqual(env_test, {'scenario': 'odl'})

        env_test = getTestEnv('functest/onos', functest_yaml)
        self.assertEqual(env_test, {'scenario': 'onos'})

        env_test = getTestEnv('policy-test', functest_yaml)
        self.assertEqual(env_test, {'scenario': 'odl'})

        env_test = getTestEnv('foo', functest_yaml)
        self.assertEqual(env_test, '')

    def test_isTestRunnable(self):

        test = isTestRunnable('ovno', functest_yaml)
        self.assertFalse(test)

        test = isTestRunnable('doctor', functest_yaml)
        self.assertTrue(test)

        test = isTestRunnable('promise', functest_yaml)
        self.assertTrue(test)

        test = isTestRunnable('functest/onos', functest_yaml)
        self.assertFalse(test)

        test = isTestRunnable('functest/odl', functest_yaml)
        self.assertTrue(test)

        test = isTestRunnable('functest/vping_ssh', functest_yaml)
        self.assertTrue(test)

        test = isTestRunnable('functest/vping_userdata', functest_yaml)
        self.assertTrue(test)

        test = isTestRunnable('functest/tempest', functest_yaml)
        self.assertTrue(test)

        test = isTestRunnable('functest/rally', functest_yaml)
        self.assertTrue(test)

        test = isTestRunnable('functest/vims', functest_yaml)
        self.assertTrue(test)

    def test_generateTestcaseList(self):

        test = generateTestcaseList(functest_yaml)

        expected_list = "vping_ssh vping_userdata tempest odl doctor " + \
            "promise policy-test odl-vpn_service-tests vims rally "
        self.assertEqual(test, expected_list)

    def tearDown(self):
        os.environ["INSTALLER_TYPE"] = ""
        os.environ["DEPLOY_SCENARIO"] = ""


if __name__ == '__main__':
    unittest.main()