forked from rdmcgregor/conf2yaml
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
62 lines (54 loc) · 3.38 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import unittest
from conf2yaml import convert_to_yaml
from uciparse import uci
from pyfakefs import fake_filesystem_unittest
from test_data import *
class test_suite(unittest.TestCase):
def test_firwall_1(self):
lines = test_firewall_1["input"].split("\n")
self.assertEqual( test_firewall_1["output"],convert_to_yaml(uci.UciFile.from_lines(lines)))
def test_firewall_2(self):
lines = test_firewall_2["input"].split("\n")
self.assertEqual( test_firewall_2["output"],convert_to_yaml(uci.UciFile.from_lines(lines)))
def test_firewall_1_with_list(self):
lines = test_firewall_1_with_list["input"].split("\n")
self.assertEqual(test_firewall_1_with_list["output"], convert_to_yaml(uci.UciFile.from_lines(lines)))
def test_firewall_3_with_comment(self):
lines = test_firewall_3_with_comment["input"].split("\n")
self.assertEqual(test_firewall_3_with_comment["output"], convert_to_yaml(uci.UciFile.from_lines(lines)))
# def test_interface_cdp_status(self):
def test_firewall_4_network_named(self):
lines = test_firewall_4_network_named["input"].split("\n")
self.assertEqual(test_firewall_4_network_named["output"], convert_to_yaml(uci.UciFile.from_lines(lines)))
def test_beardropper(self):
lines = test_beardropper["input"].split("\n")
self.assertEqual(test_beardropper["output"], convert_to_yaml(uci.UciFile.from_lines(lines)))
# with fake_filesystem_unittest.Patcher() as patcher:
# patcher.fs.create_file('/mock', contents=test_interface_cdp_status["input"])
# self.assertEqual(convert_to_yaml(CiscoConfParse('/mock')), test_interface_cdp_status["output"])
# def test_interface_switchport_access_vlan(self):
# with fake_filesystem_unittest.Patcher() as patcher:
# patcher.fs.create_file('/mock', contents=test_interface_switchport_access_vlan["input"])
# self.assertEqual(convert_to_yaml(CiscoConfParse('/mock')), test_interface_switchport_access_vlan["output"])
#
# def test_interface_switchport_mode(self):
# with fake_filesystem_unittest.Patcher() as patcher:
# patcher.fs.create_file('/mock', contents=test_interface_switchport_mode["input"])
# self.assertEqual(convert_to_yaml(CiscoConfParse('/mock')), test_interface_switchport_mode["output"])
#
# def test_interface_switchport_port_security(self):
# with fake_filesystem_unittest.Patcher() as patcher:
# patcher.fs.create_file('/mock', contents=test_interface_switchport_port_security["input"])
# self.assertEqual(convert_to_yaml(CiscoConfParse('/mock')), test_interface_switchport_port_security["output"])
#
# def test_interface_power_inline_police(self):
# with fake_filesystem_unittest.Patcher() as patcher:
# patcher.fs.create_file('/mock', contents=test_interface_power_inline_police["input"])
# self.assertEqual(convert_to_yaml(CiscoConfParse('/mock')), test_interface_power_inline_police["output"])
#
# def test_interface_spanning_tree(self):
# with fake_filesystem_unittest.Patcher() as patcher:
# patcher.fs.create_file('/mock', contents=test_interface_spanning_tree["input"])
# self.assertEqual(convert_to_yaml(CiscoConfParse('/mock')), test_interface_spanning_tree["output"])
if __name__ == '__main__':
unittest.main()