Skip to content

Commit

Permalink
Fix implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
thefrieddan1 committed Apr 8, 2024
1 parent 5c9257d commit 738350c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,22 +455,24 @@ def test__enhance_pack_properties__internal_and_external(


@pytest.mark.parametrize(
"marketplace_version, new_from_version, current_toversion, new_toversion, expected_toversion",
"marketplace_version, current_fromversion, new_from_version, current_toversion, new_toversion, expected_toversion",
[
(MarketplaceVersions.XSOAR, "8.0.0", "7.9.9", "8.2.0", "7.9.9"),
(MarketplaceVersions.XSOAR, "5.5.0", "6.2.0", "7.9.9", "7.9.9"),
(MarketplaceVersions.XSOAR, "5.5.0", "8.0.0", "7.9.9", "8.2.0", "7.9.9"),
(MarketplaceVersions.XSOAR, "5.5.0", "6.5.0", "7.2.0", "7.9.9", "7.9.9"),
(
MarketplaceVersions.XSOAR,
"5.5.0",
"6.5.0",
"7.9.9",
DEFAULT_CONTENT_ITEM_TO_VERSION,
"",
),
(MarketplaceVersions.XSOAR_SAAS, "8.0.0", "6.2.0", "8.5.0", "8.5.0"),
(MarketplaceVersions.XSOAR_SAAS, "5.5.0", "8.0.0", "6.2.0", "8.5.0", "8.5.0"),
],
)
def test_replace_item_if_has_higher_toversion(
marketplace_version,
current_fromversion,
new_from_version,
current_toversion,
new_toversion,
Expand All @@ -480,6 +482,7 @@ def test_replace_item_if_has_higher_toversion(
updates to the highest version supported by the MarketplaceVersions.XSOAR
ARGS:
marketplace_version: MarketplaceVersions the flow is running on.
current_fromversion: current fromversion of content item in the pack metadata
new_from_version: the fromversion of content item in the pack metadata
current_toversion: current toversion of content item in the pack metadata
new_toversion: a new toversion of content item
Expand All @@ -495,7 +498,10 @@ def test_replace_item_if_has_higher_toversion(
Scenario 3: On all marketplaces will update the metdata of content item toversion to empty if new toversion is DEFAULT_CONTENT_ITEM_TO_VERSION
Scenario 4: On MarketplaceVersions.XSOAR_SAAS should update metadata to the highest version.
"""
content_item_metadata = {"toversion": current_toversion}
content_item_metadata = {
"fromversion": current_fromversion,
"toversion": current_toversion,
}
marketplace = marketplace_version
my_instance = PackMetadata(
name="test",
Expand Down
19 changes: 12 additions & 7 deletions demisto_sdk/commands/content_graph/objects/pack_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,18 @@ def _replace_item_if_has_higher_toversion(
content_item_summary (dict): The current content item summary to update if needed.
marketplace (MarketplaceVersions): The marketplace to prepare the pack to upload.
"""
if marketplace == MarketplaceVersions.XSOAR and parse(
content_item.fromversion
) >= Version("8.0.0"):
logger.debug(
f"Content_item: {content_item.name} has a fromversion {content_item.fromversion} higher than applicable for XSOAR6 marketplace. Skipping metadata update."
)
return
if marketplace == MarketplaceVersions.XSOAR:
if parse(content_item.fromversion) > Version("7.9.9"):
logger.debug(
f"Content_item: {content_item.name} has a fromversion {content_item.fromversion} higher than applicable for XSOAR6 marketplace. Skipping metadata update."
)
return
elif parse(content_item_metadata["fromversion"]) >= Version("8.0.0"):
logger.debug(
f'Content item:{content_item_metadata["name"]} fromversion:{content_item_metadata["fromversion"]} is not compatible with XSOAR6 marketplace. Replacing'
)
content_item_metadata.update(content_item_summary)
self._set_empty_toversion_if_default(content_item_metadata)
if parse(content_item.toversion) > parse(
content_item_metadata["toversion"] or DEFAULT_CONTENT_ITEM_TO_VERSION
):
Expand Down

0 comments on commit 738350c

Please sign in to comment.