def test_11_main(self): stub_stdin(self, 'not_a_prefix\n2001:db8::/32\n2001:db8::/128\n10.0.0.0/8\n10.1.2.3/32') stub_stdouts(self) with patch.object(sys, 'argv', ["prog.py", "-4"]): agg_main() self.assertEqual(sys.stdout.getvalue(), '10.0.0.0/8\n') self.assertEqual(sys.stderr.getvalue(), "ERROR: 'not_a_prefix' is not a valid IP network, ignoring.\n")
def test_10__main(self): stub_stdin(self, '2001:db8::/32\n2001:db8::/128\n10.0.0.0/8\n') stub_stdouts(self) with patch.object(sys, 'argv', ["prog.py", "-6"]): agg_main() self.assertEqual(sys.stdout.getvalue(), '2001:db8::/32\n')
def test_09__main(self): stub_stdin(self, '1.1.1.24/29\n1.1.1.0/24\n1.1.1.1/32\n1.1.0.0/24\n\n') stub_stdouts(self) with patch.object(sys, 'argv', [""]): agg_main() self.assertEqual(sys.stdout.getvalue(), '1.1.0.0/23\n')
def test_13_truncate(self): stub_stdin(self, '2001:db8::1/32 2001:db9::1/32\n10.5.5.5/8\n') stub_stdouts(self) with patch.object(sys, 'argv', ["prog.py", "-t"]): agg_main() self.assertEqual(sys.stdout.getvalue(), '10.0.0.0/8\n2001:db8::/31\n')
def test_15_verbose(self): stub_stdin(self, '10.0.0.0/24 10.0.1.0/24 172.16.0.0/24 10.0.0.0/32\n') stub_stdouts(self) with patch.object(sys, 'argv', ["prog.py", "-v"]): agg_main() self.assertEqual(sys.stdout.getvalue(), "+ 10.0.0.0/23\n- 10.0.0.0/24\n- 10.0.0.0/32\n- 10.0.1.0/24\n 172.16.0.0/24\n")
def test_14_maxlength(self): stub_stdin(self, '10.0.0.0/24 10.0.1.0/25 10.0.1.128/25\n') stub_stdouts(self) with patch.object(sys, 'argv', ["prog.py", "-m", "24"]): agg_main() self.assertEqual(sys.stdout.getvalue(), '10.0.0.0/24\n')