"""Tests for JSON Schema generation.""" from config_convert.utils import generate_schema class TestGenerateSchema: def test_string_schema(self): result = generate_schema("hello") assert result["type"] == "string" def test_integer_schema(self): result = generate_schema(123) assert result["type"] == "integer" def test_float_schema(self): result = generate_schema(3.14) assert result["type"] == "number" def test_boolean_schema(self): result = generate_schema(True) assert result["type"] == "boolean" def test_null_schema(self): result = generate_schema(None) assert result["type"] == "null" def test_array_schema(self): result = generate_schema([1, 2, 3]) assert result["type"] == "array" def test_object_schema(self): result = generate_schema({"name": "test"}) assert result["type"] == "object" assert "properties" in result def test_nested_object_schema(self): data = {"database": {"host": "localhost", "port": 5432}} result = generate_schema(data) assert result["type"] == "object" assert "properties" in result assert "database" in result["properties"] assert result["properties"]["database"]["type"] == "object" def test_object_with_array_schema(self): data = {"tags": ["a", "b"]} result = generate_schema(data) assert result["type"] == "object" assert result["properties"]["tags"]["type"] == "array" def test_complex_schema(self): data = { "name": "test", "version": "1.0.0", "enabled": True, "count": 42, "ratio": 3.14, "database": { "host": "localhost", "port": 5432 }, "tags": ["a", "b", "c"] } result = generate_schema(data) assert result["type"] == "object" assert "properties" in result assert result["properties"]["name"]["type"] == "string" assert result["properties"]["count"]["type"] == "integer" assert result["properties"]["enabled"]["type"] == "boolean" assert result["properties"]["ratio"]["type"] == "number"