# Path: qarnot/_util.py
# def get_sanitized_bucket_path(path: str, show_warning: bool = True):
#     if path is not None:
#         original_path = path
#         warning = ""
#         directory_separators = ['/', '\\']
#         for separator in directory_separators:
#             double_separator = separator + separator
#             while path.__contains__(double_separator):
#                 warning = "Warning: Bucket path should not contain duplicated slashes (" + double_separator + ")\n"
#                 path = path.replace(double_separator, separator)
#             if path.startswith(separator):
#                 warning += "Warning: Bucket path should not start with a slash (" + separator + ")\n"
#                 path = path.lstrip(separator)
#         if path != original_path:
#             warning += "Path changed from " + original_path + " to " + path + "\n"
#             warning += "If bucket path sanitization is not wanted, please open a new connection with the constructor flag 'sanitize_bucket_paths=False'"
#         if show_warning:
#             print(warning)
#         return path.strip()
#     return path


from qarnot._util import get_sanitized_bucket_path

class TestUtilTools:

    def test_sanitize_bucket_path(self):
        assert "some/Invalid/Path/" == get_sanitized_bucket_path("/some//Invalid///Path/")

# Path: qarnot/_util.py
# def get_sanitized_bucket_path(path: str, show_warning: bool = True):
#     if path is not None:
#         original_path = path
#         warning = ""
#         directory_separators = ['/', '\\']
#         for separator in directory_separators:
#             double_separator = separator + separator
#             while path.__contains__(double_separator):
#                 warning = "Warning: Bucket path should not contain duplicated slashes (" + double_separator + ")\n"
#                 path = path.replace(double_separator, separator)
#             if path.startswith(separator):
#                 warning += "Warning: Bucket path should not start with a slash (" + separator + ")\n"
#                 path = path.lstrip(separator)
#         if path != original_path:
#             warning += "Path changed from " + original_path + " to " + path + "\n"
#             warning += "If bucket path sanitization is not wanted, please open a new connection with the constructor flag 'sanitize_bucket_paths=False'"
#         if show_warning:
#             print(warning)
#         return path.strip()
#     return path


# Path: test/test_util.py
from qarnot._util import get_sanitized_bucket_path


class TestUtilTools:

    def test_sanitize_bucket_path(self):
        assert "some/Invalid/Path/" == get_sanitized_bucket_path("/some//Invalid///Path/")

        assert "some\\Invalid\\Path\\" == get_sanitized_bucket_path("\\some\\\\Invalid\\\\\\Path\\")