def test__get_ca_certs_paths(embedded_dir): with mock.patch('datadog_checks.http_check.utils.os.path.dirname') as dirname: # create a tmp `embedded` folder with temp_dir() as tmp: target = os.path.join(tmp, embedded_dir) os.mkdir(target) # point `dirname()` there dirname.return_value = target # tornado not found paths = _get_ca_certs_paths() assert len(paths) == 2 assert paths[0].startswith(target) assert paths[1] == '/etc/ssl/certs/ca-certificates.crt' # mock tornado's presence sys.modules['tornado'] = mock.MagicMock(__file__='.') paths = _get_ca_certs_paths() assert len(paths) == 3 assert paths[1].endswith('ca-certificates.crt') assert paths[2] == '/etc/ssl/certs/ca-certificates.crt'
def test__get_ca_certs_paths_ko(): """ When `embedded` folder is not found, it should raise OSError """ with pytest.raises(OSError): _get_ca_certs_paths()