MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / test_connection_no_home_dir

Method test_connection_no_home_dir

tests/test_connect.py:1880–1917  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1878
1879 @unittest.skipIf(os.environ.get('PGHOST'), 'unmanaged cluster')
1880 async def test_connection_no_home_dir(self):
1881 with mock_no_home_dir():
1882 con = await self.connect(
1883 dsn='postgresql://foo/',
1884 user='postgres',
1885 database='postgres',
1886 host='localhost')
1887 await con.fetchval('SELECT 42')
1888 await con.close()
1889
1890 with mock_dev_null_home_dir():
1891 con = await self.connect(
1892 dsn='postgresql://foo/',
1893 user='postgres',
1894 database='postgres',
1895 host='localhost')
1896 await con.fetchval('SELECT 42')
1897 await con.close()
1898
1899 with self.assertRaisesRegex(
1900 exceptions.ClientConfigurationError,
1901 r'root certificate file "~/\.postgresql/root\.crt" does not exist'
1902 ):
1903 with mock_no_home_dir():
1904 await self.connect(
1905 host='localhost',
1906 user='ssl_user',
1907 ssl='verify-full')
1908
1909 with self.assertRaisesRegex(
1910 exceptions.ClientConfigurationError,
1911 r'root certificate file ".*" does not exist'
1912 ):
1913 with mock_dev_null_home_dir():
1914 await self.connect(
1915 host='localhost',
1916 user='ssl_user',
1917 ssl='verify-full')
1918
1919
1920class SSLProxyConnection(fuzzer.Connection):

Callers

nothing calls this directly

Calls 5

mock_no_home_dirFunction · 0.85
mock_dev_null_home_dirFunction · 0.85
connectMethod · 0.45
fetchvalMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected