Skip to content

Commit

Permalink
fix: fix linting errors, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyujacky committed Sep 3, 2024
1 parent aebbf35 commit 2f9c3a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 4 additions & 4 deletions commerce_coordinator/apps/commercetools/tests/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
TransactionState,
TransactionType,
Type,
TypeDraft,
TypedMoney
TypedMoney,
TypeDraft
)
from django.test import TestCase
from mock import patch
Expand All @@ -35,9 +35,9 @@
gen_order,
gen_order_history,
gen_payment,
gen_payment_with_multiple_transactions,
gen_retired_customer,
gen_return_item,
gen_payment_with_multiple_transactions
gen_return_item
)
from commerce_coordinator.apps.commercetools.tests.sub_messages.test_tasks import CommercetoolsAPIClientMock
from commerce_coordinator.apps.core.constants import ORDER_HISTORY_PER_SYSTEM_REQ_LIMIT
Expand Down
13 changes: 9 additions & 4 deletions commerce_coordinator/apps/commercetools/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""
Tests for Commerce tools utils
"""
import decimal
import hashlib
import unittest
from unittest.mock import MagicMock

from braze.client import BrazeClient
from commercetools.platform.models import TransactionState, TransactionType, TypedMoney, MoneyType
from commercetools.platform.models import MoneyType, TransactionState, TransactionType, TypedMoney
from django.conf import settings
from django.test import override_settings
from django.urls import reverse
Expand All @@ -22,8 +23,8 @@
create_retired_fields,
extract_ct_order_information_for_braze_canvas,
extract_ct_product_information_for_braze_canvas,
get_braze_client,
find_refund_transaction,
get_braze_client,
has_full_refund_transaction,
has_refund_transaction,
send_order_confirmation_email,
Expand Down Expand Up @@ -240,10 +241,14 @@ def test_has_matching_refund_transaction(self):
currency_code='USD',
type=MoneyType.CENT_PRECISION,
fraction_digits=2))
self.assertEqual(find_refund_transaction(payment, 2500), {})
self.assertEqual(find_refund_transaction(payment, decimal.Decimal(49.0)), payment.transactions[1].id)

def test_has_no_matching_refund_transaction(self):
payment = gen_payment_with_multiple_transactions(TransactionType.CHARGE, 4900)
payment = gen_payment_with_multiple_transactions(TransactionType.CHARGE, 4900, TransactionType.REFUND,
TypedMoney(cent_amount=4900,
currency_code='USD',
type=MoneyType.CENT_PRECISION,
fraction_digits=2))
self.assertEqual(find_refund_transaction(payment, 4000), {})


Expand Down

0 comments on commit 2f9c3a4

Please sign in to comment.