* debian/patches/check_postmaster.patch: Update unit tests as well.

This commit is contained in:
Michael Banck 2018-09-26 16:08:24 +02:00
parent a9ee748279
commit acb7de0bb4
2 changed files with 30 additions and 1 deletions

3
debian/changelog vendored
View file

@ -1,6 +1,7 @@
patroni (1.5.0-5) UNRELEASED; urgency=medium
*
[ Michael Banck ]
* debian/patches/check_postmaster.patch: Update unit tests as well.
-- Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org> Wed, 26 Sep 2018 14:30:00 +0200

View file

@ -23,3 +23,31 @@
# Extra safety check. The process can't be ourselves, our parent or our direct child.
if self.pid == os.getpid() or self.pid == os.getppid() or self.ppid() == os.getpid():
--- ./tests/test_postmaster.py.orig 2018-09-26 15:56:22.496398226 +0200
+++ ./tests/test_postmaster.py 2018-09-26 15:56:42.316604224 +0200
@@ -24,25 +24,6 @@
mock_read.return_value = {"pid": "123"}
self.assertIsNone(PostmasterProcess.from_pidfile(''))
- mock_init.side_effect = None
- with patch.object(psutil.Process, 'pid', 123), \
- patch.object(psutil.Process, 'ppid', return_value=124), \
- patch('os.getpid', return_value=125) as mock_ospid, \
- patch('os.getppid', return_value=126):
-
- self.assertIsNotNone(PostmasterProcess.from_pidfile(''))
-
- mock_create_time.return_value = 100000
- mock_read.return_value = {"pid": "123", "start_time": "200000"}
- self.assertIsNone(PostmasterProcess.from_pidfile(''))
-
- mock_read.return_value = {"pid": "123", "start_time": "foobar"}
- self.assertIsNotNone(PostmasterProcess.from_pidfile(''))
-
- mock_ospid.return_value = 123
- mock_read.return_value = {"pid": "123", "start_time": "100000"}
- self.assertIsNone(PostmasterProcess.from_pidfile(''))
-
@patch('psutil.Process.__init__')
def test_from_pid(self, mock_init):
mock_init.side_effect = psutil.NoSuchProcess(123)