示例#1
0
文件: test.py 项目: ltalirz/pgtest
 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
文件: test.py 项目: ltalirz/pgtest
 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
文件: test.py 项目: ltalirz/pgtest
 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
文件: test.py 项目: ltalirz/pgtest
 def test_windows_which_is_not_executable(self):
     self.assertEqual(None, pgtest.which('does not exist'))
示例#7
0
文件: test.py 项目: ltalirz/pgtest
 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
文件: test.py 项目: ltalirz/pgtest
 def test_windows_which_is_executable(self):
     self.assertEqual('C:\\Windows\\system32\\ping.exe', pgtest.which('ping'))
示例#9
0
文件: test.py 项目: ltalirz/pgtest
 def test_windows_which_unicode(self):
         self.assertEqual('C:\\Windows\\system32\\ping.exe', pgtest.which(u'ping'))
示例#10
0
文件: test.py 项目: ltalirz/pgtest
 def test_unix_which_unicode(self):
         self.assertEqual('/bin/ping', pgtest.which(u'ping'))
示例#11
0
文件: test.py 项目: ltalirz/pgtest
 def test_which_non_string(self):
     with self.assertRaises(TypeError):
         pgtest.which(1)
示例#12
0
文件: test.py 项目: ltalirz/pgtest
 def testunix_which_path_is_executable(self):
     self.assertEqual('/bin/ping', pgtest.which('/bin/ping'))
示例#13
0
文件: test.py 项目: ltalirz/pgtest
 def test_pg_ctl_valid(self):
     self.assertIsNotNone(pgtest.which(self.pg.pg_ctl))
示例#14
0
文件: test.py 项目: ltalirz/pgtest
 def setUpClass(cls):
     cls.pg_ctl_exe = pgtest.which('pg_ctl')
     cls.pg = pgtest.PGTest()