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 ##############################################################################
10 from apex.inventory import Inventory
11 from apex.inventory import InventoryException
13 from nose.tools import assert_is_instance
14 from nose.tools import assert_raises
15 from nose.tools import assert_equal
17 inventory_files = ('intel_pod2_settings.yaml',
18 'nokia_pod1_settings.yaml',
19 'pod_example_settings.yaml')
22 class TestInventory(object):
24 def setup_class(klass):
25 """This method is run once for each class before any tests are run"""
28 def teardown_class(klass):
29 """This method is run once for each class _after_ all tests are run"""
32 """This method is run once before _each_ test method is executed"""
35 """This method is run once after _each_ test method is executed"""
38 for f in inventory_files:
39 i = Inventory('../config/inventory/{}'.format(f))
40 assert_equal(i.dump_instackenv_json(), None)
43 i = Inventory(i, virtual=True)
44 assert_equal(i.dump_instackenv_json(), None)
46 # Remove nodes to violate HA node count
47 while len(i['nodes']) >= 5:
49 assert_raises(InventoryException,
52 # Remove nodes to violate non-HA node count
53 while len(i['nodes']) >= 2:
55 assert_raises(InventoryException,
56 Inventory, i, ha=False)
58 def test_exception(sefl):
59 e = InventoryException("test")
61 assert_is_instance(e, InventoryException)