Esempio n. 1
0
def test_force_close_all_instances():
    zmq1 = MagicMock()
    zmq2 = MagicMock()
    zmq3 = MagicMock()
    zmq_objects = {"zmq": {"1": zmq1, "2": zmq2}, "other_zmq": {"3": zmq3}}

    with patch("salt.transport.zeromq.AsyncZeroMQReqChannel.instance_map", zmq_objects):
        salt.transport.zeromq.AsyncZeroMQReqChannel.force_close_all_instances()

        assert zmq1.mock_calls == [call.close()]
        assert zmq2.mock_calls == [call.close()]
        assert zmq3.mock_calls == [call.close()]

        # check if instance map changed
        assert zmq_objects is salt.transport.zeromq.AsyncZeroMQReqChannel.instance_map
Esempio n. 2
0
    def test_force_close_all_instances(self):
        zmq1 = MagicMock()
        zmq2 = MagicMock()
        zmq3 = MagicMock()
        zmq_objects = {"zmq": {"1": zmq1, "2": zmq2}, "other_zmq": {"3": zmq3}}

        with patch("salt.transport.zeromq.AsyncZeroMQReqChannel.instance_map",
                   zmq_objects):
            salt.transport.zeromq.AsyncZeroMQReqChannel.force_close_all_instances(
            )

            self.assertEqual(zmq1.mock_calls, [call.close()])
            self.assertEqual(zmq2.mock_calls, [call.close()])
            self.assertEqual(zmq3.mock_calls, [call.close()])

            # check if instance map changed
            self.assertIs(
                zmq_objects,
                salt.transport.zeromq.AsyncZeroMQReqChannel.instance_map)