mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
helpers/postgresql.py
Replace os.system with subprocess.call
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import os
|
||||
import psycopg2
|
||||
import unittest
|
||||
import requests
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
import yaml
|
||||
|
||||
from governor import Governor, main, sigchld_handler, sigterm_handler
|
||||
from test_ha import true, false
|
||||
from test_postgresql import Postgresql, os_system, psycopg2_connect
|
||||
from test_postgresql import Postgresql, subprocess_call, psycopg2_connect
|
||||
from test_etcd import requests_get, requests_put, requests_delete
|
||||
|
||||
if sys.hexversion >= 0x03000000:
|
||||
@@ -38,7 +39,7 @@ class TestGovernor(unittest.TestCase):
|
||||
|
||||
def set_up(self):
|
||||
self.touched = False
|
||||
os.system = os_system
|
||||
subprocess.call = subprocess_call
|
||||
psycopg2.connect = psycopg2_connect
|
||||
requests.get = requests_get
|
||||
requests.put = requests_put
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import os
|
||||
import psycopg2
|
||||
import unittest
|
||||
import shutil
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
from helpers.etcd import Cluster, Member
|
||||
from helpers.postgresql import Postgresql
|
||||
|
||||
|
||||
def os_system(cmd):
|
||||
def subprocess_call(cmd, shell=False):
|
||||
return 0
|
||||
|
||||
|
||||
@@ -89,7 +90,7 @@ class TestPostgresql(unittest.TestCase):
|
||||
super(TestPostgresql, self).__init__(method_name)
|
||||
|
||||
def set_up(self):
|
||||
os.system = os_system
|
||||
subprocess.call = subprocess_call
|
||||
self.p = Postgresql({'name': 'test0', 'data_dir': 'data/test0', 'listen': '127.0.0.1, 127.0.0.2:5432', 'connect_address': '127.0.0.2:5432', 'replication': {
|
||||
'username': 'replicator', 'password': 'rep-pass', 'network': '127.0.0.1/32'}, 'parameters': {'foo': 'bar'}, 'recovery_conf': {'foo': 'bar'}})
|
||||
psycopg2.connect = psycopg2_connect
|
||||
|
||||
Reference in New Issue
Block a user