def test_get_throughput_of_tasks_put_onto_queue_returns_0_if_no_data(self, mock_boto3, mocker): sqs_scaler = SqsScaler(app_name, min_instances, max_instances, **self.input_attrs) mocker.patch.object( sqs_scaler, '_get_sqs_throughput_of_tasks_put_onto_queue', return_value=[] ) statsd_mock = mocker.patch.object(sqs_scaler, 'statsd_client') assert sqs_scaler._get_throughput_of_tasks_put_onto_queue('my-queue') == 0 statsd_mock.gauge.assert_called_once_with('testmy-queue.queue-throughput', 0)
def test_get_throughput_of_tasks_put_onto_queue_uses_max_value(self, mock_boto3, mocker): sqs_scaler = SqsScaler(app_name, min_instances, max_instances, **self.input_attrs) _get_sqs_throughput_mock = mocker.patch.object( sqs_scaler, '_get_sqs_throughput_of_tasks_put_onto_queue', return_value=[100, 200, 50] ) statsd_mock = mocker.patch.object(sqs_scaler, 'statsd_client') assert sqs_scaler._get_throughput_of_tasks_put_onto_queue('my-queue') == 200 # queue prefix "test" pulled from SQS_QUEUE_PREFIX env var statsd_mock.gauge.assert_called_once_with('testmy-queue.queue-throughput', 50) _get_sqs_throughput_mock.assert_called_once_with('testmy-queue')