Skip to content

Fix sqs arn #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions skew/resources/aws/sqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ def __init__(self, client, data, query=None):
self.data = {self.Meta.id: data,
'QueueName': data.split('/')[-1]}
self._id = self.data['QueueName']

@property
def arn(self):
return 'arn:aws:%s:%s:%s:%s' % (
self._client.service_name,
self._client.region_name,
self._client.account_id,
self.id)
9 changes: 9 additions & 0 deletions tests/unit/responses/queues/sqs.ListQueueTags_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"status_code": 200,
"data": {
"Tags": {
"Env": "Production",
"Project": "Marketing"
}
}
}
9 changes: 9 additions & 0 deletions tests/unit/responses/queues/sqs.ListQueues_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"status_code": 200,
"data": {
"QueueUrls": [
"https://us-east-1.queue.amazonaws.com/123456789012/someq"
]
}

}
14 changes: 13 additions & 1 deletion tests/unit/test_arn.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ def test_ec2_address(self):
self.assertEqual(l[2].data['Tags'],
[{'Key': 'Name', 'Value': 'some-name'}, {'Key': 'Env', 'Value': 'Prod'}])


def test_vpc_peering_connection(self):
placebo_cfg = {
'placebo': placebo,
Expand All @@ -401,4 +400,17 @@ def test_vpc_peering_connection(self):
self.assertEqual(len(l), 1)
self.assertEqual(l[0].arn, 'arn:aws:ec2:us-east-1:123456789012:vpc-peering-connection/pcx-027a582b95db2af78')

def test_sqs_queue(self):
placebo_cfg = {
'placebo': placebo,
'placebo_dir': self._get_response_path('queues'),
'placebo_mode': 'playback'}

arn = scan(
'arn:aws:sqs:us-east-1:123456789012:queue/*',
**placebo_cfg)
l = list(arn)
self.assertEqual(len(l), 1)
self.assertEqual(l[0].arn, 'arn:aws:sqs:us-east-1:123456789012:someq')
self.assertEqual(l[0].tags['Env'], 'Production')
self.assertEqual(l[0].tags['Project'], 'Marketing')