Skip to content

Commit

Permalink
Merge branch 'main' into mchok-metrics-counter-feature-tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mchok committed Sep 20, 2024
2 parents a17a0d4 + 05a6689 commit 6cc8c5f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,21 +187,21 @@ def find_entity(

entity: Optional[T] = None

# Determine the package entity to convert, there must be one
if entity_id:
# If the user specified a package entity ID (or we inferred one from the app entity), use that one directly
# If we're looking for a specific entity, use that one directly
entity = entities.get(entity_id)
elif len(entities) == 1:
# Otherwise, if there is only one package entity, fall back to that one
# Otherwise, if there is only one entity, fall back to that one
entity = next(iter(entities.values()))
elif len(entities) > 1:
# If there are multiple package entities, the user must specify which one to use
elif len(entities) > 1 and required:
# If there are multiple entities and it's required,
# the user must specify which one to use
raise ClickException(
f"More than one {entity_type} entity exists in the project definition file, "
f"specify {disambiguation_option} to choose which one to operate on."
)

# If we don't have a package entity to convert, error out since it's not optional
# If we don't have a package entity to convert, error out if it's required
if not entity and required:
with_id = f'with ID "{entity_id}" ' if entity_id else ""
raise ClickException(
Expand Down
18 changes: 18 additions & 0 deletions tests/nativeapp/test_v2_to_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ def test_v2_to_v1_conversions(pdfv2_input, expected_pdfv1, expected_error):
"More than one application entity exists in the project definition file, "
"specify --app-entity-id to choose which one to operate on.",
],
[
{
"definition_version": "2",
"entities": {
**package_v2("pkg1"),
**app_v2("app1", "pkg1"),
**app_v2("app2", "pkg1"),
},
},
"",
"",
False,
{
"definition_version": "1.1",
"native_app": native_app_v1("pkg1", "pkg1", ""),
},
None,
],
[
{
"definition_version": "2",
Expand Down

0 comments on commit 6cc8c5f

Please sign in to comment.