def test_patroni_main(self, mock_machines): main() sys.argv = ['patroni.py', 'postgres0.yml'] mock_machines.__get__ = Mock(return_value=['http://remotehost:2379']) with patch.object(Patroni, 'run', Mock(side_effect=SleepException())): self.assertRaises(SleepException, main) with patch.object(Patroni, 'run', Mock(side_effect=KeyboardInterrupt())): main()
def test_patroni_main(self): main() sys.argv = ['patroni.py', 'postgres0.yml'] time.sleep = time_sleep with patch.object(Client, 'machines') as mock_machines: mock_machines.__get__ = Mock(return_value=['http://remotehost:2379']) Patroni.initialize = nop touch_member = Patroni.touch_member run = Patroni.run Patroni.touch_member = self.touch_member Patroni.run = time_sleep Etcd.delete_leader = nop self.assertRaises(Exception, main) Patroni.run = run Patroni.touch_member = touch_member
def test_patroni_main(self): main() sys.argv = ['patroni.py', 'postgres0.yml'] time.sleep = time_sleep with patch.object(Client, 'machines') as mock_machines: mock_machines.__get__ = Mock( return_value=['http://remotehost:2379']) Patroni.initialize = nop touch_member = Patroni.touch_member run = Patroni.run Patroni.touch_member = self.touch_member Patroni.run = time_sleep Etcd.delete_leader = nop self.assertRaises(Exception, main) Patroni.run = run Patroni.touch_member = touch_member
#!/usr/bin/env python from patroni import main if __name__ == '__main__': main()
from patroni import main if __name__ == '__main__': main()