Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
labhvam5 committed Dec 5, 2023
1 parent 13a04ea commit 92cc37d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 27 deletions.
8 changes: 3 additions & 5 deletions tests/test_fyle_integrations_imports/test_modules/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -5997,7 +5997,7 @@
}

categories_data = {
"create_new_auto_create_categories_destination_attributes_accounts_sync" : [
"create_new_auto_create_categories_destination_attributes_accounts_sync": [
{
'Name':'Utility',
'SubAccount':False,
Expand Down Expand Up @@ -6119,7 +6119,7 @@
}
},
],
"create_new_auto_create_categories_destination_attributes_accounts" : [
"create_new_auto_create_categories_destination_attributes_accounts": [
{
'Name':'Utility',
'SubAccount':False,
Expand Down Expand Up @@ -6438,7 +6438,6 @@
323494
],
'restricted_spender_user_ids':[

],
'sub_category':None,
'system_category':'Train',
Expand All @@ -6459,7 +6458,6 @@
323492
],
'restricted_spender_user_ids':[

],
'sub_category':None,
'system_category':'Fuel',
Expand Down Expand Up @@ -7565,4 +7563,4 @@
'id':'135446'
}
]
}
}
11 changes: 6 additions & 5 deletions tests/test_fyle_integrations_imports/test_modules/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_construct_attributes_filter(db):
sync_after = datetime.strptime(date_string, '%Y-%m-%d %H:%M:%S.%f')

base = get_base_class_instance(workspace_id=1, source_field='COST_CENTER', destination_field='CUSTOMER', platform_class_name='cost_centers', sync_after=sync_after)

filters = base.construct_attributes_filter('COST_CENTER', False, paginated_destination_attribute_values)

assert filters == {'attribute_type': 'COST_CENTER', 'workspace_id': 1, 'value__in': paginated_destination_attribute_values}
Expand Down Expand Up @@ -218,10 +218,11 @@ def test_resolve_expense_attribute_errors(db):
category_list = []
category_list.append(
Mapping(
workspace_id=workspace_id,
source_id=source_category.id,
destination_id=destination_attribute.id
))
workspace_id=workspace_id,
source_id=source_category.id,
destination_id=destination_attribute.id
)
)
Mapping.objects.bulk_create(category_list)

category.resolve_expense_attribute_errors()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from apps.workspaces.models import QBOCredential, Workspace, WorkspaceGeneralSettings, FyleCredential
from fyle_integrations_platform_connector import PlatformConnector
from fyle_integrations_imports.modules.categories import Category
from apps.tasks.models import Error
from tests.test_fyle_integrations_imports.test_modules.fixtures import categories_data


Expand Down Expand Up @@ -64,7 +63,6 @@ def test_sync_destination_attributes(mocker, db):
assert destination_attributes_count == 68



def test_sync_expense_atrributes(mocker, db):
workspace_id = 2
fyle_credentials = FyleCredential.objects.get(workspace_id=workspace_id)
Expand Down Expand Up @@ -99,7 +97,6 @@ def test_sync_expense_atrributes(mocker, db):
assert categories_count == 284



def test_auto_create_destination_attributes(mocker, db):
workspace_id = 2
qbo_credentials = QBOCredential.get_active_qbo_credentials(workspace_id)
Expand Down Expand Up @@ -128,7 +125,7 @@ def test_auto_create_destination_attributes(mocker, db):
)
mock_call.side_effect = [
categories_data['create_new_auto_create_categories_expense_attributes_0'],
categories_data['create_new_auto_create_categories_expense_attributes_1']
categories_data['create_new_auto_create_categories_expense_attributes_1']
]

expense_attributes_count = ExpenseAttribute.objects.filter(workspace_id=workspace_id, attribute_type = 'CATEGORY').count()
Expand Down Expand Up @@ -175,7 +172,7 @@ def test_auto_create_destination_attributes(mocker, db):
]

destination_attribute = DestinationAttribute.objects.filter(workspace_id=workspace_id, value='Levi', attribute_type='ACCOUNT').first()

assert destination_attribute.active == True

expense_attribute = ExpenseAttribute.objects.filter(workspace_id=workspace_id, value='Levi', attribute_type='CATEGORY').first()
Expand All @@ -194,7 +191,7 @@ def test_auto_create_destination_attributes(mocker, db):
category.trigger_import()

destination_attribute = DestinationAttribute.objects.filter(workspace_id=workspace_id, value='Levi', attribute_type='ACCOUNT').first()

assert destination_attribute.active == False

expense_attribute = ExpenseAttribute.objects.filter(workspace_id=workspace_id, value='Levi', attribute_type='CATEGORY').first()
Expand All @@ -203,7 +200,7 @@ def test_auto_create_destination_attributes(mocker, db):

post_run_expense_attribute_disabled_count = ExpenseAttribute.objects.filter(workspace_id=workspace_id, active=False, attribute_type='CATEGORY').count()

assert post_run_expense_attribute_disabled_count == pre_run_expense_attribute_disabled_count + 1
assert post_run_expense_attribute_disabled_count == pre_run_expense_attribute_disabled_count + 1

# not re-enable case for categories import
with mock.patch('fyle.platform.apis.v1beta.admin.Categories.list_all') as mock_call:
Expand All @@ -222,7 +219,7 @@ def test_auto_create_destination_attributes(mocker, db):
]

pre_run_destination_attribute_count = DestinationAttribute.objects.filter(workspace_id=workspace_id, attribute_type = 'ACCOUNT', active=False).count()

assert pre_run_destination_attribute_count == 1

pre_run_expense_attribute_count = ExpenseAttribute.objects.filter(workspace_id=workspace_id, attribute_type = 'CATEGORY', active=False).count()
Expand Down Expand Up @@ -257,7 +254,7 @@ def test_auto_create_destination_attributes(mocker, db):
)
mock_call.side_effect = [
categories_data['create_new_auto_create_categories_expense_attributes_2'],
categories_data['create_new_auto_create_categories_expense_attributes_3']
categories_data['create_new_auto_create_categories_expense_attributes_3']
]

expense_attributes_count = ExpenseAttribute.objects.filter(workspace_id=workspace_id, attribute_type = 'CATEGORY').count()
Expand Down Expand Up @@ -307,7 +304,7 @@ def test_auto_create_destination_attributes(mocker, db):
]

destination_attribute = DestinationAttribute.objects.filter(workspace_id=workspace_id, value='Concrete', attribute_type='ACCOUNT', display_name='Item').first()

assert destination_attribute.active == True

expense_attribute = ExpenseAttribute.objects.filter(workspace_id=workspace_id, value='Concrete', attribute_type='CATEGORY').first()
Expand All @@ -326,7 +323,7 @@ def test_auto_create_destination_attributes(mocker, db):
category.trigger_import()

destination_attribute = DestinationAttribute.objects.filter(workspace_id=workspace_id, value='Concrete', attribute_type='ACCOUNT', display_name='Item').first()

assert destination_attribute.active == False

expense_attribute = ExpenseAttribute.objects.filter(workspace_id=workspace_id, value='Concrete', attribute_type='CATEGORY').first()
Expand All @@ -335,7 +332,7 @@ def test_auto_create_destination_attributes(mocker, db):

post_run_expense_attribute_disabled_count = ExpenseAttribute.objects.filter(workspace_id=workspace_id, active=False, attribute_type='CATEGORY').count()

assert post_run_expense_attribute_disabled_count == pre_run_expense_attribute_disabled_count + 1
assert post_run_expense_attribute_disabled_count == pre_run_expense_attribute_disabled_count + 1

# not re-enable case for items import
with mock.patch('fyle.platform.apis.v1beta.admin.Categories.list_all') as mock_call:
Expand All @@ -357,7 +354,7 @@ def test_auto_create_destination_attributes(mocker, db):
]

pre_run_destination_attribute_count = DestinationAttribute.objects.filter(workspace_id=workspace_id, attribute_type = 'ACCOUNT', active=False, display_name='Item').count()

assert pre_run_destination_attribute_count == 1

pre_run_expense_attribute_count = ExpenseAttribute.objects.filter(workspace_id=workspace_id, attribute_type = 'CATEGORY', active=False).count()
Expand Down Expand Up @@ -395,7 +392,7 @@ def test_auto_create_destination_attributes(mocker, db):
]

pre_run_destination_attribute_count = DestinationAttribute.objects.filter(workspace_id=workspace_id, attribute_type = 'ACCOUNT', active=False, display_name='Item').count()

assert pre_run_destination_attribute_count == 0

pre_run_expense_attribute_count = ExpenseAttribute.objects.filter(workspace_id=workspace_id, attribute_type = 'CATEGORY', active=False).count()
Expand Down
3 changes: 0 additions & 3 deletions tests/test_mappings/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from django_q.models import Schedule
from fyle.platform.exceptions import InvalidTokenError as FyleInvalidTokenError
from fyle_accounting_mappings.models import (
CategoryMapping,
DestinationAttribute,
EmployeeMapping,
ExpenseAttribute,
Expand Down Expand Up @@ -39,9 +38,7 @@
)
from apps.tasks.models import Error
from apps.workspaces.models import FyleCredential, QBOCredential, WorkspaceGeneralSettings
from tests.helper import dict_compare_keys
from tests.test_mappings.fixtures import data
from tests.test_fyle.fixtures import data as fyle_data


def test_auto_create_tax_codes_mappings(db, mocker):
Expand Down

0 comments on commit 92cc37d

Please sign in to comment.