Completed
Pull Request — master (#543)
by
unknown
10:49
created

TestInterfaceDelAccessVlan   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B test_action() 0 27 1
1
"""Generated test for checking pynos based actions
2
"""
3
import xml.etree.ElementTree as ET
4
from st2tests.base import BaseActionTestCase
5
from interface_del_access_vlan import interface_del_access_vlan
6
7
__all__ = [
8
    'TestInterfaceDelAccessVlan'
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 TestInterfaceDelAccessVlan(BaseActionTestCase):
25
    """Test holder class
26
    """
27
    action_cls = interface_del_access_vlan
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
            'username': '',
36
            'password': '',
37
            'inter_type': 'tengigabitethernet',
38
            'ip': '',
39
            'inter': '10/0/1',
40
            'port': '22',
41
            'vlan_id': '44',
42
            'test': True,
43
            'callback': mock_callback.callback
44
        }
45
46
        action.run(**kwargs)
47
48
        expected_xml = (
49
            '<config><interface xmlns="urn:brocade.com:mgmt:brocade-interface"'
50
            '><tengigabitethernet><name>10/0/1</name><switchport><access><acce'
51
            'ssvlan operation="delete">44</accessvlan></access></switchport></'
52
            'tengigabitethernet></interface></config>'
53
        )
54
55
        self.assertTrue(expected_xml, mock_callback.returned_data)
56