def no_snmp_connections(monkeypatch): close_all_connections() def no_snmp(self): raise TransportConnectionError(None, None) monkeypatch.setattr('modules.transports.SNMPTransport.connect', no_snmp)
#!/usr/bin/env python3 from modules.audit import audit from modules.database import init_scanning, set_finish_time from modules.reporting import generate_report from modules.testing import run_tests from modules.transports import close_all_connections if __name__ == '__main__': init_scanning() audit() run_tests() close_all_connections() set_finish_time() generate_report('sample_report.pdf')
def test_000_file_exist_4(run_docker, no_transports): close_all_connections() assert test.main()[0] == Status.ERROR and test.main()[1]
def test_000_file_exist_3(run_docker, no_ssh_connections): close_all_connections() assert test.main()[0] == Status.NOT_APPLICABLE
def test_002_permissions_4(run_docker, no_transports): close_all_connections() assert test.main()[0] == Status.ERROR and test.main()[1]
def test_002_permissions_3(run_docker, no_ssh_connections): close_all_connections() assert test.main()[0] == Status.NOT_APPLICABLE
def no_transports(monkeypatch): close_all_connections() monkeypatch.delattr('modules.transports._TRANSPORTS')
def no_mysql_connections(monkeypatch): close_all_connections() monkeypatch.delattr('pymysql.connect')
def no_ssh_connections(monkeypatch): close_all_connections() monkeypatch.delattr('paramiko.SSHClient.connect')
def pytest_sessionfinish(session, exitstatus): close_all_connections()
def stop_container(): close_all_connections() containers = docker.from_env().containers.list() for container in containers: if container.name in started_containers: container.stop()