1 ##############################################################################
2 # Copyright (c) 2016 Dan Radez (Red Hat)
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
12 from nose.tools import (
17 from apex import Inventory
18 from apex.inventory.inventory import InventoryException
19 from apex.tests.constants import (
24 inventory_files = ('intel_pod2_settings.yaml',
25 'nokia_pod1_settings.yaml',
26 'pod_example_settings.yaml')
28 files_dir = os.path.join(TEST_CONFIG_DIR, 'inventory')
34 """This method is run once for each class before any tests are run"""
37 def teardown_class(cls):
38 """This method is run once for each class _after_ all tests are run"""
41 """This method is run once before _each_ test method is executed"""
44 """This method is run once after _each_ test method is executed"""
46 def test_inventory_baremetal(self):
47 for f in inventory_files:
48 i = Inventory(os.path.join(files_dir, f))
49 assert_equal(i.dump_instackenv_json(), None)
51 def test_inventory_invalid_ha_count(self):
52 assert_raises(InventoryException, Inventory,
53 os.path.join(TEST_DUMMY_CONFIG, 'inventory-virt.yaml'),
54 virtual=True, ha=True)
56 def test_inventory_invalid_noha_count(self):
57 assert_raises(InventoryException, Inventory,
58 os.path.join(TEST_DUMMY_CONFIG,
59 'inventory-virt-1-node.yaml'),
60 virtual=True, ha=False)
62 def test_inventory_virtual(self):
63 i = Inventory(os.path.join(TEST_DUMMY_CONFIG, 'inventory-virt.yaml'),
64 virtual=True, ha=False)
65 assert_equal(i.dump_instackenv_json(), None)
67 def test_exception(self):
68 e = InventoryException("test")
70 assert_is_instance(e, InventoryException)