コード例 #1
0
ファイル: sqs_events_test.py プロジェクト: bryson/salt
 def test_no_queue_present(self, mock_sleep, mock_logging, mock_sqs):
     """
     Test to ensure the SQS engine logs a warning when queue not present
     """
     q = None
     q_name = "mysqs"
     mock_fire = MagicMock(return_value=True)
     sqs_events._process_queue(q, q_name, mock_fire)
     self.assertTrue(mock_logging.warning.called)
     self.assertFalse(mock_sqs.queue.Queue().get_messages.called)
コード例 #2
0
ファイル: test_sqs_events.py プロジェクト: cldeluna/salt
 def test_no_queue_present(self, mock_sleep, mock_logging, mock_sqs):
     '''
     Test to ensure the SQS engine logs a warning when queue not present
     '''
     q = None
     q_name = 'mysqs'
     mock_fire = MagicMock(return_value=True)
     sqs_events._process_queue(q, q_name, mock_fire)
     self.assertTrue(mock_logging.warning.called)
     self.assertFalse(mock_sqs.queue.Queue().get_messages.called)
コード例 #3
0
def test_master_message_fires(mock_sqs):
    """
    Test SQS engine correctly gets and fires messages on master
    """
    msgs = [sample_msg(), sample_msg()]
    mock_sqs.queue.Queue().get_messages.return_value = msgs
    q = mock_sqs.queue.Queue()
    q_name = "mysqs"
    mock_fire = MagicMock(return_value=True)
    sqs_events._process_queue(q, q_name, mock_fire)
    assert mock_sqs.queue.Queue().get_messages.called, len(msgs)
    assert mock_fire.called, len(msgs)
コード例 #4
0
def test_no_queue_present(mock_sqs):
    """
    Test to ensure the SQS engine logs a warning when queue not present
    """
    with patch("salt.engines.sqs_events.log") as mock_logging:
        with patch("time.sleep", return_value=None) as mock_sleep:
            q = None
            q_name = "mysqs"
            mock_fire = MagicMock(return_value=True)
            sqs_events._process_queue(q, q_name, mock_fire)
            assert mock_logging.warning.called
            assert not mock_sqs.queue.Queue().get_messages.called
コード例 #5
0
ファイル: sqs_events_test.py プロジェクト: bryson/salt
 def test_master_message_fires(self, mock_sqs):
     """
     Test SQS engine correctly gets and fires messages on master
     """
     msgs = [self.sample_msg(), self.sample_msg()]
     mock_sqs.queue.Queue().get_messages.return_value = msgs
     q = mock_sqs.queue.Queue()
     q_name = "mysqs"
     mock_fire = MagicMock(return_value=True)
     sqs_events._process_queue(q, q_name, mock_fire)
     self.assertTrue(mock_sqs.queue.Queue().get_messages.called, len(msgs))
     self.assertTrue(mock_fire.called, len(msgs))
コード例 #6
0
ファイル: test_sqs_events.py プロジェクト: cldeluna/salt
 def test_master_message_fires(self, mock_sqs):
     '''
     Test SQS engine correctly gets and fires messages on master
     '''
     msgs = [self.sample_msg(), self.sample_msg()]
     mock_sqs.queue.Queue().get_messages.return_value = msgs
     q = mock_sqs.queue.Queue()
     q_name = 'mysqs'
     mock_fire = MagicMock(return_value=True)
     sqs_events._process_queue(q, q_name, mock_fire)
     self.assertTrue(mock_sqs.queue.Queue().get_messages.called, len(msgs))
     self.assertTrue(mock_fire.called, len(msgs))
コード例 #7
0
ファイル: test_sqs_events.py プロジェクト: MalloZup/salt-2
 def test_no_queue_present(self):
     '''
     Test to ensure the SQS engine logs a warning when queue not present
     '''
     with patch('salt.engines.sqs_events.log') as mock_logging:
         with patch('time.sleep', return_value=None) as mock_sleep:
             q = None
             q_name = 'mysqs'
             mock_fire = MagicMock(return_value=True)
             sqs_events._process_queue(q, q_name, mock_fire)
             self.assertTrue(mock_logging.warning.called)
             self.assertFalse(self.mock_sqs.queue.Queue().get_messages.called)
コード例 #8
0
def test_minion_message_fires(mock_sqs):
    """
    Test SQS engine correctly gets and fires messages on minion
    """
    msgs = [sample_msg(), sample_msg()]
    mock_sqs.queue.Queue().get_messages.return_value = msgs
    q = mock_sqs.queue.Queue()
    q_name = "mysqs"
    mock_event = MagicMock(return_value=True)
    mock_fire = MagicMock(return_value=True)
    with patch.dict(sqs_events.__salt__, {"event.send": mock_event}):
        sqs_events._process_queue(q, q_name, mock_fire)
        assert mock_sqs.queue.Queue().get_messages.called
        assert all(x.delete.called for x in msgs)
コード例 #9
0
ファイル: sqs_events_test.py プロジェクト: bryson/salt
 def test_minion_message_fires(self, mock_sqs):
     """
     Test SQS engine correctly gets and fires messages on minion
     """
     msgs = [self.sample_msg(), self.sample_msg()]
     mock_sqs.queue.Queue().get_messages.return_value = msgs
     q = mock_sqs.queue.Queue()
     q_name = "mysqs"
     mock_event = MagicMock(return_value=True)
     mock_fire = MagicMock(return_value=True)
     with patch.dict(sqs_events.__salt__, {"event.send": mock_event}):
         sqs_events._process_queue(q, q_name, mock_fire)
         self.assertTrue(mock_sqs.queue.Queue().get_messages.called)
         self.assertTrue(all(x.delete.called for x in msgs))
コード例 #10
0
 def test_minion_message_fires(self):
     '''
     Test SQS engine correctly gets and fires messages on minion
     '''
     msgs = [self.sample_msg(), self.sample_msg()]
     self.mock_sqs.queue.Queue().get_messages.return_value = msgs
     q = self.mock_sqs.queue.Queue()
     q_name = 'mysqs'
     mock_event = MagicMock(return_value=True)
     mock_fire = MagicMock(return_value=True)
     with patch.dict(sqs_events.__salt__, {'event.send': mock_event}):
         sqs_events._process_queue(q, q_name, mock_fire)
         self.assertTrue(self.mock_sqs.queue.Queue().get_messages.called)
         self.assertTrue(all(x.delete.called for x in msgs))