-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve Coverage * Adding Actual Unit Test with basic test
- Loading branch information
Showing
2 changed files
with
82 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import subprocess | ||
|
||
status = {'OK': 0, 'WARNING': 1, 'CRITICAL': 2, 'UNKNOWN': 3} | ||
test_host = 'one.one.one.one' | ||
test_ipv4 = '1.1.1.1' | ||
test_ipv6 = '2606:4700:4700::1111' | ||
crit = 99 | ||
warn = 99 | ||
|
||
|
||
def test_no_options(): | ||
command = 'python check_rbl.py' | ||
result = subprocess.run(command.split()) | ||
assert result.returncode == status['UNKNOWN'] | ||
|
||
|
||
def test_len_options(): | ||
command = 'python check_rbl.py -w 99' | ||
result = subprocess.run(command.split()) | ||
assert result.returncode == status['UNKNOWN'] | ||
|
||
|
||
def test_host_and_ip(): | ||
command = f'python check_rbl.py -a {test_ipv4} -h {test_host}' | ||
result = subprocess.run(command.split()) | ||
assert result.returncode == status['UNKNOWN'] | ||
|
||
|
||
def test_ipv4_and_ipv6(): | ||
command = f'python check_rbl.py --ipv4 {test_ipv4} --ipv6 {test_ipv6}' | ||
result = subprocess.run(command.split()) | ||
assert result.returncode == status['UNKNOWN'] | ||
|
||
|
||
def test_error_resolving(): | ||
command = f'python check_rbl.py -h invalid.com' | ||
result = subprocess.run(command.split()) | ||
assert result.returncode == status['UNKNOWN'] | ||
|
||
|
||
def test_full_run_host(): | ||
command = f'python check_rbl.py -d -w {warn} -c {crit} -h {test_host}' | ||
result = subprocess.run(command.split()) | ||
assert result.returncode == status['OK'] | ||
|
||
|
||
def test_full_run_ipv4(): | ||
command = f'python check_rbl.py -d -w {warn} -c {crit} -a {test_ipv4}' | ||
result = subprocess.run(command.split()) | ||
assert result.returncode == status['OK'] | ||
|
||
|
||
def test_full_run_ipv6(): | ||
command = f'python check_rbl.py -d -w {warn} -c {crit} -a {test_ipv6}' | ||
result = subprocess.run(command.split()) | ||
assert result.returncode == status['OK'] |