diff --git a/tests/test_fyle_integrations_imports/test_modules/fixtures.py b/tests/test_fyle_integrations_imports/test_modules/fixtures.py index 0577abc7..c3254ee5 100644 --- a/tests/test_fyle_integrations_imports/test_modules/fixtures.py +++ b/tests/test_fyle_integrations_imports/test_modules/fixtures.py @@ -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, @@ -6119,7 +6119,7 @@ } }, ], - "create_new_auto_create_categories_destination_attributes_accounts" : [ + "create_new_auto_create_categories_destination_attributes_accounts": [ { 'Name':'Utility', 'SubAccount':False, @@ -6438,7 +6438,6 @@ 323494 ], 'restricted_spender_user_ids':[ - ], 'sub_category':None, 'system_category':'Train', @@ -6459,7 +6458,6 @@ 323492 ], 'restricted_spender_user_ids':[ - ], 'sub_category':None, 'system_category':'Fuel', @@ -7565,4 +7563,4 @@ 'id':'135446' } ] -} \ No newline at end of file +} diff --git a/tests/test_fyle_integrations_imports/test_modules/test_base.py b/tests/test_fyle_integrations_imports/test_modules/test_base.py index 98476e43..8f8ea1fd 100644 --- a/tests/test_fyle_integrations_imports/test_modules/test_base.py +++ b/tests/test_fyle_integrations_imports/test_modules/test_base.py @@ -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} @@ -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() diff --git a/tests/test_fyle_integrations_imports/test_modules/test_categories.py b/tests/test_fyle_integrations_imports/test_modules/test_categories.py index 10e936d5..59c7f5a5 100644 --- a/tests/test_fyle_integrations_imports/test_modules/test_categories.py +++ b/tests/test_fyle_integrations_imports/test_modules/test_categories.py @@ -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 @@ -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) @@ -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) @@ -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() @@ -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() @@ -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() @@ -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: @@ -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() @@ -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() @@ -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() @@ -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() @@ -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: @@ -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() @@ -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() diff --git a/tests/test_mappings/test_tasks.py b/tests/test_mappings/test_tasks.py index cf1eb6c1..441c3912 100644 --- a/tests/test_mappings/test_tasks.py +++ b/tests/test_mappings/test_tasks.py @@ -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, @@ -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):