@patch('salt.minion.Matcher')
    def test_grain(self, mock_matcher):
        with patch.dict(match.__grains__, {'id': 101}):

            mock_matcher.side_effect = MagicMock()
            with patch.object(mock_matcher, 'grain_match', MagicMock()):
                self.assertTrue(match.grain('tgt'))

            mock_matcher.side_effect = MagicMock(return_value='B')
            self.assertFalse(match.grain('tgt'))
Test for Return True if the minion matches the given grain target
dataset/ETHPy150Open saltstack/salt/tests/unit/modules/match_test.py/MatchTestCase.test_grain