Completed
Pull Request — master (#543)
by
unknown
03:05
created

TestSystemRouterId.test_action()   B

Complexity

Conditions 1

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
dl 0
loc 26
rs 8.8571
c 1
b 0
f 0
1
"""Generated test for checking pynos based actions
2
"""
3
import xml.etree.ElementTree as ET
4
from st2tests.base import BaseActionTestCase
5
from system_router_id import system_router_id
6
7
__all__ = [
8
    'TestSystemRouterId'
9
]
10
11
12
class MockCallback(object):  # pylint:disable=too-few-public-methods
13
    """Class to hold mock callback and result
14
    """
15
    returned_data = None
16
17
    def callback(self, call, **kwargs):  # pylint:disable=unused-argument
18
        """Mock callback method
19
        """
20
        xml_result = ET.tostring(call)
21
        self.returned_data = xml_result
22
23
24
class TestSystemRouterId(BaseActionTestCase):
25
    """Test holder class
26
    """
27
    action_cls = system_router_id
28
29
    def test_action(self):
30
        """Generated test to check action
31
        """
32
        action = self.get_action_instance()
33
        mock_callback = MockCallback()
34
        kwargs = {
35
            'router_id': '4',
36
            'username': '',
37
            'rbridge_id': '224',
38
            'ip': '',
39
            'password': '',
40
            'port': '22',
41
            'test': True,
42
            'callback': mock_callback.callback
43
        }
44
45
        action.run(**kwargs)
46
47
        expected_xml = (
48
            '<config><rbridge-id xmlns="urn:brocade.com:mgmt:brocade-rbridge">'
49
            '<rbridge-id>224</rbridge-id><ip><rtm-config xmlns="urn:brocade.co'
50
            'm:mgmt:brocade-rtm"><router-id>4</router-id></rtm-config></ip></r'
51
            'bridge-id></config>'
52
        )
53
54
        self.assertTrue(expected_xml, mock_callback.returned_data)
55