|
1
|
|
|
"""Generated test for checking pynos based actions |
|
2
|
|
|
""" |
|
3
|
|
|
import xml.etree.ElementTree as ET |
|
4
|
|
|
from st2tests.base import BaseActionTestCase |
|
5
|
|
|
from bgp_update_source import bgp_update_source |
|
6
|
|
|
|
|
7
|
|
|
__all__ = [ |
|
8
|
|
|
'TestBgpUpdateSource' |
|
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 TestBgpUpdateSource(BaseActionTestCase): |
|
25
|
|
|
"""Test holder class |
|
26
|
|
|
""" |
|
27
|
|
|
action_cls = bgp_update_source |
|
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
|
|
|
'int_name': '1', |
|
37
|
|
|
'neighbor': '10.2.1.4', |
|
38
|
|
|
'get': False, |
|
39
|
|
|
'ip': '', |
|
40
|
|
|
'vrf': 'test', |
|
41
|
|
|
'int_type': 'tengigabitethernet', |
|
42
|
|
|
'password': '', |
|
43
|
|
|
'port': '22', |
|
44
|
|
|
'rbridge_id': '224', |
|
45
|
|
|
'test': True, |
|
46
|
|
|
'callback': mock_callback.callback |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
action.run(**kwargs) |
|
50
|
|
|
|
|
51
|
|
|
expected_xml = ( |
|
52
|
|
|
'<config><rbridge-id xmlns="urn:brocade.com:mgmt:brocade-rbridge">' |
|
53
|
|
|
'<rbridge-id>224</rbridge-id><router><bgp xmlns="urn:brocade.com:m' |
|
54
|
|
|
'gmt:brocade-bgp"><vrf-name>test</vrf-name><router-bgp-cmds-holder' |
|
55
|
|
|
'><router-bgp-attributes><neighbor-ips><neighbor-addr><router-bgp-' |
|
56
|
|
|
'neighbor-address>10.2.1.4</router-bgp-neighbor-address><update-so' |
|
57
|
|
|
'urce><loopback>1</loopback></update-source></neighbor-addr></neig' |
|
58
|
|
|
'hbor-ips></router-bgp-attributes></router-bgp-cmds-holder></bgp><' |
|
59
|
|
|
'/router></rbridge-id></config>' |
|
60
|
|
|
) |
|
61
|
|
|
|
|
62
|
|
|
self.assertTrue(expected_xml, mock_callback.returned_data) |
|
63
|
|
|
|