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 ApexInventoryException
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)
50 i['nodes'][0]['arch'] = 'aarch64'
52 assert_equal(i['nodes'][0]['arch'], 'aarch64')
54 def test_inventory_invalid_ha_count(self):
55 assert_raises(ApexInventoryException, Inventory,
56 os.path.join(TEST_DUMMY_CONFIG, 'inventory-virt.yaml'),
57 virtual=True, ha=True)
59 def test_inventory_invalid_noha_count(self):
60 assert_raises(ApexInventoryException, Inventory,
61 os.path.join(TEST_DUMMY_CONFIG,
62 'inventory-virt-1-node.yaml'),
63 virtual=True, ha=False)
65 def test_inventory_virtual(self):
66 i = Inventory(os.path.join(TEST_DUMMY_CONFIG, 'inventory-virt.yaml'),
67 virtual=True, ha=False)
68 assert_equal(i.dump_instackenv_json(), None)
70 def test_get_node_counts(self):
71 i = Inventory(os.path.join(TEST_DUMMY_CONFIG, 'inventory-virt.yaml'),
72 virtual=True, ha=False)
73 assert_equal(i.get_node_counts(), (1, 1))