def test_infer_schema(): item1 = { "url": "https://example.com", "id": 0, "race": {"t": "21k"}, "a": [{"k": "v"}], } item2 = { "url": "https://example.com", "id": 1, "race": {"t": "10k"}, "a": [{"k": "v"}], } assert schema_tools.infer_schema([item1, item2]) == schema assert schema_tools.infer_schema([item2]) == schema
def test_infer_schema(): item1 = {"url": "https://example.com", "_key": 0} item2 = {"url": "https://example.com", "_key": 1} schema = { "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "float": {"pattern": r"^-?[0-9]+\.[0-9]{2}$"}, "url": { "pattern": ( r"^https?://(www\.)?[a-z0-9.-]*\.[a-z]{2,}" r"([^<>%\x20\x00-\x1f\x7F]|%[0-9a-fA-F]{2})*$" ) }, }, "type": "object", "properties": {"url": {"type": "string"}, "_key": {"type": "integer"}}, "additionalProperties": False, "required": ["_key", "url"], } assert infer_schema([item1, item2]) == schema assert infer_schema([item2]) == schema
def test_infer_schema(): item1 = {"url": "https://example.com", "id": 0} item2 = {"url": "https://example.com", "id": 1} assert schema_tools.infer_schema([item1, item2]) == schema assert schema_tools.infer_schema([item2]) == schema