예제 #1
0
    def test_grains(self):
        '''
        test cache.grains runner
        '''
        mock_minion = ['Larry']
        mock_ret = {}
        self.assertEqual(cache.grains(minion=mock_minion), mock_ret)

        mock_data = 'grain stuff'
        mock_outputter = 'deprecated'

        class MockMaster(object):
            def __init__(self, *args, **kwargs):
                pass

            def get_minion_grains(self):
                return mock_data

        mock_ret = {'outputter': mock_outputter, 'data': mock_data}
        with patch.object(salt.utils.master, 'MasterPillarUtil', MockMaster):
            self.assertEqual(cache.grains(outputter=mock_outputter), mock_ret)

        mock_outputter = None
        with patch.object(salt.utils.master, 'MasterPillarUtil', MockMaster):
            self.assertEqual(cache.grains(outputter=mock_outputter), mock_data)
    def test_grains(self):
        '''
        test cache.grains runner
        '''
        mock_minion = ['Larry']
        mock_ret = {}
        self.assertEqual(cache.grains(minion=mock_minion), mock_ret)

        mock_data = 'grain stuff'
        mock_outputter = 'deprecated'

        class MockMaster(object):
            def __init__(self, *args, **kwargs):
                pass

            def get_minion_grains(self):
                return mock_data

        mock_ret = {'outputter': mock_outputter, 'data': mock_data}
        with patch.object(salt.utils.master, 'MasterPillarUtil', MockMaster):
            self.assertEqual(cache.grains(outputter=mock_outputter), mock_ret)

        mock_outputter = None
        with patch.object(salt.utils.master, 'MasterPillarUtil', MockMaster):
            self.assertEqual(cache.grains(outputter=mock_outputter), mock_data)
예제 #3
0
    def test_grains(self):
        """
        test cache.grains runner
        """
        mock_minion = ["Larry"]
        mock_ret = {}
        self.assertEqual(cache.grains(minion=mock_minion), mock_ret)

        mock_data = "grain stuff"

        class MockMaster(object):
            def __init__(self, *args, **kwargs):
                pass

            def get_minion_grains(self):
                return mock_data

        with patch.object(salt.utils.master, "MasterPillarUtil", MockMaster):
            self.assertEqual(cache.grains(), mock_data)