Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e41ebb9
fix: Handled inventory as default in getEnvDefinition method
bijjalmayank Apr 24, 2026
78dee69
fix: Remove 'inventory' from required fields in schema
bijjalmayank Apr 24, 2026
c92c04a
Fix: Remove 'inventory' from required fields in schema (#1239)
bijjalmayank Apr 20, 2026
3b6d5a3
fix: Removed inventory from schema and handled defualt inventory in g…
bijjalmayank Apr 24, 2026
41dcdf2
fix: Added test_getEnvDefinition.py for business_helper.py
bijjalmayank Apr 29, 2026
6e5f923
fix: Added test_business_helper.py for business_helper.py
bijjalmayank Apr 29, 2026
13488c1
fix: Added test_getEnvDefinition.py for business_helper.py (#1269)
bijjalmayank Apr 29, 2026
c67e277
fix: Added logging in test_business_helper.py
bijjalmayank Apr 29, 2026
1445116
fix: Added logging in test_business_helper.py
bijjalmayank Apr 29, 2026
6956ddb
Merge branch 'feature/inventory-optional' into feature/local-inventor…
KamalArya Apr 29, 2026
ba72ed4
fix: parameterize getEnvDefinition tests using structured test cases
bijjalmayank Apr 30, 2026
f0963c9
Fix: Remove 'inventory' from required fields in schema (#1239)
bijjalmayank Apr 20, 2026
353af95
fix: Removed inventory from schema and handled defualt inventory in g…
bijjalmayank Apr 24, 2026
6c734bf
fix: Added test_getEnvDefinition.py for business_helper.py (#1269)
bijjalmayank Apr 29, 2026
6345983
fix: Added logging in test_business_helper.py (#1274)
bijjalmayank Apr 29, 2026
a877c88
fix: deleted unused test file
KamalArya Apr 29, 2026
4f387a5
fix: remove redundant logging
bijjalmayank Apr 30, 2026
a8bb0b5
Merge branch 'feature/inventory-optional' into feature/local-inventor…
KamalArya Apr 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion python/envgene/envgenehelper/business_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ def getEnvDefinition(env_dir = None):
env_definition_path = getEnvDefinitionPath(env_dir)
if not check_file_exists(env_definition_path):
raise ReferenceError(f"Environment definition for env {env_dir} is not found in {env_definition_path}")
return openYaml(env_definition_path)
env_definition_yaml = openYaml(env_definition_path)
if 'inventory' not in env_definition_yaml:
logger.warning(f"'inventory' section is not found in env_definition.yml for env {env_dir}. Adding empty 'inventory' section to avoid errors in plugins.")
env_definition_yaml['inventory'] = {}
return env_definition_yaml



def getEnvDefinitionPath(env_dir) -> str:
Expand Down
92 changes: 92 additions & 0 deletions python/envgene/envgenehelper/test_business_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
from .business_helper import getEnvDefinition
import pytest
import logging

@pytest.fixture(scope="session", autouse=True)
def log_start():
logging.basicConfig(level=logging.INFO, force=True)

@pytest.fixture(scope="session", autouse=True)
def log_end(request):
yield
if request.session.testsfailed == 0:
logging.info("===== test_business_helper.py : All test cases passed successfully =====")


test_cases = [
{
"name": "Inventory Missing",
"input_yaml": {"applications": []},
"file_exists": True,
"expected_inventory": {},
"expect_exception": None,
"env_dir": "test_env",
},
{
"name": "Inventory Exists",
"input_yaml": {"inventory": {"a": 1}},
"file_exists": True,
"expected_inventory": {"a": 1},
"expect_exception": None,
"env_dir": "test_env",
},
{
"name": "File Not Found",
"input_yaml": None,
"file_exists": False,
"expected_inventory": None,
"expect_exception": ReferenceError,
"env_dir": "test_env",
},
{
"name": "Env Dir Fallback",
"input_yaml": {"applications": []},
"file_exists": True,
"expected_inventory": {},
"expect_exception": None,
"env_dir": None,
},
{
"name": "Empty YAML",
"input_yaml": {},
"file_exists": True,
"expected_inventory": {},
"expect_exception": None,
"env_dir": "test_env",
},
]

@pytest.mark.parametrize(
"case",
test_cases,
ids=[case["name"] for case in test_cases]
)
def test_get_env_definition(case, monkeypatch):
monkeypatch.setattr(
"envgenehelper.business_helper.getEnvDefinitionPath",
lambda x: "dummy_path"
)
monkeypatch.setattr(
"envgenehelper.business_helper.check_file_exists",
lambda x: case["file_exists"]
)
if case["input_yaml"] is not None:
monkeypatch.setattr(
"envgenehelper.business_helper.openYaml",
lambda x: case["input_yaml"].copy()
)
monkeypatch.setattr(
"envgenehelper.business_helper.get_current_env_dir_from_env_vars",
lambda: "env_from_vars"
)
if case["expect_exception"]:
with pytest.raises(case["expect_exception"]):
getEnvDefinition(case["env_dir"])
return

result = getEnvDefinition(case["env_dir"])
assert "inventory" in result
assert result["inventory"] == case["expected_inventory"]

if case["name"] == "Inventory Exists":
assert result["inventory"] == case["input_yaml"]["inventory"]
1 change: 0 additions & 1 deletion schemas/env-definition.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@
}
},
"required": [
"inventory",
"envTemplate"
]
}
Loading