Skip to content

Commit

Permalink
Adding projects test
Browse files Browse the repository at this point in the history
  • Loading branch information
labhvam5 committed Nov 20, 2023
1 parent d4327f7 commit 3cbb8c2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fyle_integrations_imports
26 changes: 26 additions & 0 deletions tests/test_fyle_integrations_imports/test_modules/fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
projects_data = {
"get_projects_destination_attributes_customers": [
{
"FullyQualifiedName": "France",
"domain": "QBO",
"Name": "France",
"SyncToken": "0",
"SubClass": False,
"sparse": False,
"Active": True,
"Id": "5000000000000007280",
"MetaData": {"CreateTime": "2015-07-22T13:57:27-07:00", "LastUpdatedTime": "2015-07-22T13:57:27-07:00"},
},
{
"FullyQualifiedName": "France",
"domain": "QBO",
"Name": "France",
"SyncToken": "0",
"SubClass": False,
"sparse": False,
"Active": True,
"Id": "9",
"MetaData": {"CreateTime": "2015-07-22T13:57:27-07:00", "LastUpdatedTime": "2015-07-22T13:57:27-07:00"},
},
],
}
27 changes: 27 additions & 0 deletions tests/test_fyle_integrations_imports/test_modules/test_projects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from fyle_accounting_mappings.models import (
DestinationAttribute,
ExpenseAttribute,
Mapping,
)
from apps.quickbooks_online.utils import QBOConnector
from apps.workspaces.models import QBOCredential
from fyle_integrations_imports.modules import Project
from tests.test_fyle_integrations_imports.test_modules.fixtures import projects_data

def test_sync_destination_attributes(mocker, db):
workspace_id = 3

mocker.patch('qbosdk.apis.Customers.count', return_value=5)
mocker.patch('qbosdk.apis.Customers.get', return_value=projects_data['get_projects_destination_attributes_customers'])

qbo_credentials = QBOCredential.get_active_qbo_credentials(workspace_id)
qbo_connection = QBOConnector(credentials_object=qbo_credentials, workspace_id=workspace_id)

destination_attributes_count = DestinationAttribute.objects.filter(workspace_id=3, attribute_type='CUSTOMER').count()
assert destination_attributes_count == 29

project = Project(3, 'CUSTOMER', None, qbo_connection, 'customers', True)
project.sync_destination_attributes()

destination_attributes_count = DestinationAttribute.objects.filter(workspace_id=3, attribute_type='CUSTOMER').count()
assert destination_attributes_count == 30
Empty file.

0 comments on commit 3cbb8c2

Please sign in to comment.