diff options
author | Matus Valo <matusvalo@users.noreply.github.com> | 2021-04-13 23:20:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-13 23:20:31 +0200 |
commit | c35fd1d9b4dca7ddf764a832cb677d8cfebf171f (patch) | |
tree | 92850ca36f2189fe030edb2b6965db0657c11fbd /t | |
parent | 4615415bf000bb0cca2cc1116b307a5533bd6dc3 (diff) | |
download | kombu-c35fd1d9b4dca7ddf764a832cb677d8cfebf171f.tar.gz |
Make flake8 and pydocstyle happy (#1333)
* Make flake8 happy
* Make pydocstyle happy
Diffstat (limited to 't')
-rw-r--r-- | t/unit/transport/test_SQS.py | 60 | ||||
-rw-r--r-- | t/unit/transport/test_azureservicebus.py | 26 | ||||
-rw-r--r-- | t/unit/transport/test_redis.py | 2 |
3 files changed, 59 insertions, 29 deletions
diff --git a/t/unit/transport/test_SQS.py b/t/unit/transport/test_SQS.py index 0c0bf3c7..5d958c8b 100644 --- a/t/unit/transport/test_SQS.py +++ b/t/unit/transport/test_SQS.py @@ -32,7 +32,7 @@ example_predefined_queues = { 'access_key_id': 'a', 'secret_access_key': 'b', 'backoff_tasks': ['svc.tasks.tasks.task1'], - 'backoff_policy': {1: 10, 2: 20, 3: 40, 4: 80, 5: 320, 6: 640} + 'backoff_policy': {1: 10, 2: 20, 3: 40, 4: 80, 5: 320, 6: 640} }, 'queue-2': { 'url': 'https://sqs.us-east-1.amazonaws.com/xxx/queue-2', @@ -333,7 +333,7 @@ class test_Channel: def test_is_base64_encoded(self): raw = b'{"id": "4cc7438e-afd4-4f8f-a2f3-f46567e7ca77","task": "celery.task.PingTask",' \ - b'"args": [],"kwargs": {},"retries": 0,"eta": "2009-11-17T12:30:56.527191"}' + b'"args": [],"kwargs": {},"retries": 0,"eta": "2009-11-17T12:30:56.527191"}' # noqa b64_enc = base64.b64encode(raw) assert self.channel._Channel__b64_encoded(b64_enc) assert not self.channel._Channel__b64_encoded(raw) @@ -666,7 +666,8 @@ class test_Channel: }) channel = connection.channel() - def apply_backoff_policy(queue_name, delivery_tag, retry_policy, backoff_tasks): + def apply_backoff_policy( + queue_name, delivery_tag, retry_policy, backoff_tasks): return None mock_apply_policy = Mock(side_effect=apply_backoff_policy) @@ -681,8 +682,11 @@ class test_Channel: message_mock.delivery_info = {'routing_key': queue_name} channel.qos._delivered['test_message_id'] = message_mock channel.qos.reject('test_message_id') - mock_apply_policy.assert_called_once_with('queue-1', 'test_message_id', - {1: 10, 2: 20, 3: 40, 4: 80, 5: 320, 6: 640}, ['svc.tasks.tasks.task1']) + mock_apply_policy.assert_called_once_with( + 'queue-1', 'test_message_id', + {1: 10, 2: 20, 3: 40, 4: 80, 5: 320, 6: 640}, + ['svc.tasks.tasks.task1'] + ) def test_predefined_queues_change_visibility_timeout(self): connection = Connection(transport=SQS.Transport, transport_options={ @@ -693,8 +697,10 @@ class test_Channel: def extract_task_name_and_number_of_retries(delivery_tag): return 'svc.tasks.tasks.task1', 2 - mock_extract_task_name_and_number_of_retries = Mock(side_effect=extract_task_name_and_number_of_retries) - channel.qos.extract_task_name_and_number_of_retries = mock_extract_task_name_and_number_of_retries + mock_extract_task_name_and_number_of_retries = Mock( + side_effect=extract_task_name_and_number_of_retries) + channel.qos.extract_task_name_and_number_of_retries = \ + mock_extract_task_name_and_number_of_retries queue_name = "queue-1" @@ -711,9 +717,9 @@ class test_Channel: channel.sqs.return_value = sqs_queue_mock channel.qos.reject('test_message_id') - sqs_queue_mock.change_message_visibility.assert_called_once_with(QueueUrl='https://sqs.us-east-1.amazonaws.com/xxx/queue-1', - ReceiptHandle='test_message_id', - VisibilityTimeout=20) + sqs_queue_mock.change_message_visibility.assert_called_once_with( + QueueUrl='https://sqs.us-east-1.amazonaws.com/xxx/queue-1', + ReceiptHandle='test_message_id', VisibilityTimeout=20) def test_sts_new_session(self): # Arrange @@ -725,12 +731,17 @@ class test_Channel: sqs = SQS_Channel_sqs.__get__(channel, SQS.Channel) queue_name = 'queue-1' - exchange = Exchange('test_SQS', type='direct') - queue = Queue(queue_name, exchange, queue_name) mock_generate_sts_session_token = Mock() mock_new_sqs_client = Mock() channel.new_sqs_client = mock_new_sqs_client - mock_generate_sts_session_token.side_effect = [{'Expiration': 123, 'SessionToken': 123, 'AccessKeyId': 123, 'SecretAccessKey': 123}] + mock_generate_sts_session_token.side_effect = [ + { + 'Expiration': 123, + 'SessionToken': 123, + 'AccessKeyId': 123, + 'SecretAccessKey': 123 + } + ] channel.generate_sts_session_token = mock_generate_sts_session_token # Act @@ -750,12 +761,17 @@ class test_Channel: channel.sts_expiration = datetime.utcnow() - timedelta(days=1) queue_name = 'queue-1' - exchange = Exchange('test_SQS', type='direct') - queue = Queue(queue_name, exchange, queue_name) mock_generate_sts_session_token = Mock() mock_new_sqs_client = Mock() channel.new_sqs_client = mock_new_sqs_client - mock_generate_sts_session_token.side_effect = [{'Expiration': 123, 'SessionToken': 123, 'AccessKeyId': 123, 'SecretAccessKey': 123}] + mock_generate_sts_session_token.side_effect = [ + { + 'Expiration': 123, + 'SessionToken': 123, + 'AccessKeyId': 123, + 'SecretAccessKey': 123 + } + ] channel.generate_sts_session_token = mock_generate_sts_session_token # Act @@ -774,13 +790,18 @@ class test_Channel: channel.sts_expiration = datetime.utcnow() + timedelta(days=1) queue_name = 'queue-1' - exchange = Exchange('test_SQS', type='direct') - queue = Queue(queue_name, exchange, queue_name) mock_generate_sts_session_token = Mock() mock_new_sqs_client = Mock() channel.new_sqs_client = mock_new_sqs_client channel._predefined_queue_clients = {queue_name: 'mock_client'} - mock_generate_sts_session_token.side_effect = [{'Expiration': 123, 'SessionToken': 123, 'AccessKeyId': 123, 'SecretAccessKey': 123}] + mock_generate_sts_session_token.side_effect = [ + { + 'Expiration': 123, + 'SessionToken': 123, + 'AccessKeyId': 123, + 'SecretAccessKey': 123 + } + ] channel.generate_sts_session_token = mock_generate_sts_session_token # Act @@ -788,4 +809,3 @@ class test_Channel: # Assert mock_generate_sts_session_token.assert_not_called() - diff --git a/t/unit/transport/test_azureservicebus.py b/t/unit/transport/test_azureservicebus.py index 329eeac7..bc96bbff 100644 --- a/t/unit/transport/test_azureservicebus.py +++ b/t/unit/transport/test_azureservicebus.py @@ -14,7 +14,7 @@ import azure.servicebus.exceptions import azure.core.exceptions pytest.importorskip('azure.servicebus') -from azure.servicebus import ServiceBusMessage, ServiceBusReceiveMode +from azure.servicebus import ServiceBusMessage, ServiceBusReceiveMode # noqa class ASBQueue: @@ -26,7 +26,8 @@ class ASBQueue: self.recv_calls = [] def get_receiver(self, kwargs): - receive_mode = kwargs.get('receive_mode', ServiceBusReceiveMode.PEEK_LOCK) + receive_mode = kwargs.get( + 'receive_mode', ServiceBusReceiveMode.PEEK_LOCK) class Receiver: def close(self): @@ -99,7 +100,7 @@ def test_queue_service_nocredentials(): conn = Connection(URL_NOCREDS, transport=azureservicebus.Transport) with pytest.raises(ValueError) as exc: conn.channel() - assert exc == 'Need an URI like azureservicebus://{SAS policy name}:{SAS key}@{ServiceBus Namespace}' + assert exc == 'Need an URI like azureservicebus://{SAS policy name}:{SAS key}@{ServiceBus Namespace}' # noqa def test_queue_service(): @@ -139,11 +140,16 @@ def test_default_wait_timeout_seconds(): conn = Connection(URL_CREDS, transport=azureservicebus.Transport) channel = conn.channel() - assert channel.wait_time_seconds == azureservicebus.Channel.default_wait_time_seconds + assert channel.wait_time_seconds == \ + azureservicebus.Channel.default_wait_time_seconds def test_custom_wait_timeout_seconds(): - conn = Connection(URL_CREDS, transport=azureservicebus.Transport, transport_options={'wait_time_seconds': 10}) + conn = Connection( + URL_CREDS, + transport=azureservicebus.Transport, + transport_options={'wait_time_seconds': 10} + ) channel = conn.channel() assert channel.wait_time_seconds == 10 @@ -153,7 +159,8 @@ def test_default_peek_lock_seconds(): conn = Connection(URL_CREDS, transport=azureservicebus.Transport) channel = conn.channel() - assert channel.peek_lock_seconds == azureservicebus.Channel.default_peek_lock_seconds + assert channel.peek_lock_seconds == \ + azureservicebus.Channel.default_peek_lock_seconds def test_custom_peek_lock_seconds(): @@ -175,7 +182,7 @@ def test_invalid_peek_lock_seconds(): @pytest.fixture def random_queue(): - return 'azureservicebus_queue_{0}'.format(random.randint(1000,9999)) + return 'azureservicebus_queue_{0}'.format(random.randint(1000, 9999)) @pytest.fixture @@ -188,7 +195,10 @@ def mock_asb_management(mock_asb): return ASBMgmtMock(queues=mock_asb.queues) -MockQueue = namedtuple('MockQueue', ['queue_name', 'asb', 'asb_mgmt', 'conn', 'channel', 'producer', 'queue']) +MockQueue = namedtuple( + 'MockQueue', + ['queue_name', 'asb', 'asb_mgmt', 'conn', 'channel', 'producer', 'queue'] +) @pytest.fixture diff --git a/t/unit/transport/test_redis.py b/t/unit/transport/test_redis.py index 8a73db43..faa01f6d 100644 --- a/t/unit/transport/test_redis.py +++ b/t/unit/transport/test_redis.py @@ -1473,7 +1473,7 @@ class test_RedisSentinel: 'ssl_certfile': '/foo/cert.crt', 'ssl_keyfile': '/foo/pkey.key' } - with patch('redis.sentinel.Sentinel') as patched: + with patch('redis.sentinel.Sentinel'): with Connection( 'sentinel://', transport_options={'master_name': 'not_important'}, |