diff --git a/.flake8 b/.flake8 index c7bff1ca..b17bdab5 100644 --- a/.flake8 +++ b/.flake8 @@ -28,3 +28,4 @@ max-line-length = 99 max-complexity = 19 ban-relative-imports = true select = B,C,E,F,N,W,I25 +exclude=*env diff --git a/apps/mappings/tasks.py b/apps/mappings/tasks.py index 62387fc8..59d31f07 100644 --- a/apps/mappings/tasks.py +++ b/apps/mappings/tasks.py @@ -766,7 +766,7 @@ def post_merchants(platform_connection: PlatformConnector, workspace_id: int): if fyle_payload: platform_connection.merchants.post(fyle_payload) - platform_connection.merchants.sync(workspace_id) + platform_connection.merchants.sync() @handle_import_exceptions(task_name='Auto Create Vendors as Merchants') @@ -775,7 +775,7 @@ def auto_create_vendors_as_merchants(workspace_id): fyle_connection = PlatformConnector(fyle_credentials) - fyle_connection.merchants.sync(workspace_id) + fyle_connection.merchants.sync() sync_qbo_attribute('VENDOR', workspace_id) post_merchants(fyle_connection, workspace_id) diff --git a/requirements.txt b/requirements.txt index 74af2c03..1113e227 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,7 +22,7 @@ enum34==1.1.10 future==0.18.2 fyle==0.30.0 fyle-accounting-mappings==1.26.1 -fyle-integrations-platform-connector==1.30.0 +fyle-integrations-platform-connector==1.32.3 fyle-rest-auth==1.5.0 gevent==22.10.2 gunicorn==20.1.0 diff --git a/tests/test_fyle/fixtures.py b/tests/test_fyle/fixtures.py index 872fc142..a0568052 100644 --- a/tests/test_fyle/fixtures.py +++ b/tests/test_fyle/fixtures.py @@ -9123,11 +9123,24 @@ { 'code': '16200', 'created_at': '2022-08-12T16:50:53.658771+00:00', - 'display_name': 'Patents & Licenses', - 'id': 207983, + 'display_name': 'Patents & Licenses - Test', + 'id': 22330021, 'is_enabled': True, - 'name': 'Patents & Licenses', - 'org_id': 'orNoatdUnm1w', + 'name': 'Patents & Licenses - Included', + 'org_id': 'orPJvXuoLqvJ', + 'restricted_project_ids': None, + 'sub_category': None, + 'system_category': None, + 'updated_at': '2022-08-30T16:50:44.671684+00:00', + }, + { + 'code': '16200', + 'created_at': '2022-08-12T16:50:53.658771+00:00', + 'display_name': 'Patents & Licenses - Test', + 'id': 22330021, + 'is_enabled': True, + 'name': 'Patents & Licenses - Exempted', + 'org_id': 'orPJvXuoasfnn1J', 'restricted_project_ids': None, 'sub_category': None, 'system_category': None, diff --git a/tests/test_mappings/test_tasks.py b/tests/test_mappings/test_tasks.py index 42c0c8dd..9759d6c9 100644 --- a/tests/test_mappings/test_tasks.py +++ b/tests/test_mappings/test_tasks.py @@ -45,6 +45,7 @@ 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): @@ -86,13 +87,14 @@ def test_disable_category_for_items_mapping(db, mocker): workspace_general_setting.save() # mocking all the sdk calls - mocker.patch('fyle_integrations_platform_connector.apis.Categories.sync', return_value=[]) + mocker.patch('fyle.platform.apis.v1beta.admin.Categories.list_all', return_value=fyle_data['get_all_categories']) mocker.patch('fyle_integrations_platform_connector.apis.Categories.post_bulk', return_value=[]) mocker.patch('qbosdk.apis.Items.get', return_value=[]) # adding test data to the database destination_attribute = DestinationAttribute.objects.create(attribute_type='ACCOUNT', display_name='Item', value='Concrete', destination_id=3, workspace_id=workspace_id, active=False) expense_attribute = ExpenseAttribute.objects.create(attribute_type='CATEGORY', display_name='Category', value='Concrete', source_id='253737253737', workspace_id=workspace_id, active=True) + Mapping.objects.create(source_type='CATEGORY', destination_type='ACCOUNT', destination_id=destination_attribute.id, source_id=expense_attribute.id, workspace_id=workspace_id) disable_category_for_items_mapping(workspace_id) @@ -228,14 +230,24 @@ def test_auto_create_category_mappings_with_items(db, mocker): assert mappings == 46 mocker.patch('qbosdk.apis.Accounts.get', return_value=[]) - mocker.patch('fyle_integrations_platform_connector.apis.Categories.sync', return_value=[]) + mocker.patch('fyle.platform.apis.v1beta.admin.Categories.list_all', return_value=fyle_data['get_all_categories']) mocker.patch('fyle_integrations_platform_connector.apis.Categories.post_bulk', return_value=[]) mocker.patch('qbosdk.apis.Items.get', return_value=[]) response = auto_create_category_mappings(workspace_id=workspace_id) assert response == [] + category = ExpenseAttribute.objects.filter(value='Patents & Licenses - Included', workspace_id=workspace_id).first() + + assert category != None + assert category.value == 'Patents & Licenses - Included' + + category = ExpenseAttribute.objects.filter(value='Patents & Licenses - Exempted', workspace_id=workspace_id).first() + + assert category == None + item_count = Mapping.objects.filter(destination_type='ACCOUNT', source_type='CATEGORY', destination__display_name='Item', workspace_id=workspace_id).count() + assert item_count == 0 @@ -452,7 +464,7 @@ def test_schedule_fyle_attributes_creation(db, mocker): def test_post_merchants(db, mocker): mocker.patch('fyle_integrations_platform_connector.apis.Merchants.get', return_value=data['get_merchants']) mocker.patch('fyle_integrations_platform_connector.apis.Merchants.post', return_value=[]) - mocker.patch('fyle_integrations_platform_connector.apis.Merchants.sync', return_value=[]) + mocker.patch('fyle.platform.apis.v1beta.admin.expense_fields', return_value=data['get_merchants']) workspace_id = 5 fyle_credentials = FyleCredential.objects.all() fyle_credentials = FyleCredential.objects.get(workspace_id=workspace_id)