Docs: Consolidate admin documentation and migrate reference data
- Created LOCAL_DEVELOPMENT_GUIDE.md and DEPLOYMENT_GUIDE_MANUAL.md from legacy txt files. - Migrated country/time_zone data and requirements.txt to documentation/reference_data/. - Removed redundant admin/documentation/ and admin/data_files/ directories. - Enhanced app/lib_schema_v3.py to explicitly capture 'required' fields from DB 'NOT NULL' constraint. - Added verification tests for schema logic and standalone DB connectivity.
This commit is contained in:
44
tests/test_lib_schema_isolated.py
Normal file
44
tests/test_lib_schema_isolated.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
# Add current directory to path
|
||||
sys.path.append(os.getcwd())
|
||||
|
||||
# 1. Mock EVERYTHING before importing the target
|
||||
mock_config = MagicMock()
|
||||
mock_config.settings = MagicMock()
|
||||
sys.modules["app.config"] = mock_config
|
||||
|
||||
mock_db = MagicMock()
|
||||
sys.modules["app.db_sql"] = MagicMock(db=mock_db)
|
||||
|
||||
# 2. Mock DESCRIBE result
|
||||
mock_row = [
|
||||
("created_on", "timestamp", "NO", "", "current_timestamp()", "")
|
||||
]
|
||||
mock_db.execute.return_value.fetchall.return_value = mock_row
|
||||
|
||||
# 3. Import and test
|
||||
from app.lib_schema_v3 import get_object_schema_info
|
||||
|
||||
def test_isolated_logic():
|
||||
# We need to mock obj_type_kv_li as well
|
||||
import app.lib_schema_v3
|
||||
app.lib_schema_v3.obj_type_kv_li = {"journal": {"tbl": "journal", "mdl": MagicMock()}}
|
||||
|
||||
print("Testing isolated logic for get_object_schema_info...")
|
||||
info = get_object_schema_info("journal")
|
||||
|
||||
col = info["database"]["columns"][0]
|
||||
print(f"Resulting column info: {json.dumps(col, indent=2)}")
|
||||
|
||||
assert col["field"] == "created_on"
|
||||
assert col["db_type"] == "timestamp"
|
||||
assert col["required"] is True
|
||||
assert col["db_default"] == "current_timestamp()"
|
||||
print("\nIsolated test passed! The logic in lib_schema_v3 is correct.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_isolated_logic()
|
||||
Reference in New Issue
Block a user