Debian Codegraph @

tests/unit/ofacts/test_switch_style.py

raw
1 __author__ = "Nitin Kumar, Rick Sherman"
2 __credits__ = "Jeremy Schulman"
3
4 import unittest
5 from unittest.mock import patch
6 import nose2
7
8 from jnpr.junos import Device
9 from jnpr.junos.ofacts.switch_style import facts_switch_style as switch_style
10
11
12 class TestSwitchStyle(unittest.TestCase):
13 @patch("jnpr.junos.device.warnings")
14 def setUp(self, mock_warnings):
15 self.facts = {}
16 self.dev = Device(
17 host="1.1.1.1",
18 user="rick",
19 password="password123",
20 gather_facts=False,
21 fact_style="old",
22 )
23
24 def test_switch_style_mx_srx(self):
25 self.facts["personality"] = "SRX_HIGHEND"
26 switch_style(self.dev, self.facts)
27 self.assertEqual(self.facts["switch_style"], "BRIDGE_DOMAIN")
28
29 def test_switch_style_model_firefly(self):
30 self.facts["personality"] = "SWITCH"
31 self.facts["model"] = "FIReFly"
32 switch_style(self.dev, self.facts)
33 self.assertEqual(self.facts["switch_style"], "NONE")
34
35 def test_switch_style_model_ex9000(self):
36 self.facts["personality"] = "SWITCH"
37 self.facts["model"] = "EX9000"
38 switch_style(self.dev, self.facts)
39 self.assertEqual(self.facts["switch_style"], "VLAN_L2NG")
40
41 def test_switch_style_model_not_specific(self):
42 self.facts["personality"] = "SWITCH"
43 self.facts["model"] = "abc"
44 switch_style(self.dev, self.facts)
45 self.assertEqual(self.facts["switch_style"], "VLAN")
46
47 def test_switch_style_persona_not_specific(self):
48 self.facts["personality"] = "PTX"
49 self.facts["model"] = "abc"
50 switch_style(self.dev, self.facts)
51 self.assertEqual(self.facts["switch_style"], "NONE")