test_jsonschema_specifications.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from collections.abc import Mapping
  2. from pathlib import Path
  3. import pytest
  4. from jsonschema_specifications import REGISTRY
  5. def test_it_contains_metaschemas():
  6. schema = REGISTRY.contents("http://json-schema.org/draft-07/schema#")
  7. assert isinstance(schema, Mapping)
  8. assert schema["$id"] == "http://json-schema.org/draft-07/schema#"
  9. assert schema["title"] == "Core schema meta-schema"
  10. def test_it_is_crawled():
  11. assert REGISTRY.crawl() == REGISTRY
  12. @pytest.mark.parametrize(
  13. "ignored_relative_path",
  14. ["schemas/.DS_Store", "schemas/draft7/.DS_Store"],
  15. )
  16. def test_it_copes_with_dotfiles(ignored_relative_path):
  17. """
  18. Ignore files like .DS_Store if someone has actually caused one to exist.
  19. We test here through the private interface as of course the global has
  20. already loaded our schemas.
  21. """
  22. import jsonschema_specifications
  23. package = Path(jsonschema_specifications.__file__).parent
  24. ignored = package / ignored_relative_path
  25. ignored.touch()
  26. try:
  27. list(jsonschema_specifications._schemas())
  28. finally:
  29. ignored.unlink()