Conversation
📝 WalkthroughWalkthroughRemoves two transfer-related constants, adds an Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (4)
Comment |
c0bf8a7 to
fb6b1cc
Compare
95332a7 to
878afc0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@adobe_vipm/flows/validation/transfer.py`:
- Around line 628-632: The if-condition that checks adobe_subscription status
uses identity comparison ("is not") which is wrong for strings; update the
condition in the transfer.py block that checks adobe_subscription and
AdobeStatus.SUBSCRIPTION_ACTIVE.value to use value inequality (!=) instead of
"is not" so the comparison reads adobe_subscription["status"] !=
AdobeStatus.SUBSCRIPTION_ACTIVE.value (keeping the same null-check order and
continue behavior).
🧹 Nitpick comments (2)
adobe_vipm/flows/helpers.py (1)
713-716: Consider explicit error handling for subscription fetch.The
get_subscriptionscall is placed after thereseller_change_requestsucceeds but is not wrapped in its own try-except. If this call fails, the error will propagate with a generic message rather than a specific subscription-fetch error context.This may be acceptable if subscription fetch failures should halt the flow entirely, but consider whether a more specific error message would help with debugging.
adobe_vipm/flows/validation/transfer.py (1)
649-661: Set-based comparison may incorrectly match orders with duplicate lines.The current implementation uses sets for comparison, which loses multiplicity information. If there are duplicate
(vendor, quantity)pairs, the comparison may incorrectly pass. For example:
- Order lines:
[(SKU-A, 10), (SKU-A, 10), (SKU-B, 5)]- Transfer lines:
[(SKU-A, 10), (SKU-B, 5), (SKU-B, 5)]Both would produce the same set
{(SKU-A, 10), (SKU-B, 5)}despite representing different distributions.If duplicate lines with identical
(vendor, quantity)pairs can occur in practice, consider usingcollections.Counterinstead:from collections import Counter def key(line: dict) -> tuple[str, int]: return (line["item"]["externalIds"]["vendor"], line["quantity"]) return Counter(map(key, order_lines)) == Counter(map(key, transfer_lines))If duplicates are impossible by design, a clarifying comment would be helpful.
878afc0 to
24fc663
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@tests/flows/validation/test_reseller_change.py`:
- Around line 601-643: The error message string includes an unintended trailing
space; remove the trailing space from the f-string that raises the MPTError (the
f"No reseller item found for partial SKU '{partial_sku}' " in transfer.py) so it
becomes f"No reseller item found for partial SKU '{partial_sku}'", and then
update the test assertions in tests/flows/validation/test_reseller_change.py
(the assert checking str(exc_info.value) and the
mock_send_error.assert_called_once_with message) to expect the message without
the trailing space.
🧹 Nitpick comments (2)
adobe_vipm/flows/validation/transfer.py (2)
588-594: Clarify intent: updating order with empty lines before validation failure.When no transfer lines and no order lines exist, calling
update_orderwith an emptyorder_lines_from_transferlist effectively clears the order. If this is intentional state synchronization, consider adding a brief comment explaining why this is needed before returning a validation failure.
673-685: Consider documenting the no-duplicates assumption.The set-based comparison works correctly under the assumption that
(vendor, quantity)pairs cannot repeat within the same order. A brief comment documenting this business constraint would help future maintainers understand whyCounterisn't needed here.`@staticmethod` def _transfer_order_lines_match(order_lines: list[dict], transfer_lines: list[dict]) -> bool: - """Compare order lines based on relevant fields only.""" + """Compare order lines based on relevant fields only. + + Note: Uses set comparison since duplicate (vendor, quantity) pairs + cannot occur within the same order per business rules. + """ if len(order_lines) != len(transfer_lines): return False
a52e3a5 to
1f1ed2d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@adobe_vipm/flows/validation/transfer.py`:
- Around line 651-652: The error message string in transfer.py unnecessarily
includes a trailing space in the f-string assigned to error_msg; update the
f-string used where error_msg and logger.error are set (referencing variables
error_msg, partial_sku and the logger usage) to remove the trailing space so the
message becomes "No reseller item found for partial SKU '{partial_sku}'" before
calling logger.error.
🧹 Nitpick comments (1)
tests/flows/validation/test_reseller_change.py (1)
599-602: Local mock override shadows the fixture.The
test_skip_one_time_skusmethod creates a localmock_get_one_time_skuspatch that shadows the fixture from conftest. While this works, consider usingmocker.patchto modify the fixture's return value instead, or parameterize the fixture to accept return values.♻️ Alternative approach using fixture configuration
You could modify the conftest fixture to accept a parameter:
`@pytest.fixture` def mock_get_one_time_skus(mocker, request): return_value = getattr(request, 'param', []) return mocker.patch( "adobe_vipm.flows.validation.transfer.get_one_time_skus", return_value=return_value, autospec=True, )Then use
@pytest.mark.parametrize("mock_get_one_time_skus", [["99999999CA"]], indirect=True)on specific tests.
d6af7b8 to
9ec1747
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@tests/flows/validation/test_reseller_change.py`:
- Around line 599-602: The inline mock patch of get_one_time_skus
(mock_get_one_time_skus) lacks autospec and should be replaced with an
autospec'd patch or, preferably, a fixture override; change the test to patch
"adobe_vipm.flows.validation.transfer.get_one_time_skus" with autospec=True (or
create a pytest fixture that yields a monkeypatch of get_one_time_skus returning
["99999999CA"] and use that fixture in tests) so the mock respects the real
function signature and follow the guideline to prefer a fixture for varying
return values.
9ec1747 to
c1537cb
Compare
c1537cb to
f62faa8
Compare
aec640a to
cc3c648
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@adobe_vipm/flows/sync/agreement.py`:
- Around line 567-571: The loop that appends (line, actual_sku) calls
models.get_adobe_sku for every line and will fail if
line["item"]["externalIds"]["vendor"] is missing or unmapped; update the code
around models.get_adobe_sku/get_market_segment to first check for the vendor ID,
call models.get_adobe_sku inside a try/conditional, and if vendor is missing or
the mapping returns None/raises, skip appending that line and emit a warning
(e.g., via logger.warn or the module logger) referencing the line id and
product_id so price sync continues resiliently; ensure agreement_lines only
receives tuples with a valid actual_sku.
🧹 Nitpick comments (1)
tests/flows/validation/test_reseller_change.py (1)
207-287: Add a test for upsize-line rejection in reseller-change validation.Once the upsize guard is enforced, add a test that creates an order with an upsize line (quantity increase) and asserts validation fails with the appropriate error and no preview order is requested.
Based on learnings: Rule: In reseller transfer validation flows (validate_reseller_change), upsize lines are not allowed as a business rule, only new lines are permitted.
|
albertsola
left a comment
There was a problem hiding this comment.
I would not reformat the pyproject.toml



Closes MPT-17580