예제 #1
0
 def test_persist_inspect_results_no_messages(
         self, mock_read_messages_from_queue,
         mock_persist_inspection_results):
     """Assert empty results does not work."""
     mock_read_messages_from_queue.return_value = []
     tasks.persist_inspection_cluster_results_task()
     mock_read_messages_from_queue.assert_called_once_with(
         settings.HOUNDIGRADE_RESULTS_QUEUE_NAME,
         tasks.HOUNDIGRADE_MESSAGE_READ_LEN)
     mock_persist_inspection_results.assert_not_called()
예제 #2
0
    def test_persist_inspect_results_aws_cloud_image_not_found(
            self, mock_read_messages_from_queue):
        """Assert no work for aws cloud with unknown images."""
        with patch.object(tasks, 'scale_down_cluster') as mock_scale_down:
            message = {'cloud': 'aws', 'results': {'fake_image': {}}}

            mock_read_messages_from_queue.return_value = [message]
            tasks.persist_inspection_cluster_results_task()
            mock_read_messages_from_queue.assert_called_once_with(
                settings.HOUNDIGRADE_RESULTS_QUEUE_NAME,
                tasks.HOUNDIGRADE_MESSAGE_READ_LEN)
            mock_scale_down.delay.assert_called_once()
예제 #3
0
 def test_persist_inspect_results_unknown_cloud(
         self, mock_read_messages_from_queue,
         mock_persist_inspection_results):
     """Assert no work for unknown cloud."""
     with patch.object(tasks, 'scale_down_cluster') as mock_scale_down:
         mock_read_messages_from_queue.return_value = [{'cloud': 'unknown'}]
         tasks.persist_inspection_cluster_results_task()
         mock_read_messages_from_queue.assert_called_once_with(
             settings.HOUNDIGRADE_RESULTS_QUEUE_NAME,
             tasks.HOUNDIGRADE_MESSAGE_READ_LEN)
         mock_persist_inspection_results.assert_not_called()
         mock_scale_down.delay.assert_called_once()
예제 #4
0
 def test_persist_inspect_results_aws_cloud_str_message(
         self, mock_read_messages_from_queue,
         mock_persist_inspection_results):
     """Test case where message is str not python dict."""
     with patch.object(tasks, 'scale_down_cluster') as mock_scale_down:
         message = json.dumps({'cloud': 'aws'})
         mock_read_messages_from_queue.return_value = [message]
         tasks.persist_inspection_cluster_results_task()
         mock_read_messages_from_queue.assert_called_once_with(
             settings.HOUNDIGRADE_RESULTS_QUEUE_NAME,
             tasks.HOUNDIGRADE_MESSAGE_READ_LEN)
         mock_persist_inspection_results.assert_called_once_with(
             json.loads(message))
         mock_scale_down.delay.assert_called_once()