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

Testbgp_update_source   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_action() 0 23 1
1
import xml.etree.ElementTree as ET
2
from st2tests.base import BaseActionTestCase
3
4
from bgp_update_source import bgp_update_source
5
6
__all__ = [
7
    'Testbgp_update_source'
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 Testbgp_update_source(BaseActionTestCase):
20
    action_cls = bgp_update_source
21
22
    def test_action(self):
23
        action = self.get_action_instance()
24
        mock_callback = MockCallback()
25
        kwargs = {
26
            'username': '',
27
            'int_name': '1',
28
            'neighbor': '10.2.1.4',
29
            'get': 'False',
30
            'ip': '',
31
            'vrf': 'test',
32
            'int_type': 'tengigabitethernet',
33
            'password': '',
34
            'port': '22',
35
            'rbridge_id': '224',
36
            'test': True,
37
            'callback': mock_callback.callback
38
        }
39
40
        action.run(**kwargs)
41
42
        expected_xml = """<config><rbridge-id xmlns="urn:brocade.com:mgmt:brocade-rbridge"><rbridge-id>224</rbridge-id><router><bgp xmlns="urn:brocade.com:mgmt:brocade-bgp"><vrf-name>test</vrf-name><router-bgp-cmds-holder><router-bgp-attributes><neighbor-ips><neighbor-addr><router-bgp-neighbor-address>10.2.1.4</router-bgp-neighbor-address><update-source><loopback>1</loopback></update-source></neighbor-addr></neighbor-ips></router-bgp-attributes></router-bgp-cmds-holder></bgp></router></rbridge-id></config>"""
43
44
        self.assertTrue(expected_xml, mock_callback.returned_data)
45