def test_docker_api_version(mock_docker, caplog, vers, res): mock_docker.return_value = mock.MagicMock(**{'version.return_value': vers}) caplog.set_level(logging.INFO) DockerAPI().version() for ver in res: if ver not in caplog.text: pytest.fail('Version does not match expectation')
def docker_api(): return DockerAPI()
def set_docker_api(self): """Setting up Docker Python API client""" self.docker_api = DockerAPI()
def test_docker_api_init_raises(mock_docker, test_exception, res_exception): mock_docker.return_value = mock.MagicMock(**{'ping.side_effect': test_exception}) with pytest.raises(res_exception): DockerAPI()