Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 committed Oct 6, 2023
1 parent 93c6d56 commit bbce745
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/fyle/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def update_complete_expenses(exported_expenses: List[Expense], url: str) -> None

__bulk_update_expenses(expense_to_be_updated)


@retry(n=3, backoff=1, exceptions=InternalServerError)
def bulk_post_accounting_export_summary(platform: PlatformConnector, payload: List[dict]):
"""
Expand Down
29 changes: 26 additions & 3 deletions tests/test_fyle/test_actions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
from unittest import mock

from django.conf import settings
from django.db.models import Q

from fyle_integrations_platform_connector import PlatformConnector
from fyle.platform.exceptions import InternalServerError, RetryException

from apps.fyle.models import Expense, ExpenseGroup
from apps.fyle.actions import update_expenses_in_progress, mark_expenses_as_skipped, \
mark_accounting_export_summary_as_synced, update_failed_expenses, update_complete_expenses
from apps.fyle.actions import (
update_expenses_in_progress,
mark_expenses_as_skipped,
mark_accounting_export_summary_as_synced,
update_failed_expenses,
update_complete_expenses,
bulk_post_accounting_export_summary
)
from apps.fyle.helpers import get_updated_accounting_export_summary
from apps.workspaces.models import Workspace
from apps.workspaces.models import Workspace, FyleCredential


def test_update_expenses_in_progress(db):
Expand Down Expand Up @@ -89,3 +100,15 @@ def test_update_complete_expenses(db):
assert expense.accounting_export_summary['error_type'] == None
assert expense.accounting_export_summary['url'] == 'https://qbo.google.com'
assert expense.accounting_export_summary['id'] == expense.expense_id


def test_bulk_post_accounting_export_summary(db):
fyle_credentails = FyleCredential.objects.get(workspace_id=3)
platform = PlatformConnector(fyle_credentails)

with mock.patch('fyle.platform.apis.v1beta.admin.Expenses.post_bulk_accounting_export_summary') as mock_call:
mock_call.side_effect = InternalServerError('Timeout')
try:
bulk_post_accounting_export_summary(platform, {})
except RetryException:
assert mock_call.call_count == 3

0 comments on commit bbce745

Please sign in to comment.