コード例 #1
0
 def test_download_s3_object_bucket_timeout(self, mock_logger,
                                            mock_s3_conn):
     """LookupTables - Download S3 Object, ReadTimeoutError"""
     mock_s3_conn.side_effect = ReadTimeoutError('TestPool',
                                                 'Test Read timed out.',
                                                 endpoint_url='test/url')
     self.buckets_info['bucket_name'].pop()
     LookupTables._download_s3_objects(self.buckets_info)
     assert_equal(LookupTables._tables, {})
     mock_logger.assert_called_with('Reading %s from S3 timed out',
                                    'foo.json')
コード例 #2
0
 def test_download_s3_object(self):
     """LookupTables - Download S3 Object"""
     LookupTables._download_s3_objects(self.buckets_info)
     expected_result = {
         'foo': {
             'bucket_name_key': 'foo_value'
         },
         'bar': {
             'bucket_name_key': 'bar_value'
         }
     }
     assert_equal(LookupTables._tables, expected_result)
コード例 #3
0
    def test_download_s3_object_compressed(self, mock_logger):
        """LookupTables - Download S3 Object, Compressed File"""
        put_mock_s3_object(
            'bucket_name', 'bar.json',
            zlib.compress(json.dumps({'compressed_key': 'compressed_val'})))

        expected_result = {
            'foo': {
                'bucket_name_key': 'foo_value'
            },
            'bar': {
                'compressed_key': 'compressed_val'
            }
        }

        LookupTables._download_s3_objects(self.buckets_info)

        assert_equal(LookupTables._tables, expected_result)
        mock_logger.assert_any_call('Data in \'%s\' is not compressed',
                                    'foo.json')
コード例 #4
0
 def test_download_s3_object_bucket_exception(self, mock_logger):
     """LookupTables - Download S3 Object, Bucket Does Not Exist"""
     LookupTables._download_s3_objects({'wrong_bucket': ['foo.json']})
     mock_logger.assert_called_with(
         'Encounterred error while downloading %s from %s, %s', 'foo.json',
         'wrong_bucket', 'The specified bucket does not exist')