Exemplo n.º 1
0
    def test_runner(self):
        """
        Test if it execute a runner on the master and return the data
        from the runner function
        """
        ret = "No access to master. If using salt-call with --local," " please remove."
        self.assertEqual(publish.runner("manage.down"), ret)

        mock = MagicMock(return_value=True)
        mock_id = MagicMock(return_value="salt_id")
        with patch.dict(publish.__opts__, {"master_uri": mock, "id": mock_id}):
            Channel.flag = 0
            self.assertTrue(publish.runner("manage.down"))

            Channel.flag = 1
            self.assertEqual(publish.runner("manage.down"),
                             "'manage.down' runner publish timed out")
Exemplo n.º 2
0
    def test_runner(self, mock):
        '''
        Test if it execute a runner on the master and return the data
        from the runner function
        '''
        ret = ('No access to master. If using salt-call with --local,'
               ' please remove.')
        self.assertEqual(publish.runner('manage.down'), ret)

        mock = MagicMock(return_value=True)
        mock_id = MagicMock(return_value='salt_id')
        with patch.dict(publish.__opts__, {'master_uri': mock, 'id': mock_id}):
            Channel.flag = 0
            self.assertTrue(publish.runner('manage.down'))

            Channel.flag = 1
            self.assertEqual(publish.runner('manage.down'),
                             "'manage.down' runner publish timed out")
Exemplo n.º 3
0
    def test_runner(self, mock):
        '''
        Test if it execute a runner on the master and return the data
        from the runner function
        '''
        ret = ('No access to master. If using salt-call with --local,'
               ' please remove.')
        self.assertEqual(publish.runner('manage.down'), ret)

        mock = MagicMock(return_value=True)
        mock_id = MagicMock(return_value='salt_id')
        with patch.dict(publish.__opts__, {'master_uri': mock,
                                           'id': mock_id}):
            Channel.flag = 0
            self.assertTrue(publish.runner('manage.down'))

            Channel.flag = 1
            self.assertEqual(publish.runner('manage.down'),
                             "'manage.down' runner publish timed out")
Exemplo n.º 4
0
def test_runner():
    """
    Test if it execute a runner on the master and return the data
    from the runner function
    """
    ret = "No access to master. If using salt-call with --local, please remove."
    assert publish.runner("manage.down") == ret
    mock = MagicMock(return_value=True)
    mock_id = MagicMock(return_value="salt_id")
    with patch("salt.crypt.SAuth", return_value=SAuth(publish.__opts__)):
        with patch("salt.transport.client.ReqChannel", Channel()):
            with patch.dict(publish.__opts__, {"master_uri": mock, "id": mock_id}):
                Channel.flag = 0
                assert publish.runner("manage.down")
                Channel.flag = 1
                assert (
                    publish.runner("manage.down")
                    == "'manage.down' runner publish timed out"
                )