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 TEST_CONFIG_DIR
21 inventory_files = ('intel_pod2_settings.yaml',
22 'nokia_pod1_settings.yaml',
23 'pod_example_settings.yaml')
25 files_dir = os.path.join(TEST_CONFIG_DIR, 'inventory')
31 """This method is run once for each class before any tests are run"""
34 def teardown_class(cls):
35 """This method is run once for each class _after_ all tests are run"""
38 """This method is run once before _each_ test method is executed"""
41 """This method is run once after _each_ test method is executed"""
44 for f in inventory_files:
45 i = Inventory(os.path.join(files_dir, f))
46 assert_equal(i.dump_instackenv_json(), None)
49 i = Inventory(i, virtual=True)
50 assert_equal(i.dump_instackenv_json(), None)
52 # Remove nodes to violate HA node count
53 while len(i['nodes']) >= 5:
55 assert_raises(InventoryException,
58 # Remove nodes to violate non-HA node count
59 while len(i['nodes']) >= 2:
61 assert_raises(InventoryException,
62 Inventory, i, ha=False)
64 def test_exception(self):
65 e = InventoryException("test")
67 assert_is_instance(e, InventoryException)