Skip to content

Commit

Permalink
Stringify 'queue' parameter in payload
Browse files Browse the repository at this point in the history
Bug which alters the normal functioning of the sensor.
  • Loading branch information
stefangusa authored and Stefan Gusa committed May 17, 2020
1 parent 5414688 commit ac4c854
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
@@ -1,5 +1,8 @@
# Changelog

## 1.3.4
- Change `queue` parameter type in sensor payload from `urllib.parse.ParseResult` to `str`.

## 1.3.3
- Fix aliases 'ec2_start_instance' and 'ec2_stop_instance'

Expand Down
2 changes: 1 addition & 1 deletion sensors/sqs_sensor.py
Expand Up @@ -84,7 +84,7 @@ def poll(self):

for msg in msgs:
if msg:
payload = {"queue": queue,
payload = {"queue": six.moves.urllib.parse.urlunparse(queue),
"account_id": account_id,
"region": region,
"body": json.loads(msg.body)}
Expand Down
11 changes: 4 additions & 7 deletions tests/test_sensor_sqs.py
@@ -1,5 +1,4 @@
import mock
import six
import yaml

from boto3.session import Session
Expand Down Expand Up @@ -213,9 +212,8 @@ def test_set_input_queues_config_dynamically(self):

# get message from queue 'hoge', 'fuga' then 'puyo'
self.assertEqual([x['payload']['queue'] for x in contexts],
[six.moves.urllib.parse.urlparse(queue) for queue in
['hoge', 'fuga', 'puyo',
'https://sqs.us-west-2.amazonaws.com/123456789098/queue_name_3']])
['hoge', 'fuga', 'puyo',
'https://sqs.us-west-2.amazonaws.com/123456789098/queue_name_3'])

@mock.patch.object(Session, 'client', mock.Mock(return_value=MockStsClient()))
@mock.patch.object(Session, 'resource',
Expand All @@ -238,9 +236,8 @@ def test_set_input_queues_config_with_list(self):
self.assertNotEqual(contexts, [])
self.assertTriggerDispatched(trigger='aws.sqs_new_message')
self.assertEqual([x['payload']['queue'] for x in contexts],
[six.moves.urllib.parse.urlparse(queue) for queue in
['foo', 'bar',
'https://sqs.us-west-2.amazonaws.com/123456789098/queue_name_3']])
['foo', 'bar',
'https://sqs.us-west-2.amazonaws.com/123456789098/queue_name_3'])

@mock.patch.object(Session, 'client', mock.Mock(return_value=MockStsClient()))
@mock.patch.object(Session, 'resource',
Expand Down

0 comments on commit ac4c854

Please sign in to comment.