11# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
22# SPDX-License-Identifier: Apache-2.0
33import typing as t
4+ from copy import deepcopy
45
56import pytest
67
@@ -19,7 +20,7 @@ def test_manifest_hash(valid_manifest):
1920 manifest = Manifest .fromdict (valid_manifest )
2021 # ONLY UPDATE MANIFEST HASH WHEN IT'S NECESSARY!!!
2122 assert (
22- manifest .manifest_hash == '1bd6824f65d801ec3014b407dafde5e6cf6020f04f7bfee88b7e7d723da4bac0 '
23+ manifest .manifest_hash == '8dd1abf83989a97bcd7590b795f5436169f3a2d74a99c832cb97a2d3e8b44205 '
2324 )
2425
2526
@@ -111,17 +112,40 @@ def test_invalid_manifest(manifest, errors):
111112 assert error in produced_errors
112113
113114
114- def test_validator_commit_sha_and_repo (valid_manifest ):
115- valid_manifest ['commit_sha' ] = (
116- '252f10c83610ebca1a059c0bae8255eba2f95be4d1d7bcfa89d7248a82d9f111'
117- )
115+ def test_validator_repo_info_and_repo (valid_manifest ):
116+ original_valid_manifest = deepcopy (valid_manifest )
117+
118+ valid_manifest ['repository_info' ] = {
119+ 'commit_sha' : '252f10c83610ebca1a059c0bae8255eba2f95be4d1d7bcfa89d7248a82d9f111'
120+ }
118121 del valid_manifest ['repository' ]
119122 errors = Manifest .validate_manifest (valid_manifest )
123+ assert errors == [
124+ 'Invalid field "repository". Must set when "repository_info" is set' ,
125+ ]
120126
127+ valid_manifest = deepcopy (original_valid_manifest )
128+ valid_manifest ['repository_info' ] = {'path' : 'foo/bar' }
129+ del valid_manifest ['repository' ]
130+ errors = Manifest .validate_manifest (valid_manifest )
121131 assert errors == [
122- 'Invalid field "repository". Must set when "commit_sha " is set' ,
132+ 'Invalid field "repository". Must set when "repository_info " is set' ,
123133 ]
124134
135+ valid_manifest = deepcopy (original_valid_manifest )
136+ valid_manifest ['repository_info' ] = {}
137+ del valid_manifest ['repository' ]
138+ errors = Manifest .validate_manifest (valid_manifest )
139+ assert errors == [
140+ 'Invalid field "repository". Must set when "repository_info" is set' ,
141+ ]
142+
143+ valid_manifest = deepcopy (original_valid_manifest )
144+ valid_manifest .pop ('repository_info' , None )
145+ del valid_manifest ['repository' ]
146+ errors = Manifest .validate_manifest (valid_manifest )
147+ assert errors == []
148+
125149
126150@pytest .mark .parametrize (
127151 'require_field,public,require' ,
0 commit comments