summaryrefslogtreecommitdiffstats
path: root/testcases/tests/TestFunctestUtils.py
blob: e1f81ecdfe2927e58fb2e8ff8350d68a9e10cdac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/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()