Adds parser tests and cleanup
[apex.git] / apex / tests / test_apex_clean.py
1 ##############################################################################
2 # Copyright (c) 2016 Tim Rozet (Red Hat)
3 #
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 ##############################################################################
9
10 import mock
11 import pyipmi
12 import pyipmi.chassis
13 from mock import patch
14 from nose import tools
15
16 from apex import clean_nodes
17
18
19 class TestClean:
20     @classmethod
21     def setup_class(cls):
22         """This method is run once for each class before any tests are run"""
23
24     @classmethod
25     def teardown_class(cls):
26         """This method is run once for each class _after_ all tests are run"""
27
28     def setup(self):
29         """This method is run once before _each_ test method is executed"""
30
31     def teardown(self):
32         """This method is run once after _each_ test method is executed"""
33
34     def test_clean(self):
35         with mock.patch.object(pyipmi.Session, 'establish') as mock_method:
36             with patch.object(pyipmi.chassis.Chassis,
37                               'chassis_control_power_down') as mock_method2:
38                 clean_nodes('apex/tests/config/inventory.yaml')
39
40         tools.assert_equal(mock_method.call_count, 5)
41         tools.assert_equal(mock_method2.call_count, 5)