aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit/vnf/ims/test_clearwater.py
blob: 18bebfdff54460367139110dcb69147f35da94e7 (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
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Gener
#!/usr/bin/env python

# 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 logging
import unittest

import mock

from functest.opnfv_tests.vnf.ims import clearwater
from functest.opnfv_tests.vnf.ims import orchestrator_cloudify


class ClearwaterTesting(unittest.TestCase):

    logging.disable(logging.CRITICAL)

    def setUp(self):
        self.clearwater = clearwater.Clearwater()
        self.orchestrator = orchestrator_cloudify.Orchestrator('test_dir')
        self.clearwater.orchestrator = self.orchestrator
        self.clearwater.dep_name = 'test_dep_name'
        self.bp = {'file_name': 'test_file',
                   'destination_folder': 'test_folder',
                   'url': 'test_url',
                   'branch': 'test_branch'}

    def test_deploy_vnf_blueprint_download_failed(self):
        with mock.patch.object(self.clearwater.orchestrator,
                               'download_upload_and_deploy_blueprint',
                               return_value='error'):
            self.assertEqual(self.clearwater.deploy_vnf(self.bp),
                             'error')

    def test_deploy_vnf_blueprint_download_passed(self):
        with mock.patch.object(self.clearwater.orchestrator,
                               'download_upload_and_deploy_blueprint',
                               return_value=''):
            self.clearwater.deploy_vnf(self.bp)
            self.assertEqual(self.clearwater.deploy, True)

    def test_undeploy_vnf_deployment_passed(self):
        with mock.patch.object(self.clearwater.orchestrator,
                               'undeploy_deployment'):
            self.clearwater.deploy = True
            self.clearwater.undeploy_vnf()
            self.assertEqual(self.clearwater.deploy, False)

    def test_undeploy_vnf_deployment_with_undeploy(self):
        with mock.patch.object(self.clearwater.orchestrator,
                               'undeploy_deployment') as m:
            self.clearwater.deploy = False
            self.clearwater.undeploy_vnf(),
            self.assertEqual(self.clearwater.deploy, False)
            self.assertFalse(m.called)

            self.clearwater.orchestrator = None
            self.clearwater.deploy = True
            self.clearwater.undeploy_vnf(),
            self.assertEqual(self.clearwater.deploy, True)

            self.clearwater.deploy = False
            self.clearwater.undeploy_vnf(),
            self.assertEqual(self.clearwater.deploy, False)

    def test_set_methods(self):
        self.clearwater.set_orchestrator(self.orchestrator)
        self.assertTrue(self.clearwater.orchestrator, self.orchestrator)
        self.clearwater.set_flavor_id('test_flavor_id')
        self.assertTrue(self.clearwater.config['flavor_id'], 'test_flavor_id')
        self.clearwater.set_image_id('test_image_id')
        self.assertTrue(self.clearwater.config['image_id'], 'test_image_id')
        self.clearwater.set_agent_user('test_user')
        self.assertTrue(self.clearwater.config['agent_user'], 'test_user')
        self.clearwater.set_external_network_name('test_network')
        self.assertTrue(self.clearwater.config['external_network_name'],
                        'test_network')
        self.clearwater.set_public_domain('test_domain')
        self.assertTrue(self.clearwater.config['public_domain'],
                        'test_domain')

if __name__ == "__main__":
    unittest.main(verbosity=2)
r Laza' link: 'http://meetbot.opnfv.org/meetings/opnfv-meeting/2016/opnfv-meeting.2016-02-16-14.59.html' - type: 'promotion' name: 'Mei Mei' link: 'http://lists.opnfv.org/pipermail/opnfv-tsc/2016-March/002228.html' - type: 'removal' name: 'Peter Banzi' link: '' - type: 'promotion' name: 'Trevor Bramwell' link: 'http://lists.opnfv.org/pipermail/opnfv-tech-discuss/2016-July/011659.html' - type: 'promotion' name: 'Serena Feng' link: '' - type: 'promotion' name: 'Yolanda Robla Mota' link: '' - type: 'promotion' name: 'Markos' link: '' - type: 'promotion' name: 'Luke Hinds' link: '' - type: 'promotion' name: 'Alexandru Avadanii' link: 'https://gerrit.opnfv.org/gerrit/#/c/64499/'