From dac00d17ff9f3d2bb959697b6e567015bfc2702b Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sat, 30 May 2020 20:33:50 -0700 Subject: [PATCH] add nixos test --- tests/fixtures/nixos/route-ee.json | 1 + tests/fixtures/nixos/route-ee.out | 4 ++++ tests/test_route.py | 12 ++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 tests/fixtures/nixos/route-ee.json create mode 100644 tests/fixtures/nixos/route-ee.out diff --git a/tests/fixtures/nixos/route-ee.json b/tests/fixtures/nixos/route-ee.json new file mode 100644 index 00000000..a65a9417 --- /dev/null +++ b/tests/fixtures/nixos/route-ee.json @@ -0,0 +1 @@ +[{"destination": "default", "gateway": "_gateway", "genmask": "0.0.0.0", "flags": "UG", "metric": 202, "ref": 0, "use": 0, "iface": "ens33", "mss": 0, "window": 0, "irtt": 0, "flags_pretty": ["UP", "GATEWAY"]}, {"destination": "192.168.71.0", "gateway": "0.0.0.0", "genmask": "255.255.255.0", "flags": "U", "metric": 202, "ref": 0, "use": 0, "iface": "ens33", "mss": 0, "window": 0, "irtt": 0, "flags_pretty": ["UP"]}] diff --git a/tests/fixtures/nixos/route-ee.out b/tests/fixtures/nixos/route-ee.out new file mode 100644 index 00000000..78f02a9d --- /dev/null +++ b/tests/fixtures/nixos/route-ee.out @@ -0,0 +1,4 @@ +Kernel IP routing table +Destination Gateway Genmask Flags Metric Ref Use Iface MSS Window irtt +default _gateway 0.0.0.0 UG 202 0 0 ens33 0 0 0 +192.168.71.0 0.0.0.0 255.255.255.0 U 202 0 0 ens33 0 0 0 diff --git a/tests/test_route.py b/tests/test_route.py index d757e466..2ad87a49 100644 --- a/tests/test_route.py +++ b/tests/test_route.py @@ -22,6 +22,9 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/route-vn.out'), 'r', encoding='utf-8') as f: self.ubuntu_18_4_route_vn = f.read() + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/nixos/route-ee.out'), 'r', encoding='utf-8') as f: + self.nixos_route_ee = f.read() + # output with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route.json'), 'r', encoding='utf-8') as f: self.centos_7_7_route_json = json.loads(f.read()) @@ -35,6 +38,9 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/route-vn.json'), 'r', encoding='utf-8') as f: self.ubuntu_18_4_route_vn_json = json.loads(f.read()) + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/nixos/route-ee.json'), 'r', encoding='utf-8') as f: + self.nixos_route_ee_json = json.loads(f.read()) + def test_route_centos_7_7(self): """ Test 'route' on Centos 7.7 @@ -59,6 +65,12 @@ class MyTests(unittest.TestCase): """ self.assertEqual(jc.parsers.route.parse(self.ubuntu_18_4_route_vn, quiet=True), self.ubuntu_18_4_route_vn_json) + def test_route_ee_nixos(self): + """ + Test 'route -ee' on NixOS + """ + self.assertEqual(jc.parsers.route.parse(self.nixos_route_ee, quiet=True), self.nixos_route_ee_json) + if __name__ == '__main__': unittest.main()