Merge "Documentation for unit test project"
[functest.git] / functest / opnfv_tests / openstack / snaps / smoke.py
1 # Copyright (c) 2015 All rights reserved
2 # This program and the accompanying materials
3 # are made available under the terms of the Apache License, Version 2.0
4 # which accompanies this distribution, and is available at
5 #
6 # http://www.apache.org/licenses/LICENSE-2.0
7
8 import os
9 import unittest
10
11 from snaps import test_suite_builder
12
13 from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
14     SnapsTestRunner
15 from functest.utils.constants import CONST
16
17
18 class SnapsSmoke(SnapsTestRunner):
19     """
20     This test executes the Python Tests included with the SNAPS libraries
21     that exercise many of the OpenStack APIs within Keystone, Glance, Neutron,
22     and Nova
23     """
24     def __init__(self, **kwargs):
25         if "case_name" not in kwargs:
26             kwargs["case_name"] = "snaps_smoke"
27         super(SnapsSmoke, self).__init__(**kwargs)
28
29         self.suite = unittest.TestSuite()
30
31         image_config = None
32         if hasattr(CONST, 'snaps_images_cirros'):
33             image_config = CONST.__getattribute__('snaps_images_cirros')
34
35         # Tests requiring floating IPs leverage files contained within the
36         # SNAPS repository and are found relative to that path
37         if self.use_fip:
38             snaps_dir = os.path.join(CONST.__getattribute__('dir_repo_snaps'),
39                                      'snaps')
40             os.chdir(snaps_dir)
41
42         test_suite_builder.add_openstack_integration_tests(
43             suite=self.suite,
44             os_creds=self.os_creds,
45             ext_net_name=self.ext_net_name,
46             use_keystone=self.use_keystone,
47             flavor_metadata=self.flavor_metadata,
48             image_metadata=image_config,
49             use_floating_ips=self.use_fip)