feat(examples): expand test suiteand improve error handling
New Features - Added extensive test configurations for Docker, React, Vue, Tailwind, pytest, and various combinations. - Introduced new scenarios such as docker_react, docker_vue, docker_react_htmx, all_postgres, all_mysql, and unified structures. Enhancements - Added missing comma in metadata dictionary for valid syntax. - Enhanced exception handling to print traceback on errors. - Updated path formatting to use consistent double‑quoted strings. - Improved cleanup of test directories and imports. Bug Fixes - Fixed syntax error in metadata dict that caused runtime failure. - Corrected path construction to use forward slashes for cross‑platform compatibility.
This commit is contained in:
2 files changed
+93
-32
No files matched your search
+88
-25
@@ -6,7 +6,7 @@ Comprehensive test for ALL djinit features and use cases.
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ def create_project(name, metadata, structure="standard"):
|
|||||||
"unified_structure": False,
|
"unified_structure": False,
|
||||||
"single_structure": False,
|
"single_structure": False,
|
||||||
"project_module_name": "config",
|
"project_module_name": "config",
|
||||||
**metadata
|
**metadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle different structures
|
# Handle different structures
|
||||||
@@ -70,7 +70,7 @@ def create_project(name, metadata, structure="standard"):
|
|||||||
project_name=name,
|
project_name=name,
|
||||||
primary_app=app_names[0] if app_names else "users",
|
primary_app=app_names[0] if app_names else "users",
|
||||||
app_names=app_names,
|
app_names=app_names,
|
||||||
metadata=full_metadata
|
metadata=full_metadata,
|
||||||
)
|
)
|
||||||
success = creator.create()
|
success = creator.create()
|
||||||
return success, test_dir
|
return success, test_dir
|
||||||
@@ -78,6 +78,7 @@ def create_project(name, metadata, structure="standard"):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f" Error: {e}")
|
print(f" Error: {e}")
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return False, test_dir
|
return False, test_dir
|
||||||
finally:
|
finally:
|
||||||
@@ -107,38 +108,100 @@ def run_all_tests():
|
|||||||
("basic_pre", "predefined", {}, ["requirements.txt"], []),
|
("basic_pre", "predefined", {}, ["requirements.txt"], []),
|
||||||
("basic_uni", "unified", {}, ["requirements.txt"], []),
|
("basic_uni", "unified", {}, ["requirements.txt"], []),
|
||||||
("basic_sgl", "single", {}, ["requirements.txt"], []),
|
("basic_sgl", "single", {}, ["requirements.txt"], []),
|
||||||
|
|
||||||
# Single features
|
# Single features
|
||||||
("docker", "standard", {"use_docker": True, "database_type": "postgresql"}, ["Dockerfile", "docker-compose.yml"], ["postgres"]),
|
(
|
||||||
("docker_mysql", "standard", {"use_docker": True, "database_type": "mysql"}, ["Dockerfile", "docker-compose.yml"], ["mysql"]),
|
"docker",
|
||||||
|
"standard",
|
||||||
|
{"use_docker": True, "database_type": "postgresql"},
|
||||||
|
["Dockerfile", "docker-compose.yml"],
|
||||||
|
["postgres"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"docker_mysql",
|
||||||
|
"standard",
|
||||||
|
{"use_docker": True, "database_type": "mysql"},
|
||||||
|
["Dockerfile", "docker-compose.yml"],
|
||||||
|
["mysql"],
|
||||||
|
),
|
||||||
("react", "standard", {"use_vite": True}, ["vite.config.js", "package.json"], ["react"]),
|
("react", "standard", {"use_vite": True}, ["vite.config.js", "package.json"], ["react"]),
|
||||||
("vue", "standard", {"use_vue": True}, ["vite.config.js", "package.json"], ["vue"]),
|
("vue", "standard", {"use_vue": True}, ["vite.config.js", "package.json"], ["vue"]),
|
||||||
("tailwind", "standard", {"use_tailwind": True}, ["requirements.txt"], ["tailwind"]),
|
("tailwind", "standard", {"use_tailwind": True}, ["requirements.txt"], ["tailwind"]),
|
||||||
("htmx", "standard", {"use_htmx": True}, ["requirements.txt"], ["htmx"]),
|
("htmx", "standard", {"use_htmx": True}, ["requirements.txt"], ["htmx"]),
|
||||||
("pytest", "standard", {"use_pytest": True}, ["pytest.ini", "conftest.py"], ["pytest"]),
|
("pytest", "standard", {"use_pytest": True}, ["pytest.ini", "conftest.py"], ["pytest"]),
|
||||||
|
|
||||||
# Combinations
|
# Combinations
|
||||||
("docker_react", "standard", {"use_docker": True, "use_vite": True, "database_type": "postgresql"}, ["Dockerfile", "vite.config.js"], ["postgres", "react"]),
|
(
|
||||||
("docker_vue", "standard", {"use_docker": True, "use_vue": True, "database_type": "postgresql"}, ["Dockerfile", "vite.config.js"], ["postgres", "vue"]),
|
"docker_react",
|
||||||
("react_pytest", "standard", {"use_vite": True, "use_pytest": True}, ["vite.config.js", "pytest.ini"], ["react", "pytest"]),
|
"standard",
|
||||||
("vue_pytest", "standard", {"use_vue": True, "use_pytest": True}, ["vite.config.js", "pytest.ini"], ["vue", "pytest"]),
|
{"use_docker": True, "use_vite": True, "database_type": "postgresql"},
|
||||||
("tailwind_htmx", "standard", {"use_tailwind": True, "use_htmx": True}, ["requirements.txt"], ["tailwind", "htmx"]),
|
["Dockerfile", "vite.config.js"],
|
||||||
|
["postgres", "react"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"docker_vue",
|
||||||
|
"standard",
|
||||||
|
{"use_docker": True, "use_vue": True, "database_type": "postgresql"},
|
||||||
|
["Dockerfile", "vite.config.js"],
|
||||||
|
["postgres", "vue"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"react_pytest",
|
||||||
|
"standard",
|
||||||
|
{"use_vite": True, "use_pytest": True},
|
||||||
|
["vite.config.js", "pytest.ini"],
|
||||||
|
["react", "pytest"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"vue_pytest",
|
||||||
|
"standard",
|
||||||
|
{"use_vue": True, "use_pytest": True},
|
||||||
|
["vite.config.js", "pytest.ini"],
|
||||||
|
["vue", "pytest"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"tailwind_htmx",
|
||||||
|
"standard",
|
||||||
|
{"use_tailwind": True, "use_htmx": True},
|
||||||
|
["requirements.txt"],
|
||||||
|
["tailwind", "htmx"],
|
||||||
|
),
|
||||||
# All features
|
# All features
|
||||||
("all_postgres", "standard", {
|
(
|
||||||
"use_docker": True, "use_vite": True, "use_tailwind": True,
|
"all_postgres",
|
||||||
"use_htmx": True, "use_pytest": True, "database_type": "postgresql"
|
"standard",
|
||||||
}, ["Dockerfile", "vite.config.js", "pytest.ini"], ["postgres", "react", "pytest"]),
|
{
|
||||||
|
"use_docker": True,
|
||||||
("all_mysql", "standard", {
|
"use_vite": True,
|
||||||
"use_docker": True, "use_vue": True, "use_tailwind": True,
|
"use_tailwind": True,
|
||||||
"use_pytest": True, "database_type": "mysql"
|
"use_htmx": True,
|
||||||
}, ["Dockerfile", "vite.config.js", "pytest.ini"], ["mysql", "vue", "pytest"]),
|
"use_pytest": True,
|
||||||
|
"database_type": "postgresql",
|
||||||
|
},
|
||||||
|
["Dockerfile", "vite.config.js", "pytest.ini"],
|
||||||
|
["postgres", "react", "pytest"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"all_mysql",
|
||||||
|
"standard",
|
||||||
|
{"use_docker": True, "use_vue": True, "use_tailwind": True, "use_pytest": True, "database_type": "mysql"},
|
||||||
|
["Dockerfile", "vite.config.js", "pytest.ini"],
|
||||||
|
["mysql", "vue", "pytest"],
|
||||||
|
),
|
||||||
# Structure tests with features
|
# Structure tests with features
|
||||||
("predefined_docker", "predefined", {"use_docker": True, "database_type": "postgresql"}, ["Dockerfile"], ["postgres"]),
|
(
|
||||||
|
"predefined_docker",
|
||||||
|
"predefined",
|
||||||
|
{"use_docker": True, "database_type": "postgresql"},
|
||||||
|
["Dockerfile"],
|
||||||
|
["postgres"],
|
||||||
|
),
|
||||||
("predefined_vue", "predefined", {"use_vue": True}, ["vite.config.js"], ["vue"]),
|
("predefined_vue", "predefined", {"use_vue": True}, ["vite.config.js"], ["vue"]),
|
||||||
("unified_docker", "unified", {"use_docker": True, "database_type": "postgresql"}, ["Dockerfile"], ["postgres"]),
|
(
|
||||||
|
"unified_docker",
|
||||||
|
"unified",
|
||||||
|
{"use_docker": True, "database_type": "postgresql"},
|
||||||
|
["Dockerfile"],
|
||||||
|
["postgres"],
|
||||||
|
),
|
||||||
("unified_vue", "unified", {"use_vue": True}, ["vite.config.js"], ["vue"]),
|
("unified_vue", "unified", {"use_vue": True}, ["vite.config.js"], ["vue"]),
|
||||||
("single_docker", "single", {"use_docker": True, "database_type": "postgresql"}, ["Dockerfile"], ["postgres"]),
|
("single_docker", "single", {"use_docker": True, "database_type": "postgresql"}, ["Dockerfile"], ["postgres"]),
|
||||||
("single_vue", "single", {"use_vue": True}, ["vite.config.js"], ["vue"]),
|
("single_vue", "single", {"use_vue": True}, ["vite.config.js"], ["vue"]),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ Comprehensive test for all djinit features including Vue.
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
||||||
|
|
||||||
from djinit.creators.setup import SetupCreator
|
from djinit.creators.setup import SetupCreator
|
||||||
|
|
||||||
@@ -37,15 +37,11 @@ def create_project(name, metadata):
|
|||||||
"unified_structure": False,
|
"unified_structure": False,
|
||||||
"single_structure": False,
|
"single_structure": False,
|
||||||
"project_module_name": "config",
|
"project_module_name": "config",
|
||||||
**metadata
|
**metadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
creator = SetupCreator(
|
creator = SetupCreator(
|
||||||
project_dir=name,
|
project_dir=name, project_name=name, primary_app="users", app_names=["users"], metadata=full_metadata
|
||||||
project_name=name,
|
|
||||||
primary_app="users",
|
|
||||||
app_names=["users"],
|
|
||||||
metadata=full_metadata
|
|
||||||
)
|
)
|
||||||
success = creator.create()
|
success = creator.create()
|
||||||
return success, test_dir
|
return success, test_dir
|
||||||
@@ -53,6 +49,7 @@ def create_project(name, metadata):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f" Error: {e}")
|
print(f" Error: {e}")
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return False, test_dir
|
return False, test_dir
|
||||||
finally:
|
finally:
|
||||||
@@ -93,6 +90,7 @@ def run_tests():
|
|||||||
print(f" Metadata: {metadata}")
|
print(f" Metadata: {metadata}")
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
test_dir = "/tmp/djinit_vue_test"
|
test_dir = "/tmp/djinit_vue_test"
|
||||||
if os.path.exists(test_dir):
|
if os.path.exists(test_dir):
|
||||||
shutil.rmtree(test_dir)
|
shutil.rmtree(test_dir)
|
||||||
|
|||||||
Reference in new issue
Block a user