<commit_before>from tests.unit import AWSMockServiceTestCase

from boto.ec2.connection import EC2Connection
from boto.ec2.snapshot import Snapshot


class TestDescribeSnapshots(AWSMockServiceTestCase):

    connection_class = EC2Connection

    def default_body(self):
        return b"""
            <DescribeSnapshotsResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
               <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
               <snapshotSet>
                  <item>
                     <snapshotId>snap-1a2b3c4d</snapshotId>
                     <volumeId>vol-1a2b3c4d</volumeId>
                     <status>pending</status>
                     <startTime>YYYY-MM-DDTHH:MM:SS.SSSZ</startTime>
                     <progress>30%</progress>
                     <ownerId>111122223333</ownerId>
                     <volumeSize>15</volumeSize>
                     <description>Daily Backup</description>
                     <tagSet>
                        <item>
                           <key>Purpose</key>
                           <value>demo_db_14_backup</value>
                        </item>
                     </tagSet>
                     <encrypted>false</encrypted>
                  </item>
               </snapshotSet>
            </DescribeSnapshotsResponse>
        """

    def test_describe_snapshots(self):
        self.set_http_response(status_code=200)
        response = self.service_connection.get_all_snapshots(['snap-1a2b3c4d', 'snap-9f8e7d6c'],
                                                             owner=['self', '111122223333'],
                                                             restorable_by='999988887777',
                                                             filters={'status': 'pending',
                                                                      'tag-value': '*db_*'})
        self.assert_request_parameters({
            'Action': 'DescribeSnapshots',
            'SnapshotId.1': 'snap-1a2b3c4d',
            'SnapshotId.2': 'snap-9f8e7d6c',
            'Owner.1': 'self',
            'Owner.2': '111122223333',
            'RestorableBy.1': '999988887777',
            'Filter.1.Name': 'status',
            'Filter.1.Value.1': 'pending',
            'Filter.2.Name': 'tag-value',
            'Filter.2.Value.1': '*db_*'},
            ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
                                  'SignatureVersion', 'Timestamp',
                                  'Version'])
        self.assertEqual(len(response), 1)
        self.assertIsInstance(response[0], Snapshot)
        self.assertEqual(response[0].id, 'snap-1a2b3c4d')<commit_msg>fix test_describe_snapshots by using OrderedDict<commit_after>from tests.unit import AWSMockServiceTestCase

from boto.ec2.connection import EC2Connection
from boto.ec2.snapshot import Snapshot
from boto.compat import OrderedDict


class TestDescribeSnapshots(AWSMockServiceTestCase):

    connection_class = EC2Connection

    def default_body(self):
        return b"""
            <DescribeSnapshotsResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
               <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
               <snapshotSet>
                  <item>
                     <snapshotId>snap-1a2b3c4d</snapshotId>
                     <volumeId>vol-1a2b3c4d</volumeId>
                     <status>pending</status>
                     <startTime>YYYY-MM-DDTHH:MM:SS.SSSZ</startTime>
                     <progress>30%</progress>
                     <ownerId>111122223333</ownerId>
                     <volumeSize>15</volumeSize>
                     <description>Daily Backup</description>
                     <tagSet>
                        <item>
                           <key>Purpose</key>
                           <value>demo_db_14_backup</value>
                        </item>
                     </tagSet>
                     <encrypted>false</encrypted>
                  </item>
               </snapshotSet>
            </DescribeSnapshotsResponse>
        """

    def test_describe_snapshots(self):
        self.set_http_response(status_code=200)
        response = self.service_connection.get_all_snapshots(['snap-1a2b3c4d', 'snap-9f8e7d6c'],
                                                             owner=['self', '111122223333'],
                                                             restorable_by='999988887777',
                                                             filters=OrderedDict((('status', 'pending'),
                                                                                  ('tag-value', '*db_*'))))
        self.assert_request_parameters({
            'Action': 'DescribeSnapshots',
            'SnapshotId.1': 'snap-1a2b3c4d',
            'SnapshotId.2': 'snap-9f8e7d6c',
            'Owner.1': 'self',
            'Owner.2': '111122223333',
            'RestorableBy.1': '999988887777',
            'Filter.1.Name': 'status',
            'Filter.1.Value.1': 'pending',
            'Filter.2.Name': 'tag-value',
            'Filter.2.Value.1': '*db_*'},
            ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
                                  'SignatureVersion', 'Timestamp',
                                  'Version'])
        self.assertEqual(len(response), 1)
        self.assertIsInstance(response[0], Snapshot)
        self.assertEqual(response[0].id, 'snap-1a2b3c4d')
{'fraction_non_alphanumeric': 0.11319722931097338, 'fraction_numerical': 0.04958075100255195, 'mean_word_length': 1.3960698689956332, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1533427', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1461, 'n_words': 185}