Debian Codegraph @

tests/test_81_dnsviz_probe_run_online.py

raw symbols SCIP
1 import io
2 import os
3 import platform
4 import subprocess
5 import tempfile
6 import unittest
7
8 class DNSVizProbeRunOnlineTestCase(unittest.TestCase):
9 def setUp(self):
10 self.current_cwd = os.getcwd()
11
12 self.output = tempfile.NamedTemporaryFile('wb', prefix='dnsviz', delete=False)
13 self.output.close()
14
15 def tearDown(self):
16 os.remove(self.output.name)
17
18 def assertReturnCode(self, retcode):
19 if retcode == 5:
20 self.skipTest("No recursive resolves found nor given")
21 else:
22 self.assertEqual(retcode, 0)
23
24 def test_dnsviz_probe_auth(self):
25 with io.open(self.output.name, 'wb') as fh:
26 self.assertReturnCode(subprocess.call(['dnsviz', 'probe', '-d', '0', '-A', '.'], stdout=fh))
27
28 with io.open(self.output.name, 'wb') as fh:
29 self.assertReturnCode(subprocess.call(['dnsviz', 'probe', '-d', '0', '-A', 'example.com'], stdout=fh))
30
31 def test_dnsviz_probe_rec(self):
32 with io.open(self.output.name, 'wb') as fh:
33 self.assertReturnCode(subprocess.call(['dnsviz', 'probe', '-d', '0', '.'], stdout=fh))
34
35 with io.open(self.output.name, 'wb') as fh:
36 self.assertReturnCode(subprocess.call(['dnsviz', 'probe', '-d', '0', 'example.com'], stdout=fh))
37
38 def test_dnsviz_probe_rec_multi(self):
39 if platform.system().lower() == 'darwin':
40 # Skip MacOS
41 return
42 with io.open(self.output.name, 'wb') as fh:
43 self.assertReturnCode(subprocess.call(['dnsviz', 'probe', '-d', '0', '-t', '3', '.', 'example.com', 'example.net'], stdout=fh))
44
45 if __name__ == '__main__':
46 unittest.main()