Beispiel #1
0
    def test_pcre_match_different_minion_id(self):
        """
        Tests for situations where the glob matcher is called with a different
        minion_id than what is found in __opts__
        """
        # not passing minion_id, should return False
        self.assertFalse(match.pcre("bar.*04"))

        # passing minion_id, should return True
        self.assertTrue(match.pcre("bar.*04", "bar04"))
Beispiel #2
0
    def test_pcre(self, mock_matcher):
        '''
        Test for Return True if the minion ID matches the given pcre target
        '''
        mock_matcher.side_effect = MagicMock()
        with patch.dict(match.__grains__, {'id': 101}):
            with patch.object(mock_matcher, 'pcre_match', MagicMock()):
                self.assertTrue(match.pcre('tgt'))

        mock_matcher.side_effect = MagicMock(return_value='B')
        with patch.dict(match.__grains__, {'id': 101}):
            self.assertFalse(match.pcre('tgt'))
Beispiel #3
0
    def test_pcre(self, mock_matcher):
        '''
        Test for Return True if the minion ID matches the given pcre target
        '''
        mock_matcher.side_effect = MagicMock()
        with patch.dict(match.__grains__, {'id': 101}):
            with patch.object(mock_matcher, 'pcre_match', MagicMock()):
                self.assertTrue(match.pcre('tgt'))

        mock_matcher.side_effect = MagicMock(return_value='B')
        with patch.dict(match.__grains__, {'id': 101}):
            self.assertFalse(match.pcre('tgt'))