Exemplo n.º 1
0
 def test_list_objects_calls_with_correct_params(self, mock_paginator):
     mock_paginate = MagicMock()
     mock_paginate.paginate = MagicMock(return_value=[{}])
     mock_paginator.return_value = mock_paginate
     s3.list_objects("loc", "pre")
     mock_paginator.assert_called_once_with("list_objects_v2")
     mock_paginate.paginate.assert_called_once_with(Bucket="loc", Prefix="pre")
Exemplo n.º 2
0
 def test_list_objects_filters_folders(self, mock_paginator):
     mock_paginate = MagicMock()
     mock_paginate.paginate = MagicMock(return_value=[{
         "Contents": [{
             "Key": "val1/"
         }, {
             "Key": "val2/"
         }]
     }])
     mock_paginator.return_value = mock_paginate
     self.assertEqual(s3.list_objects("loc", "pre"), [])
Exemplo n.º 3
0
 def test_list_objects_calls_returns_valid_keys(self, mock_paginator):
     mock_paginate = MagicMock()
     mock_paginate.paginate = MagicMock(return_value=[{
         "Contents": [{
             "Key": "val1"
         }, {
             "Key": "val2"
         }]
     }])
     mock_paginator.return_value = mock_paginate
     self.assertEqual(s3.list_objects("loc", "pre"), ["val1", "val2"])
Exemplo n.º 4
0
def list_objects(prefix: str) -> List[str]:
    """List object keys under a common prefix
    Args:
        prefix The prefix key to scan
    Returns:
        list of string keys on success
    Raises:
        exceptions.StorageError on any unexpected error interacting with storage
    """
    try:
        return storage.list_objects(STORAGE_LOCATION, prefix)
    except Exception:
        raise exceptions.StorageError(
            "Uncaught exception while performing storage list_objects")