diff options
author | Casey Deccio <casey@deccio.net> | 2019-01-12 08:02:58 +0300 |
---|---|---|
committer | Casey Deccio <casey@deccio.net> | 2019-01-15 06:09:43 +0300 |
commit | 3024f1cc01c2b899c687a98f79862da13dd954d1 (patch) | |
tree | 8d940d611066f8e1e7dc3ea45ee477ae0c8d9ee1 /tests | |
parent | ddf1a06602aa7b02acbbd550cd53a760e2af0e32 (diff) |
Define common names at top
Diffstat (limited to 'tests')
-rw-r--r-- | tests/offline_tests.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/tests/offline_tests.py b/tests/offline_tests.py index 74bed2e..4ce1525 100644 --- a/tests/offline_tests.py +++ b/tests/offline_tests.py @@ -4,6 +4,12 @@ import os import subprocess import unittest +DATA_DIR = os.path.dirname(__file__) +EXAMPLE_AUTHORITATIVE = os.path.join(DATA_DIR, 'data', 'example-authoritative.json.gz') +EXAMPLE_RECURSIVE = os.path.join(DATA_DIR, 'data', 'example-recursive.json.gz') +ROOT_AUTHORITATIVE = os.path.join(DATA_DIR, 'data', 'root-authoritative.json.gz') +ROOT_RECURSIVE = os.path.join(DATA_DIR, 'data', 'root-recursive.json.gz') + class DNSGrokTestCase(unittest.TestCase): def setUp(self): self.devnull = io.open('/dev/null', 'wb') @@ -12,25 +18,25 @@ class DNSGrokTestCase(unittest.TestCase): self.devnull.close() def test_grok_root_authoritative(self): - with gzip.open('%s/data/root-authoritative.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(ROOT_AUTHORITATIVE) as fh: p = subprocess.Popen(['dnsviz', 'grok'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) def test_grok_root_recursive(self): - with gzip.open('%s/data/root-recursive.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(ROOT_RECURSIVE) as fh: p = subprocess.Popen(['dnsviz', 'grok'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) def test_grok_example_authoritative(self): - with gzip.open('%s/data/example-authoritative.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(EXAMPLE_AUTHORITATIVE) as fh: p = subprocess.Popen(['dnsviz', 'grok'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) def test_grok_example_recursive(self): - with gzip.open('%s/data/example-recursive.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(EXAMPLE_RECURSIVE) as fh: p = subprocess.Popen(['dnsviz', 'grok'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) @@ -43,25 +49,25 @@ class DNSPrintTestCase(unittest.TestCase): self.devnull.close() def test_print_root_authoritative(self): - with gzip.open('%s/data/root-authoritative.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(ROOT_AUTHORITATIVE) as fh: p = subprocess.Popen(['dnsviz', 'print'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) def test_print_root_recursive(self): - with gzip.open('%s/data/root-recursive.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(ROOT_RECURSIVE) as fh: p = subprocess.Popen(['dnsviz', 'print'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) def test_print_example_authoritative(self): - with gzip.open('%s/data/example-authoritative.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(EXAMPLE_AUTHORITATIVE) as fh: p = subprocess.Popen(['dnsviz', 'print'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) def test_print_example_recursive(self): - with gzip.open('%s/data/example-recursive.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(EXAMPLE_RECURSIVE) as fh: p = subprocess.Popen(['dnsviz', 'print'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) @@ -74,25 +80,25 @@ class DNSGraphTestCase(unittest.TestCase): self.devnull.close() def test_graph_root_authoritative(self): - with gzip.open('%s/data/root-authoritative.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(ROOT_AUTHORITATIVE) as fh: p = subprocess.Popen(['dnsviz', 'graph', '-Thtml'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) def test_graph_root_recursive(self): - with gzip.open('%s/data/root-recursive.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(ROOT_RECURSIVE) as fh: p = subprocess.Popen(['dnsviz', 'graph', '-Thtml'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) def test_graph_example_authoritative(self): - with gzip.open('%s/data/example-authoritative.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(EXAMPLE_AUTHORITATIVE) as fh: p = subprocess.Popen(['dnsviz', 'graph', '-Thtml'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) def test_graph_example_recursive(self): - with gzip.open('%s/data/example-recursive.json.gz' % os.path.dirname(__file__)) as fh: + with gzip.open(EXAMPLE_RECURSIVE) as fh: p = subprocess.Popen(['dnsviz', 'graph', '-Thtml'], stdin=subprocess.PIPE, stdout=self.devnull) p.communicate(input=fh.read()) self.assertEqual(p.returncode, 0) |