Skip to content

Commit b7dfa46

Browse files
committed
CMR-10388: Fixing commented out test.
1 parent bf3da75 commit b7dfa46

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

subscription/test/subscription_worker_test.py

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import unittest
23
from unittest.mock import patch, MagicMock
34
import boto3
@@ -53,12 +54,53 @@ def test_process_messages(self, mock_access_control, mock_sns):
5354
mock_access_control_instance = MagicMock()
5455
mock_access_control.return_value = mock_access_control_instance
5556

56-
#messages = {'Messages': [{'Body': 'test message'
57-
# 'MessageAttributes': {"type": "subscriber"
58-
# "Value": "user1"}}]}
59-
#process_messages(mock_sns_instance, 'test-topic', messages, mock_access_control_instance)
57+
mock_access_control_instance.has_read_permission.return_value = True
58+
59+
# messages = {'Messages': [{'Body': {'Type': 'Notification',
60+
# 'MessageId': 'dfb70dfe-6f63-5cfc-9a5f-6dc731b504de',
61+
# 'TopicArn': 'arn:name',
62+
# 'Subject': 'Update Notification',
63+
# 'Message': '{"concept-id": "G1200484365-PROV", "granule-ur": "gnss.rnx.gz.json", "producer-granule-id": "gnss.rnx.gz", "location": "http://localhost:3003/concepts/G1200484365-PROV/4"}',
64+
# 'Timestamp': '2025-02-26T18:25:26.951Z',
65+
# 'SignatureVersion': '1',
66+
# 'Signature': 'HIQ==',
67+
# 'SigningCertURL': 'https://sns.region.amazonaws.com/SNS-9.pem',
68+
# 'UnsubscribeURL': 'https://sns.region.amazonaws.com/?Ac',
69+
# 'MessageAttributes': {'mode': {'Type': 'String', 'Value': 'Update'},
70+
# 'collection-concept-id': {'Type': 'String', 'Value': 'C1200484363-PROV'},
71+
# 'endpoint': {'Type': 'String', 'Value': 'http://notification/tester'},
72+
# 'subscriber': {'Type': 'String', 'Value': 'user1_test'},
73+
# 'endpoint-type': {'Type': 'String', 'Value': 'url'}}}}]}
74+
messages = {
75+
'Messages': [{
76+
'Body': json.dumps({
77+
'Type': 'Notification',
78+
'MessageId': 'dfb70dfe-6f63-5cfc-9a5f-6dc731b504de',
79+
'TopicArn': 'arn:name',
80+
'Subject': 'Update Notification',
81+
'Message': '{"concept-id": "G1200484365-PROV", "granule-ur": "gnss.rnx.gz.json", "producer-granule-id": "gnss.rnx.gz", "location": "http://localhost:3003/concepts/G1200484365-PROV/4"}',
82+
'Timestamp': '2025-02-26T18:25:26.951Z',
83+
'SignatureVersion': '1',
84+
'Signature': 'HIQ==',
85+
'SigningCertURL': 'https://sns.region.amazonaws.com/SNS-9.pem',
86+
'UnsubscribeURL': 'https://sns.region.amazonaws.com/?Ac',
87+
'MessageAttributes': {
88+
'mode': {'Type': 'String', 'Value': 'Update'},
89+
'collection-concept-id': {'Type': 'String', 'Value': 'C1200484363-PROV'},
90+
'endpoint': {'Type': 'String', 'Value': 'http://notification/tester'},
91+
'subscriber': {'Type': 'String', 'Value': 'user1_test'},
92+
'endpoint-type': {'Type': 'String', 'Value': 'url'}
93+
}
94+
})
95+
}]
96+
}
97+
98+
process_messages(mock_sns_instance, 'test-topic', messages, mock_access_control_instance)
99+
100+
# Check if has_read_permission was called with correct arguments
101+
mock_access_control_instance.has_read_permission.assert_called_once_with('user1_test', 'C1200484363-PROV')
60102

61-
#mock_sns_instance.publish_message.assert_called_once_with('test-topic', {'Body': 'test message'})
103+
mock_sns_instance.publish_message.assert_called_once_with('test-topic', messages['Messages'][0])
62104

63105
if __name__ == '__main__':
64106
unittest.main()

0 commit comments

Comments
 (0)