|
@@ -65,7 +65,7 @@ TEST_O3DE_REPOB_JSON_PAYLOAD = '''
|
|
|
}
|
|
|
'''
|
|
|
|
|
|
-# This holds the repo 2.0.0 schema, which houses all relevant objects in file
|
|
|
+# This holds the repo 1.0.0 schema, which houses all relevant objects in file
|
|
|
# A possible future field for the version data is download_prebuilt_uri,
|
|
|
# which indicates where to download dedicated binaries of a version of the O3DE object.
|
|
|
TEST_O3DE_REPO_JSON_VERSION_2_FILENAME = '3b14717bafd5a3bd768d3d0791a44998c3bd0fb2bfa1a7e2ee8bb1a39b04d631.json'
|
|
@@ -75,7 +75,7 @@ TEST_O3DE_REPO_JSON_VERSION_2_PAYLOAD = '''
|
|
|
|
|
|
"origin": "Studios",
|
|
|
|
|
|
- "$schemaVersion":"2.0.0",
|
|
|
+ "$schemaVersion":"1.0.0",
|
|
|
|
|
|
"repo_uri": "https://downloads.testgem3.com/o3de-repo",
|
|
|
|
|
@@ -107,26 +107,14 @@ TEST_O3DE_REPO_JSON_VERSION_2_PAYLOAD = '''
|
|
|
"dependencies": [],
|
|
|
"versions_data": [{
|
|
|
"origin_uri": "https://downloads.testgem3.com/o3de-repo/testgem3-2.15/O3DE_testgem3Gem_v2.0.0_Win64_Linux64_Mac64.zip",
|
|
|
- "version": "2.0.0",
|
|
|
+ "version": "1.0.0",
|
|
|
"last_updated": "2021-03-09"
|
|
|
},
|
|
|
{
|
|
|
- "display_name": "testgem3 2.15.4",
|
|
|
+ "display_name": "testgem3 2.0.0",
|
|
|
"download_source_uri": "https://downloads.testgem3.com/o3de-repo/testgem3-2.15/O3DE_testgem3Gem_v2.15.4_Win64_Linux64_Mac64.zip",
|
|
|
- "version": "2.15.4",
|
|
|
+ "version": "2.0.0",
|
|
|
"last_updated": "2023-03-09"
|
|
|
- },
|
|
|
- {
|
|
|
- "display_name": "testgem3 3.1.2",
|
|
|
- "source_control_uri": "https://github.com/testgem3/O3DEtestgem3Plugin.git",
|
|
|
- "version": "3.1.2",
|
|
|
- "last_updated": "2025-02-19"
|
|
|
- },
|
|
|
- {
|
|
|
- "display_name": "testgem3 3.2.0",
|
|
|
- "origin_uri": "https://github.com/testgem3/O3DEtestgem3Plugin",
|
|
|
- "version": "3.2.0",
|
|
|
- "last_updated": "2025-02-19"
|
|
|
}
|
|
|
]
|
|
|
}],
|
|
@@ -181,6 +169,60 @@ TEST_O3DE_REPO_JSON_VERSION_2_PAYLOAD = '''
|
|
|
}
|
|
|
'''
|
|
|
|
|
|
+TEST_O3DE_REPO_GEM3_JSON_VERSION_1_PAYLOAD = '''
|
|
|
+{
|
|
|
+ "gem_name": "testgem3",
|
|
|
+ "display_name": "testgem3 2",
|
|
|
+ "download_api": "HTTP",
|
|
|
+ "license": "Community",
|
|
|
+ "license_url": "https://www.testgem3.com/testgem3-community-license",
|
|
|
+ "origin": "Persistant Studios - testgem3.com",
|
|
|
+ "requirements": "Users will need to download testgem3 Editor from the <a href='https://www.testgem3.com/download/'>testgem3 Web Site</a> to edit/author effects.",
|
|
|
+ "documentation_url": "https://www.testgem3.com/docs/testgem3-v2/plugins/o3de-gem/",
|
|
|
+ "type": "Code",
|
|
|
+ "summary": "The testgem3 Gem provides real-time FX solution for particle effects.",
|
|
|
+ "canonical_tags": [
|
|
|
+ "Gem"
|
|
|
+ ],
|
|
|
+ "user_tags": [
|
|
|
+ "Particles",
|
|
|
+ "Simulation",
|
|
|
+ "SDK"
|
|
|
+ ],
|
|
|
+ "dependencies": [],
|
|
|
+ "origin_uri": "https://downloads.testgem3.com/o3de-repo/testgem3-2.15/O3DE_testgem3Gem_v2.0.0_Win64_Linux64_Mac64.zip",
|
|
|
+ "version": "1.0.0",
|
|
|
+ "last_updated": "2021-03-09"
|
|
|
+}
|
|
|
+'''
|
|
|
+
|
|
|
+TEST_O3DE_REPO_GEM3_JSON_VERSION_2_PAYLOAD = '''
|
|
|
+{
|
|
|
+ "gem_name": "testgem3",
|
|
|
+ "download_api": "HTTP",
|
|
|
+ "license": "Community",
|
|
|
+ "license_url": "https://www.testgem3.com/testgem3-community-license",
|
|
|
+ "origin": "Persistant Studios - testgem3.com",
|
|
|
+ "requirements": "Users will need to download testgem3 Editor from the <a href='https://www.testgem3.com/download/'>testgem3 Web Site</a> to edit/author effects.",
|
|
|
+ "documentation_url": "https://www.testgem3.com/docs/testgem3-v2/plugins/o3de-gem/",
|
|
|
+ "type": "Code",
|
|
|
+ "summary": "The testgem3 Gem provides real-time FX solution for particle effects.",
|
|
|
+ "canonical_tags": [
|
|
|
+ "Gem"
|
|
|
+ ],
|
|
|
+ "user_tags": [
|
|
|
+ "Particles",
|
|
|
+ "Simulation",
|
|
|
+ "SDK"
|
|
|
+ ],
|
|
|
+ "dependencies": [],
|
|
|
+ "display_name": "testgem3 2.0.0",
|
|
|
+ "download_source_uri": "https://downloads.testgem3.com/o3de-repo/testgem3-2.15/O3DE_testgem3Gem_v2.15.4_Win64_Linux64_Mac64.zip",
|
|
|
+ "version": "2.0.0",
|
|
|
+ "last_updated": "2023-03-09"
|
|
|
+}
|
|
|
+'''
|
|
|
+
|
|
|
TEST_O3DE_REPO_BROKEN_JSON_PAYLOAD = '''
|
|
|
{
|
|
|
"repo_name": "Test Repo",
|
|
@@ -227,6 +269,25 @@ TEST_O3DE_REPO_GEM_JSON_PAYLOAD = '''
|
|
|
"dependencies": []
|
|
|
}
|
|
|
'''
|
|
|
+TEST_O3DE_REPO_GEM2_JSON_PAYLOAD = '''
|
|
|
+{
|
|
|
+ "gem_name": "TestGem2",
|
|
|
+ "license": "Apache-2.0 Or MIT",
|
|
|
+ "origin": "Test Creator",
|
|
|
+ "origin_uri": "http://o3derepo.org/TestGem2/gem.zip",
|
|
|
+ "repo_uri": "http://o3derepo.org",
|
|
|
+ "type": "Tool",
|
|
|
+ "summary": "A test downloadable gem.",
|
|
|
+ "canonical_tags": [
|
|
|
+ "Gem"
|
|
|
+ ],
|
|
|
+ "user_tags": [],
|
|
|
+ "icon_path": "preview.png",
|
|
|
+ "requirements": "",
|
|
|
+ "documentation_url": "",
|
|
|
+ "dependencies": []
|
|
|
+}
|
|
|
+'''
|
|
|
|
|
|
TEST_O3DE_REPO_PROJECT_FILE_NAME = '233c6e449888b4dc1355b2bf668b91b53715888e6777a2791df0e7aec9d08989.json'
|
|
|
TEST_O3DE_REPO_PROJECT_JSON_PAYLOAD = '''
|
|
@@ -258,6 +319,35 @@ TEST_O3DE_REPO_PROJECT_JSON_PAYLOAD = '''
|
|
|
]
|
|
|
}
|
|
|
'''
|
|
|
+TEST_O3DE_REPO_PROJECT2_JSON_PAYLOAD = '''
|
|
|
+{
|
|
|
+ "project_name": "TestProject2",
|
|
|
+ "project_id": "{04112c69-306d-4de6-b3b4-4cb1a3eca58e}",
|
|
|
+ "version" : "0.0.0",
|
|
|
+ "compatible_engines" : [
|
|
|
+ "o3de==1.2.3"
|
|
|
+ ],
|
|
|
+ "engine_api_dependencies" : [
|
|
|
+ "framework==1.2.3"
|
|
|
+ ],
|
|
|
+ "origin": "The primary repo for TestProject2 goes here: i.e. http://www.mydomain.com",
|
|
|
+ "license": "What license TestProject2 uses goes here: i.e. https://opensource.org/licenses/MIT",
|
|
|
+ "display_name": "TestProject",
|
|
|
+ "summary": "A short description of TestProject.",
|
|
|
+ "canonical_tags": [
|
|
|
+ "Project"
|
|
|
+ ],
|
|
|
+ "user_tags": [
|
|
|
+ "TestProject2"
|
|
|
+ ],
|
|
|
+ "icon_path": "preview.png",
|
|
|
+ "engine": "o3de==1.2.3",
|
|
|
+ "restricted_name": "projects",
|
|
|
+ "external_subdirectories": [
|
|
|
+ "TestGem"
|
|
|
+ ]
|
|
|
+}
|
|
|
+'''
|
|
|
|
|
|
TEST_O3DE_REPO_TEMPLATE_FILE_NAME = '7802eae005ca1c023e14611ed63182299bf87e760708b4dba8086a134e309f3a.json'
|
|
|
TEST_O3DE_REPO_TEMPLATE_JSON_PAYLOAD = '''
|
|
@@ -279,6 +369,25 @@ TEST_O3DE_REPO_TEMPLATE_JSON_PAYLOAD = '''
|
|
|
"dependencies": []
|
|
|
}
|
|
|
'''
|
|
|
+TEST_O3DE_REPO_TEMPLATE2_JSON_PAYLOAD = '''
|
|
|
+{
|
|
|
+ "template_name": "TestTemplate2",
|
|
|
+ "license": "Apache-2.0 Or MIT",
|
|
|
+ "origin": "Test Creator",
|
|
|
+ "origin_uri": "http://o3derepo.org/TestTemplate/template2.zip",
|
|
|
+ "repo_uri": "http://o3derepo.org",
|
|
|
+ "type": "Tool",
|
|
|
+ "summary": "A test downloadable gem.",
|
|
|
+ "canonical_tags": [
|
|
|
+ "Template"
|
|
|
+ ],
|
|
|
+ "user_tags": [],
|
|
|
+ "icon_path": "preview.png",
|
|
|
+ "requirements": "",
|
|
|
+ "documentation_url": "",
|
|
|
+ "dependencies": []
|
|
|
+}
|
|
|
+'''
|
|
|
|
|
|
@pytest.fixture(scope='class')
|
|
|
def init_register_repo_data(request):
|
|
@@ -290,8 +399,11 @@ class TestRepos:
|
|
|
valid_urls = [
|
|
|
'http://o3derepo.org/repo.json',
|
|
|
'http://o3derepo.org/TestGem/gem.json',
|
|
|
+ 'http://o3derepo.org/TestGem2/gem.json',
|
|
|
'http://o3derepo.org/TestProject/project.json',
|
|
|
+ 'http://o3derepo.org/TestProject2/project.json',
|
|
|
'http://o3derepo.org/TestTemplate/template.json',
|
|
|
+ 'http://o3derepo.org/TestTemplate2/template.json',
|
|
|
'http://o3derecursiverepo.org/repo.json'
|
|
|
]
|
|
|
|
|
@@ -399,53 +511,102 @@ class TestRepos:
|
|
|
assert result == expected_result
|
|
|
assert repo_path not in manifest.get_manifest_repos()
|
|
|
|
|
|
- def test_get_object_list(self):
|
|
|
+ @pytest.mark.parametrize("test_name, repo_paths, expected_gems_json_data, expected_projects_json_data, expected_templates_json_data", [
|
|
|
+ pytest.param("repoA loads repoA objects", ['http://o3de.org/repoA'],
|
|
|
+ [TEST_O3DE_REPO_GEM_JSON_PAYLOAD],
|
|
|
+ [TEST_O3DE_REPO_PROJECT_JSON_PAYLOAD],
|
|
|
+ [TEST_O3DE_REPO_TEMPLATE_JSON_PAYLOAD]),
|
|
|
+ pytest.param("repoB loads repoB objects", ['http://o3de.org/repoB'],
|
|
|
+ [TEST_O3DE_REPO_GEM_JSON_PAYLOAD, TEST_O3DE_REPO_GEM2_JSON_PAYLOAD],
|
|
|
+ [TEST_O3DE_REPO_PROJECT2_JSON_PAYLOAD],
|
|
|
+ [TEST_O3DE_REPO_TEMPLATE2_JSON_PAYLOAD]),
|
|
|
+ # TestGem is included twice because it is in both repositories
|
|
|
+ pytest.param("repoA and repoB loads all objects", ['http://o3de.org/repoA','http://o3de.org/repoB'],
|
|
|
+ [TEST_O3DE_REPO_GEM_JSON_PAYLOAD, TEST_O3DE_REPO_GEM_JSON_PAYLOAD, TEST_O3DE_REPO_GEM2_JSON_PAYLOAD],
|
|
|
+ [TEST_O3DE_REPO_PROJECT_JSON_PAYLOAD, TEST_O3DE_REPO_PROJECT2_JSON_PAYLOAD],
|
|
|
+ [TEST_O3DE_REPO_TEMPLATE_JSON_PAYLOAD, TEST_O3DE_REPO_TEMPLATE2_JSON_PAYLOAD]),
|
|
|
+ # RepoC contains a mix of objects with versions_data and objects without
|
|
|
+ pytest.param("repoC loads repoC objects", ['http://o3de.org/repoC'],
|
|
|
+ [TEST_O3DE_REPO_GEM3_JSON_VERSION_1_PAYLOAD, TEST_O3DE_REPO_GEM3_JSON_VERSION_2_PAYLOAD],
|
|
|
+ [TEST_O3DE_REPO_PROJECT_JSON_PAYLOAD],
|
|
|
+ [TEST_O3DE_REPO_TEMPLATE_JSON_PAYLOAD])
|
|
|
+ ])
|
|
|
+ def test_get_object_json_data(self, test_name, repo_paths, expected_gems_json_data,
|
|
|
+ expected_projects_json_data, expected_templates_json_data):
|
|
|
self.o3de_manifest_data = json.loads(TEST_O3DE_MANIFEST_JSON_PAYLOAD)
|
|
|
- self.o3de_manifest_data["repos"] = ["http://o3de.org/repoA", "http://o3de.org/repoB"]
|
|
|
- self.created_files.clear()
|
|
|
+ self.o3de_manifest_data["repos"] = repo_paths
|
|
|
|
|
|
def load_o3de_manifest(manifest_path: pathlib.Path = None) -> dict:
|
|
|
return copy.deepcopy(self.o3de_manifest_data)
|
|
|
|
|
|
- def save_o3de_manifest(manifest_data: dict, manifest_path: pathlib.Path = None) -> bool:
|
|
|
- self.o3de_manifest_data = manifest_data
|
|
|
- return True
|
|
|
-
|
|
|
def mocked_open(path, mode, *args, **kwargs):
|
|
|
file_data = bytes(0)
|
|
|
if pathlib.Path(path).name == TEST_O3DE_REPOA_FILENAME:
|
|
|
file_data = TEST_O3DE_REPOA_JSON_PAYLOAD
|
|
|
elif pathlib.Path(path).name == TEST_O3DE_REPOB_FILENAME:
|
|
|
file_data = TEST_O3DE_REPOB_JSON_PAYLOAD
|
|
|
+ elif pathlib.Path(path).name == TEST_O3DE_REPO_JSON_VERSION_2_FILENAME:
|
|
|
+ file_data = TEST_O3DE_REPO_JSON_VERSION_2_PAYLOAD
|
|
|
+
|
|
|
mockedopen = mock_open(mock=MagicMock(), read_data=file_data)
|
|
|
return mockedopen(self, *args, **kwargs)
|
|
|
|
|
|
+ def get_json_data_file(object_json: pathlib.Path,
|
|
|
+ object_typename: str,
|
|
|
+ object_validator: callable) -> dict or None:
|
|
|
+ if object_typename == 'gem':
|
|
|
+ if object_json == self.test_gem_cache_filename:
|
|
|
+ return json.loads(TEST_O3DE_REPO_GEM_JSON_PAYLOAD)
|
|
|
+ if object_json == self.test_gem2_cache_filename:
|
|
|
+ return json.loads(TEST_O3DE_REPO_GEM2_JSON_PAYLOAD)
|
|
|
+ else:
|
|
|
+ return None
|
|
|
+ elif object_typename == 'project':
|
|
|
+ if object_json == self.test_project_cache_filename:
|
|
|
+ return json.loads(TEST_O3DE_REPO_PROJECT_JSON_PAYLOAD)
|
|
|
+ elif object_json == self.test_project2_cache_filename:
|
|
|
+ return json.loads(TEST_O3DE_REPO_PROJECT2_JSON_PAYLOAD)
|
|
|
+ else:
|
|
|
+ return None
|
|
|
+ elif object_typename == 'template':
|
|
|
+ if object_json == self.test_template_cache_filename:
|
|
|
+ return json.loads(TEST_O3DE_REPO_TEMPLATE_JSON_PAYLOAD)
|
|
|
+ elif object_json == self.test_template2_cache_filename:
|
|
|
+ return json.loads(TEST_O3DE_REPO_TEMPLATE2_JSON_PAYLOAD)
|
|
|
+ else:
|
|
|
+ return None
|
|
|
+ else:
|
|
|
+ None
|
|
|
+
|
|
|
with patch('o3de.manifest.load_o3de_manifest', side_effect=load_o3de_manifest) as _1,\
|
|
|
- patch('o3de.manifest.save_o3de_manifest', side_effect=save_o3de_manifest) as _2, \
|
|
|
- patch('pathlib.Path.open', mocked_open) as _3, \
|
|
|
- patch('pathlib.Path.is_file', return_value=True) as _4:
|
|
|
- # Gems
|
|
|
- object_set = repo.get_gem_json_paths_from_cached_repo('http://o3de.org/repoA')
|
|
|
- assert len(object_set) == 1
|
|
|
- object_set = repo.get_gem_json_paths_from_all_cached_repos()
|
|
|
- assert len(object_set) == 2
|
|
|
- # Projects
|
|
|
- object_set = repo.get_project_json_paths_from_cached_repo('http://o3de.org/repoA')
|
|
|
- assert len(object_set) == 1
|
|
|
- object_set = repo.get_project_json_paths_from_all_cached_repos()
|
|
|
- assert len(object_set) == 2
|
|
|
- # Templates
|
|
|
- object_set = repo.get_template_json_paths_from_cached_repo('http://o3de.org/repoA')
|
|
|
- assert len(object_set) == 1
|
|
|
- object_set = repo.get_template_json_paths_from_all_cached_repos()
|
|
|
- assert len(object_set) == 2
|
|
|
- assert True
|
|
|
+ patch('o3de.manifest.get_o3de_cache_folder', return_value=pathlib.Path('Cache')) as _2, \
|
|
|
+ patch('o3de.manifest.get_json_data_file', side_effect=get_json_data_file) as get_json_data_file_patch, \
|
|
|
+ patch('pathlib.Path.open', mocked_open) as _3, \
|
|
|
+ patch('pathlib.Path.is_file', return_value=True) as _4:
|
|
|
+
|
|
|
+ self.test_gem_cache_filename, _ = repo.get_cache_file_uri("http://o3derepo.org/TestGem/gem.json")
|
|
|
+ self.test_gem2_cache_filename, _ = repo.get_cache_file_uri("http://o3derepo.org/TestGem2/gem.json")
|
|
|
+ self.test_project_cache_filename, _ = repo.get_cache_file_uri("http://o3derepo.org/TestProject/project.json")
|
|
|
+ self.test_project2_cache_filename, _ = repo.get_cache_file_uri("http://o3derepo.org/TestProject2/project.json")
|
|
|
+ self.test_template_cache_filename, _ = repo.get_cache_file_uri("http://o3derepo.org/TestTemplate/template.json")
|
|
|
+ self.test_template2_cache_filename, _ = repo.get_cache_file_uri("http://o3derepo.org/TestTemplate2/template.json")
|
|
|
+
|
|
|
+ # Gems
|
|
|
+ gems_json_data = repo.get_gem_json_data_from_all_cached_repos()
|
|
|
+ assert gems_json_data == [json.loads(data) for data in expected_gems_json_data]
|
|
|
+ # Projects
|
|
|
+ projects_json_data = repo.get_project_json_data_from_all_cached_repos()
|
|
|
+ assert projects_json_data == [json.loads(data) for data in expected_projects_json_data]
|
|
|
+ # Templates
|
|
|
+ templates_json_data = repo.get_template_json_data_from_all_cached_repos()
|
|
|
+ assert templates_json_data == [json.loads(data) for data in expected_templates_json_data]
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("repo_uri, validate_objects", [
|
|
|
+ # tests with version schema 0.0.0
|
|
|
pytest.param('http://o3de.org/repoA', False),
|
|
|
pytest.param('http://o3de.org/repoA', True),
|
|
|
- #tests with version schema 2.0.0
|
|
|
+ # tests with version schema 1.0.0
|
|
|
pytest.param('http://o3de.org/repoC', False),
|
|
|
pytest.param('http://o3de.org/repoC', True)
|
|
|
])
|