From 1cc938b2e166b61c4246693eeaa443af1ac529f2 Mon Sep 17 00:00:00 2001 From: labhvam5 Date: Wed, 6 Dec 2023 13:55:12 +0530 Subject: [PATCH] removing the construct test --- .../test_modules/test_categories.py | 154 ------------------ 1 file changed, 154 deletions(-) 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 1d957d4d..1ea036f0 100644 --- a/tests/test_fyle_integrations_imports/test_modules/test_categories.py +++ b/tests/test_fyle_integrations_imports/test_modules/test_categories.py @@ -458,157 +458,3 @@ def test_construct_fyle_payload(db): ) assert fyle_payload == categories_data['create_fyle_category_payload_create_disable_case'] - -def compare_q_objects(q1, q2): - # Convert Q objects to dictionaries and sort the key-value pairs - q1_dict = sorted(q1.children, key=lambda x: x[0]) - q2_dict = sorted(q2.children, key=lambda x: x[0]) - - # Compare the sorted dictionaries - assert q1_dict == q2_dict - -def test_construct_attributes_filter(db): - workspace_id = 2 - qbo_credentials = QBOCredential.get_active_qbo_credentials(workspace_id) - qbo_connection = QBOConnector(credentials_object=qbo_credentials, workspace_id=workspace_id) - - Workspace.objects.filter(id=workspace_id).update(fyle_org_id='or5qYLrvnoF9') - - # destination-field without sync-after with only import-categories enabled - category = Category(workspace_id, 'ACCOUNT', None, qbo_connection, ['accounts'], True, False, ['Expense', 'Fixed Asset']) - category.sync_after = None - constructed_expense_filter = category.construct_attributes_filter('ACCOUNT', True) - - filter_1 = { - 'attribute_type': 'ACCOUNT', - 'workspace_id': workspace_id, - 'detail__account_type__in': ['Expense', 'Fixed Asset'], - 'display_name':'Account', - } - response = Q(**filter_1) - - compare_q_objects(constructed_expense_filter, response) - - # destination-field without sync-after with only import-items enabled - category = Category(workspace_id, 'ACCOUNT', None, qbo_connection, ['items'], True, False, ['Expense', 'Fixed Asset']) - category.sync_after = None - constructed_expense_filter = category.construct_attributes_filter('ACCOUNT', True) - - filter_1 = { - 'attribute_type': 'ACCOUNT', - 'workspace_id': workspace_id, - 'display_name':'Item', - } - response = Q(**filter_1) - - compare_q_objects(constructed_expense_filter, response) - - # destination-field without sync-after with both import-items and import-categories enabled - category = Category(workspace_id, 'ACCOUNT', None, qbo_connection, ['items', 'accounts'], True, False, ['Expense', 'Fixed Asset']) - category.sync_after = None - constructed_expense_filter = category.construct_attributes_filter('ACCOUNT', True) - - filter_1 = { - 'attribute_type': 'ACCOUNT', - 'workspace_id': workspace_id, - 'display_name':'Item', - } - filter_2 = { - 'attribute_type': 'ACCOUNT', - 'workspace_id': workspace_id, - 'detail__account_type__in': ['Expense', 'Fixed Asset'], - 'display_name':'Account', - } - response = Q(**filter_2) | Q(**filter_1) - - # assert constructed_expense_filter == response - - # adding the sync_after value - date_string = '2023-08-06 12:50:05.875029' - sync_after = datetime.strptime(date_string, '%Y-%m-%d %H:%M:%S.%f') - - # destination-field with sync-after with only import-categories enabled - category = Category(workspace_id, 'ACCOUNT', None, qbo_connection, ['accounts'], True, False, ['Expense', 'Fixed Asset']) - category.sync_after = sync_after - constructed_expense_filter = category.construct_attributes_filter('ACCOUNT', True) - - filter_1 = { - 'attribute_type': 'ACCOUNT', - 'workspace_id': workspace_id, - 'updated_at__gte': sync_after, - 'detail__account_type__in': ['Expense', 'Fixed Asset'], - 'display_name':'Account', - } - response = Q(**filter_1) - - compare_q_objects(constructed_expense_filter, response) - - # destination-field with sync-after with only import-items enabled - category = Category(workspace_id, 'ACCOUNT', None, qbo_connection, ['items'], True, False, ['Expense', 'Fixed Asset']) - category.sync_after = sync_after - constructed_expense_filter = category.construct_attributes_filter('ACCOUNT', True) - - filter_1 = { - 'attribute_type': 'ACCOUNT', - 'workspace_id': workspace_id, - 'updated_at__gte': sync_after, - 'display_name':'Item', - } - response = Q(**filter_1) - - compare_q_objects(constructed_expense_filter, response) - - # destination-field with sync-after with both import-items and import-categories enabled - category = Category(workspace_id, 'ACCOUNT', None, qbo_connection, ['items', 'accounts'], True, False, ['Expense', 'Fixed Asset']) - category.sync_after = sync_after - constructed_expense_filter = category.construct_attributes_filter('ACCOUNT', True) - - filter_1 = { - 'attribute_type': 'ACCOUNT', - 'workspace_id': workspace_id, - 'updated_at__gte': sync_after, - 'display_name':'Item', - } - filter_2 = { - 'attribute_type': 'ACCOUNT', - 'workspace_id': workspace_id, - 'detail__account_type__in': ['Expense', 'Fixed Asset'], - 'updated_at__gte': sync_after, - 'display_name':'Account', - } - response = Q(**filter_2) | Q(**filter_1) - - print("constructed_expense_filter") - print(constructed_expense_filter) - print("response") - print(response) - - assert constructed_expense_filter == response - - # source-field with sync-after and paginated_values - category = Category(workspace_id, 'ACCOUNT', None, qbo_connection, ['items'], True, False, ['Expense', 'Fixed Asset']) - category.sync_after = sync_after - constructed_expense_filter = category.construct_attributes_filter('CATEGORY', False, ['Fuel', 'Advertising']) - - filter_1 = { - 'attribute_type': 'CATEGORY', - 'workspace_id': workspace_id, - 'value__in': ['Fuel', 'Advertising'], - } - response = Q(**filter_1) - - compare_q_objects(constructed_expense_filter, response) - - # source-field without sync-after and paginated_values - category = Category(workspace_id, 'ACCOUNT', None, qbo_connection, ['items'], True, False, ['Expense', 'Fixed Asset']) - category.sync_after = None - constructed_expense_filter = category.construct_attributes_filter('CATEGORY', False, ['Fuel', 'Advertising']) - - filter_1 = { - 'attribute_type': 'CATEGORY', - 'workspace_id': workspace_id, - 'value__in': ['Fuel', 'Advertising'], - } - response = Q(**filter_1) - - compare_q_objects(constructed_expense_filter, response)