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

Testinterface_switchport_pvlan_mapping   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_action() 0 21 1
1
import xml.etree.ElementTree as ET
2
from st2tests.base import BaseActionTestCase
3
4
from interface_switchport_pvlan_mapping import interface_switchport_pvlan_mapping
5
6
__all__ = [
7
    'Testinterface_switchport_pvlan_mapping'
8
]
9
10
11
class MockCallback(object):
12
    returned_data = None
13
14
    def callback(self, call, **kwargs):
15
        xml_result = ET.tostring(call)
16
        self.returned_data = xml_result
17
18
19
class Testinterface_switchport_pvlan_mapping(BaseActionTestCase):
20
    action_cls = interface_switchport_pvlan_mapping
21
22
    def test_action(self):
23
        action = self.get_action_instance()
24
        mock_callback = MockCallback()
25
        kwargs = {
26
            'username': '',
27
            'sec_vlan': '10',
28
            'name': '10/0/2',
29
            'pri_vlan': '20',
30
            'int_type': 'tengigabitethernet',
31
            'ip': '',
32
            'password': '',
33
            'port': '22',
34
            'test': True,
35
            'callback': mock_callback.callback
36
        }
37
38
        action.run(**kwargs)
39
40
        expected_xml = """<config><interface xmlns="urn:brocade.com:mgmt:brocade-interface"><gigabitethernet><name>10/0/2</name><switchport><private-vlan><mapping><promis-pri-pvlan>20</promis-pri-pvlan><promis-sec-pvlan-range>10</promis-sec-pvlan-range></mapping></private-vlan></switchport></gigabitethernet></interface></config>"""
41
42
        self.assertTrue(expected_xml, mock_callback.returned_data)
43