Test Failed
Pull Request — master (#23)
by George
01:42
created

mock_send_message()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
from unittest import mock
2
3
from asynctest import CoroutineMock
0 ignored issues
show
Configuration introduced by
The import asynctest could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
4
import pytest
5
6
7
# boto client methods mock
8
9
@pytest.fixture
10
def queue_url():
11
    queue_url = 'https://sqs.us-east-1.amazonaws.com/123456789012/queue-name'
12
    return {'QueueUrl': queue_url}
13
14
15
@pytest.fixture
16
def sqs_message():
17
    message = {'Body': 'test'}
18
    return {'Messages': [message]}
19
20
21
def sqs_send_message():
22
    return {'MessageId': 'uuid', 'MD5OfMessageBody': 'md5',
23
            'ResponseMetada': {'RequestId': 'uuid', 'HTTPStatusCode': 200}}
24
25
26
@pytest.fixture
27
def sns_list_topics():
28
    return {'Topics': [{'TopicArn': 'arn:aws:sns:region:id:topic-name'}]}
29
30
31
@pytest.fixture
32
def sns_publish():
33
    return {'ResponseMetadata': {'HTTPStatusCode': 200, 'RequestId': 'uuid'},
34
            'MessageId': 'uuid'}
35
36
37
# boto client mock
38
39
40
@pytest.fixture
41
def boto_client_sqs(queue_url, sqs_message):
42
    mock_client = CoroutineMock()
43
    mock_client.get_queue_url.return_value = queue_url
44
    mock_client.delete_message.return_value = mock.Mock()
45
    mock_client.receive_message.return_value = sqs_message
46
    mock_client.send_message.return_value = sqs_send_message
47
    return mock_client
48
49
50
@pytest.fixture
51
def mock_boto_session_sqs(boto_client_sqs):
52
    mock_session = mock.Mock()
53
    mock_session.create_client = mock.Mock(return_value=boto_client_sqs)
54
    return mock.patch('aiobotocore.get_session', return_value=mock_session)
55
56
57
@pytest.fixture
58
def boto_client_sns(sns_publish, sns_list_topics):
59
    mock_client = CoroutineMock()
60
    mock_client.list_topics.return_value = sns_list_topics
61
    mock_client.publish.return_value = sns_publish
62
    return mock_client
63
64
65
@pytest.fixture
66
def mock_boto_session_sns(boto_client_sns):
67
    mock_session = mock.Mock()
68
    mock_session.create_client = mock.Mock(return_value=boto_client_sns)
69
    return mock.patch('aiobotocore.get_session', return_value=mock_session)
70