Exemplo n.º 1
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)
Exemplo n.º 2
0
 def test_invalid_port_type_exit(self):
     with self.assertRaises(AssertionError):
         pgtest.PGTest(port='5432')
Exemplo n.º 3
0
 def test_no_exist_copy_cluster_exit(self):
     with self.assertRaises(AssertionError):
         pgtest.PGTest('/not/a/path')
Exemplo n.º 4
0
 def test_invalid_copy_cluster_exit(self):
     temp_dir = tempfile.mkdtemp()
     with self.assertRaises(AssertionError):
         pgtest.PGTest(copy_cluster=temp_dir)
     shutil.rmtree(temp_dir, ignore_errors=True)
Exemplo n.º 5
0
 def test_invalid_pg_ctl_exe_exit(self):
     with self.assertRaises(AssertionError):
         pgtest.PGTest(pg_ctl='/not/a/path/pg_ctl')
Exemplo n.º 6
0
 def test_invalid_username_exit(self):
     with self.assertRaises(AssertionError):
         pgtest.PGTest(username='******')
Exemplo n.º 7
0
 def test_base_dir_valid(self):
     temp_dir = tempfile.mkdtemp()
     with pgtest.PGTest(base_dir=temp_dir) as pg:
         self.assertTrue(pgtest.is_server_running(pg.cluster))
     shutil.rmtree(temp_dir, ignore_errors=True)
Exemplo n.º 8
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))
Exemplo n.º 9
0
 def test_username_valid(self):
     with pgtest.PGTest(username='******') as pg:
         self.assertTrue(pgtest.is_server_running(pg.cluster))
Exemplo n.º 10
0
 def test_no_cleanup(self):
     with pgtest.PGTest(no_cleanup=True) as pg:
         base_dir = pg._base_dir
         self.assertDirExists(base_dir)
     self.assertDirExists(base_dir)
     shutil.rmtree(base_dir, ignore_errors=True)
Exemplo n.º 11
0
 def test_cleanup(self):
     with pgtest.PGTest() as pg:
         base_dir = pg._base_dir
         self.assertDirExists(base_dir)
     self.assertDirNotExists(base_dir)
Exemplo n.º 12
0
 def setUpClass(cls):
     cls.pg = pgtest.PGTest()
     cls.base_dir = cls.pg._base_dir
Exemplo n.º 13
0
 def setUpClass(cls):
     cls.pg_ctl_exe = pgtest.which('pg_ctl')
     cls.pg = pgtest.PGTest()
Exemplo n.º 14
0
 def test_invalid_max_connections_exit(self):
     with self.assertRaises(AssertionError):
         pgtest.PGTest(max_connections=3.5)
Exemplo n.º 15
0
 def test_max_connections_valid(self):
     with pgtest.PGTest(max_connections=12) as pg:
         with psycopg2.connect(**pg.dsn) as connection:
             with connection.cursor() as cursor:
                 cursor.execute('SHOW max_connections;')
                 self.assertEqual(int(list(cursor)[0][0]), 12)
Exemplo n.º 16
0
 def test_invalid_base_dir_exit(self):
     with self.assertRaises(AssertionError):
         pgtest.PGTest(base_dir='/not/a/path')