Пример #1
0
 def setUp(cls):
     cls.pg_ctl_exe = pgtest.which('pg_ctl')
     cls.temp_dir = tempfile.mkdtemp()
     cls.curr_dir = os.path.dirname(__file__)
     cls.data_dir = os.path.join(cls.temp_dir, 'data')
     cmd = ('"{pg_ctl}" initdb -D "{cluster}" -o "-U postgres -A trust"'
         ).format(pg_ctl=cls.pg_ctl_exe, cluster=cls.data_dir)
     subprocess.check_output(cmd, shell=True)
Пример #2
0
 def test_copy_data(self):
     pg_ctl_exe = pgtest.which('pg_ctl')
     temp_dir = tempfile.mkdtemp()
     data_dir = os.path.join(temp_dir, 'data')
     cmd = ('"{pg_ctl}" initdb -D "{cluster}" -o "-U postgres -A trust"'
            ).format(pg_ctl=pg_ctl_exe, cluster=data_dir)
     subprocess.check_output(cmd, shell=True)
     with pgtest.PGTest(copy_cluster=data_dir) as pg:
         self.assertTrue(pgtest.is_server_running(pg.cluster))
     shutil.rmtree(temp_dir, ignore_errors=True)
Пример #3
0
    def test_pgtest_argument(self):
        """
        Create a temporary profile, passing the pgtest argument.
        """
        from pgtest.pgtest import which

        # this should fail
        pgtest = {'pg_ctl': 'notapath'}
        with self.assertRaises(AssertionError):
            self.test_manager.use_temporary_profile(backend=self.backend, pgtest=pgtest)

        # pg_ctl is what PGTest also looks for (although it might be more clever)
        pgtest = {'pg_ctl': which('pg_ctl')}
        self.test_manager.use_temporary_profile(backend=self.backend, pgtest=pgtest)
Пример #4
0
# -*- coding: utf-8 -*-
"""Test compatibility with pgtest.
"""
from pgtest.pgtest import PGTest, which
import pytest
from pgsu import PGSU, PostgresConnectionMode

try:
    PG_CTL = which('pg_ctl')
except FileNotFoundError:
    PG_CTL = None


@pytest.mark.skipif(not PG_CTL, reason='pg_ctl not found in PATH')
def test_pgtest_compatibility():
    """Test using a temporary postgres cluster set up via PGTest.
    """

    with PGTest() as cluster:
        pgsu = PGSU(dsn=cluster.dsn)

        # make sure we've connected to the right cluster
        assert cluster.dsn['port'] == pgsu.dsn['port']
        # we should be connecting via psycopg
        assert pgsu.connection_mode == PostgresConnectionMode.PSYCOPG
Пример #5
0
 def test_pg_ctl_exe_valid(self):
     pg_ctl_exe = pgtest.which('pg_ctl')
     with pgtest.PGTest(pg_ctl=pg_ctl_exe) as pg:
         self.assertTrue(pgtest.is_server_running(pg.cluster))
Пример #6
0
 def test_windows_which_is_not_executable(self):
     self.assertEqual(None, pgtest.which('does not exist'))
Пример #7
0
 def test_windows_which_path_with_extension_is_executable(self):
     self.assertEqual('C:\\Windows\\system32\\ping.exe', pgtest.which('C:/Windows/system32/ping.exe'))
Пример #8
0
 def test_windows_which_is_executable(self):
     self.assertEqual('C:\\Windows\\system32\\ping.exe', pgtest.which('ping'))
Пример #9
0
 def test_windows_which_unicode(self):
         self.assertEqual('C:\\Windows\\system32\\ping.exe', pgtest.which(u'ping'))
Пример #10
0
 def test_unix_which_unicode(self):
         self.assertEqual('/bin/ping', pgtest.which(u'ping'))
Пример #11
0
 def test_which_non_string(self):
     with self.assertRaises(TypeError):
         pgtest.which(1)
Пример #12
0
 def testunix_which_path_is_executable(self):
     self.assertEqual('/bin/ping', pgtest.which('/bin/ping'))
Пример #13
0
 def test_pg_ctl_valid(self):
     self.assertIsNotNone(pgtest.which(self.pg.pg_ctl))
Пример #14
0
 def setUpClass(cls):
     cls.pg_ctl_exe = pgtest.which('pg_ctl')
     cls.pg = pgtest.PGTest()