test_opendal_config_parse.py 635 B

123456789101112131415161718192021
  1. import pytest
  2. from extensions.storage.opendal_storage import is_r2_endpoint
  3. @pytest.mark.parametrize(
  4. ("endpoint", "expected"),
  5. [
  6. ("https://bucket.r2.cloudflarestorage.com", True),
  7. ("https://custom-domain.r2.cloudflarestorage.com/", True),
  8. ("https://bucket.r2.cloudflarestorage.com/path", True),
  9. ("https://s3.amazonaws.com", False),
  10. ("https://storage.googleapis.com", False),
  11. ("http://localhost:9000", False),
  12. ("invalid-url", False),
  13. ("", False),
  14. ],
  15. )
  16. def test_is_r2_endpoint(endpoint: str, expected: bool):
  17. assert is_r2_endpoint(endpoint) == expected