From 66addf75e37054ec94d9ae9657ebdd2f8efc92bc Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Wed, 4 Feb 2026 07:05:36 +0000 Subject: [PATCH] Initial upload: ConfigConvert CLI with full test suite and CI/CD --- tests/test_schema.py | 71 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/test_schema.py diff --git a/tests/test_schema.py b/tests/test_schema.py new file mode 100644 index 0000000..bbaa9d5 --- /dev/null +++ b/tests/test_schema.py @@ -0,0 +1,71 @@ +"""Tests for JSON Schema generation.""" + +import pytest + +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"