cleanup
This commit is contained in:
48
dnsverify_tests.py
Normal file
48
dnsverify_tests.py
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/bin/env python
|
||||
|
||||
'''
|
||||
Unit tests for dnsverify
|
||||
'''
|
||||
|
||||
import unittest
|
||||
|
||||
from dnsverify import do_check
|
||||
from dnsverify import get_authoritative_ns
|
||||
from dnsverify import get_domains_from_yaml
|
||||
from dnsverify import verify_authoritative_ns
|
||||
from pylint.lint import Run
|
||||
from pylint.reporters import CollectingReporter
|
||||
|
||||
class TestDnsVerify(unittest.TestCase):
|
||||
def test_do_check(self):
|
||||
'''
|
||||
... Test whether checks acutally fail when an error occures.
|
||||
'''
|
||||
self.assertEqual(do_check(['puzzle.ch'], ['ns1.google.com'], verbose=False),
|
||||
False)
|
||||
def test_get_authoritative_ns(self):
|
||||
'''
|
||||
... Test whether garbage queries trigger a stack trace.
|
||||
'''
|
||||
self.assertEqual(get_authoritative_ns('dinimer.lolwas'), [])
|
||||
def test_get_domains_from_yaml(self):
|
||||
'''
|
||||
... Test whether missing files generate an empty list.
|
||||
'''
|
||||
self.assertEqual(get_domains_from_yaml(["notexist.yaml"]), [])
|
||||
def test_verify_authoritative_ns(self):
|
||||
'''
|
||||
... Test whether false if check fails and test if type errors are handeled correctly.
|
||||
'''
|
||||
self.assertEqual(verify_authoritative_ns('ns1.google.com', ['ns2.google.com']), False)
|
||||
self.assertRaises(TypeError, verify_authoritative_ns, 123, ['123'])
|
||||
self.assertRaises(TypeError, verify_authoritative_ns, "123", "123")
|
||||
|
||||
def test_pylint(self):
|
||||
'''
|
||||
... Test whether the coding style is acceptable.
|
||||
'''
|
||||
rep = CollectingReporter()
|
||||
results = Run(['dnsverify.py', '-sn'], reporter=rep, exit=False)
|
||||
score = results.linter.stats['global_note']
|
||||
self.assertGreaterEqual(score, 8, "Pylint score to low. Fix your code.")
|
||||
Reference in New Issue
Block a user