def does_object_exist(key: str) -> bool: """Tests whether or not an object key exists Args: key: The object key to check Returns: True if the object exists, False otherwise Raises: exceptions.StorageError on any unexpected error interacting with storage """ try: return storage.does_object_exist(STORAGE_LOCATION, key) except Exception: raise exceptions.StorageError( "Uncaught exception while performing storage does_object_exist")
def test_does_object_exist_returns_true_when_existing(self, mock_head): self.assertTrue(s3.does_object_exist("loc", "key"))
def test_does_object_exist_returns_false_when_head_error(self, mock_head): self.assertFalse(s3.does_object_exist("loc", "key"))
def test_does_object_exist_calls_with_correct_params(self, mock_head): s3.does_object_exist("loc", "key") mock_head.assert_called_once_with(Bucket="loc", Key="key")