test: refactor test code for pep8
This commit is contained in:
		
					parent
					
						
							
								26638e7e73
							
						
					
				
			
			
				commit
				
					
						0f43276109
					
				
			
		
					 1 changed files with 26 additions and 8 deletions
				
			
		| 
						 | 
					@ -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 main as cert_main
 | 
				
			||||||
from checkcert.checkcert import __version__ as cert_version
 | 
					from checkcert.checkcert import __version__ as cert_version
 | 
				
			||||||
from click.testing import CliRunner
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
runner = CliRunner()
 | 
					runner = CliRunner()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_main():
 | 
					def test_main():
 | 
				
			||||||
    if cert_main:
 | 
					    """validate the core function returns correctly for:
 | 
				
			||||||
        response = runner.invoke(cert_main, ["www.franklin.edu"])
 | 
					    a domain
 | 
				
			||||||
        assert response.exit_code == 0
 | 
					    a domain and a port
 | 
				
			||||||
        response = runner.invoke(cert_main, ["www.franklin.edu:443"])
 | 
					    no names specified
 | 
				
			||||||
        assert response.exit_code == 0
 | 
					    a list of domains
 | 
				
			||||||
        response = runner.invoke(cert_main, ["www.franklin.edu", "--no-color"])
 | 
					    a list of domains with a port specified on one
 | 
				
			||||||
        assert response.exit_code == 0
 | 
					    """
 | 
				
			||||||
 | 
					    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():
 | 
					def test_version():
 | 
				
			||||||
 | 
					    """get the version output and ensure it matches the version var"""
 | 
				
			||||||
    response = runner.invoke(cert_main, ["--version"])
 | 
					    response = runner.invoke(cert_main, ["--version"])
 | 
				
			||||||
    assert response.exit_code == 0
 | 
					    assert response.exit_code == 0
 | 
				
			||||||
    assert cert_version in response.output
 | 
					    assert cert_version in response.output
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_dump():
 | 
					def test_dump():
 | 
				
			||||||
 | 
					    """verify that --dump outputs data"""
 | 
				
			||||||
    response = runner.invoke(cert_main, ["www.franklin.edu", "--dump"])
 | 
					    response = runner.invoke(cert_main, ["www.franklin.edu", "--dump"])
 | 
				
			||||||
    assert response.exit_code == 0
 | 
					    assert response.exit_code == 0
 | 
				
			||||||
 | 
					    assert "www.franklin.edu" in response.output
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_san():
 | 
					def test_san():
 | 
				
			||||||
 | 
					    """verify --san outputs correctly"""
 | 
				
			||||||
    response = runner.invoke(cert_main, ["www.franklin.edu", "--san"])
 | 
					    response = runner.invoke(cert_main, ["www.franklin.edu", "--san"])
 | 
				
			||||||
    assert response.exit_code == 0
 | 
					    assert response.exit_code == 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_bad_cert():
 | 
					def test_bad_cert():
 | 
				
			||||||
 | 
					    """verify an expired certificate works"""
 | 
				
			||||||
    response = runner.invoke(cert_main, ["support.bluequill.com", "--san"])
 | 
					    response = runner.invoke(cert_main, ["support.bluequill.com", "--san"])
 | 
				
			||||||
    assert response.exit_code == 0
 | 
					    assert response.exit_code == 0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue