fixing project() func to read project.json

This commit is contained in:
evanchia
2021-06-16 11:29:14 -07:00
parent 009e96d601
commit 017845e285
2 changed files with 12 additions and 8 deletions
@@ -63,12 +63,15 @@ def _find_project_json(engine_root, project):
# Look at the "projects" key for registered project paths
try:
for projects_path in json_data["projects"]:
# Only look at project directories that match our project
if project == os.path.basename(projects_path):
check_project_json = os.path.join(projects_path, 'project.json')
# Check for the project.json file inside of the project directory
if os.path.isfile(check_project_json):
project_json = check_project_json
check_project_json = os.path.join(projects_path, 'project.json')
# Check for the project.json file inside of the project directory
if os.path.isfile(check_project_json):
# Check if the "project_name" key matches our project
with open(check_project_json, "r") as project_json_file:
project_json_data = json.load(project_json_file)
if project == project_json_data["project_name"]:
project_json = check_project_json
break
except KeyError:
pass # No projects found in the manifest json
@@ -24,7 +24,8 @@ mock_engine_root = "mock_engine_root"
mock_dev_path = "mock_dev_path"
mock_build_directory = 'mock_build_directory'
mock_project = 'mock_project'
mock_manifest_json = {'projects': [mock_project]}
mock_manifest_json_file = {'projects': [mock_project]}
mock_project_json_file = {'project_name': mock_project}
mock_project_json = os.path.join(mock_project, 'project.json')
@@ -54,7 +55,7 @@ class TestFindProjectJson(object):
@mock.patch('os.path.isfile', mock.MagicMock(return_value=True))
@mock.patch('os.path.basename', mock.MagicMock(return_value=mock_project))
@mock.patch('json.load', mock.MagicMock(return_value=mock_manifest_json))
@mock.patch('json.load', mock.MagicMock(side_effect=[mock_manifest_json_file, mock_project_json_file]))
def test_FindProjectJson_ManifestJson_ReturnsProjectJson(self):
project = abstract_resource_locator._find_project_json(mock_engine_root, mock_project)