From 0f43276109aa93d3384150a9f06c4f74006f733c Mon Sep 17 00:00:00 2001 From: Alex Kelly Date: Thu, 30 Sep 2021 16:31:19 -0400 Subject: [PATCH] test: refactor test code for pep8 --- tests/test_checkcert.py | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tests/test_checkcert.py b/tests/test_checkcert.py index e962a18..4279d7e 100644 --- a/tests/test_checkcert.py +++ b/tests/test_checkcert.py @@ -1,36 +1,54 @@ +""" Tests to validate checkcert""" +from click.testing import CliRunner from checkcert.checkcert import main as cert_main from checkcert.checkcert import __version__ as cert_version -from click.testing import CliRunner runner = CliRunner() def test_main(): - if cert_main: - response = runner.invoke(cert_main, ["www.franklin.edu"]) - assert response.exit_code == 0 - response = runner.invoke(cert_main, ["www.franklin.edu:443"]) - assert response.exit_code == 0 - response = runner.invoke(cert_main, ["www.franklin.edu", "--no-color"]) - assert response.exit_code == 0 + """validate the core function returns correctly for: + a domain + a domain and a port + no names specified + a list of domains + a list of domains with a port specified on one + """ + response = runner.invoke(cert_main, ["www.franklin.edu"]) + assert response.exit_code == 0 + response = runner.invoke(cert_main, ["www.franklin.edu:443"]) + assert response.exit_code == 0 + response = runner.invoke(cert_main, ["www.franklin.edu", "--no-color"]) + assert response.exit_code == 0 + response = runner.invoke(cert_main, ["www.franklin.edu", "library.franklin.edu"]) + assert response.exit_code == 0 + response = runner.invoke( + cert_main, ["www.franklin.edu:443", "library.franklin.edu"] + ) + assert response.exit_code == 0 def test_version(): + """get the version output and ensure it matches the version var""" response = runner.invoke(cert_main, ["--version"]) assert response.exit_code == 0 assert cert_version in response.output def test_dump(): + """verify that --dump outputs data""" response = runner.invoke(cert_main, ["www.franklin.edu", "--dump"]) assert response.exit_code == 0 + assert "www.franklin.edu" in response.output def test_san(): + """verify --san outputs correctly""" response = runner.invoke(cert_main, ["www.franklin.edu", "--san"]) assert response.exit_code == 0 def test_bad_cert(): + """verify an expired certificate works""" response = runner.invoke(cert_main, ["support.bluequill.com", "--san"]) assert response.exit_code == 0