Skip to content

Commit

Permalink
removing old test and lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
labhvam5 committed Nov 8, 2023
1 parent be7b007 commit 69fb03f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 52 deletions.
4 changes: 2 additions & 2 deletions apps/mappings/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def schedule_or_delete_fyle_import_tasks(workspace_general_settings: WorkspaceGe

if task_to_be_scheduled:
Schedule.objects.update_or_create(
func='apps.mappings.queue.construct_task_settings_payload',
func='apps.mappings.queues.construct_task_settings_payload',
args='{}'.format(workspace_general_settings.workspace_id),
defaults={
'schedule_type': Schedule.MINUTES,
Expand All @@ -37,6 +37,6 @@ def schedule_or_delete_fyle_import_tasks(workspace_general_settings: WorkspaceGe
# If the import fields count is 0, delete the schedule
if import_fields_count == 0:
Schedule.objects.filter(
func='apps.mappings.queue.construct_task_settings_payload',
func='apps.mappings.queues.construct_task_settings_payload',
args='{}'.format(workspace_general_settings.workspace_id)
).delete()
2 changes: 1 addition & 1 deletion apps/workspaces/apis/map_employees/triggers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from apps.mappings.queue import schedule_auto_map_employees
from apps.mappings.queues import schedule_auto_map_employees
from apps.workspaces.models import WorkspaceGeneralSettings


Expand Down
51 changes: 2 additions & 49 deletions tests/test_mappings/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
auto_create_category_mappings,
auto_create_cost_center_mappings,
auto_create_expense_fields_mappings,
auto_create_project_mappings,
auto_create_tax_codes_mappings,
auto_create_vendors_as_merchants,
auto_import_and_map_fyle_fields,
Expand Down Expand Up @@ -158,52 +157,6 @@ def test_schedule_tax_groups_creation(db):
assert schedule == None


def test_auto_create_project_mappings(db, mocker):
workspace_id = 4
mocker.patch('fyle_integrations_platform_connector.apis.Projects.sync', return_value=[])
mocker.patch('fyle_integrations_platform_connector.apis.Projects.post_bulk', return_value=[])
mocker.patch('qbosdk.apis.Customers.count', return_value=5)
mocker.patch('qbosdk.apis.Customers.get', return_value=[])
mocker.patch('qbosdk.apis.Departments.get', return_value=[])

response = auto_create_project_mappings(workspace_id=workspace_id)
assert response == None

mapping_setting = MappingSetting.objects.get(source_field='PROJECT', workspace_id=workspace_id)
mapping_setting.destination_field = 'CUSTOMER'
mapping_setting.save()

expense_attributes_to_enable = ExpenseAttribute.objects.filter(mapping__isnull=False, mapping__source_type='PROJECT', attribute_type='PROJECT', workspace_id=workspace_id).first()

expense_attributes_to_enable.active = False
expense_attributes_to_enable.save()

response = auto_create_project_mappings(workspace_id=workspace_id)
assert response == None

projects = DestinationAttribute.objects.filter(workspace_id=workspace_id, attribute_type='PROJECT').count()
mappings = Mapping.objects.filter(workspace_id=workspace_id, destination_type='PROJECT').count()

assert mappings == projects

with mock.patch('fyle_integrations_platform_connector.apis.Projects.sync') as mock_call:
mock_call.side_effect = WrongParamsError(msg='invalid params', response='invalid params')
auto_create_project_mappings(workspace_id=workspace_id)

mock_call.side_effect = Exception
auto_create_project_mappings(workspace_id=workspace_id)

mock_call.side_effect = FyleInvalidTokenError(msg='Invalid Token for fyle', response='Invalid Token for fyle')
auto_create_project_mappings(workspace_id=workspace_id)

fyle_credentials = FyleCredential.objects.get(workspace_id=workspace_id)
fyle_credentials.delete()

response = auto_create_project_mappings(workspace_id=workspace_id)

assert response == None


def test_remove_duplicates(db):

attributes = DestinationAttribute.objects.filter(attribute_type='EMPLOYEE')
Expand Down Expand Up @@ -271,10 +224,10 @@ def test_auto_create_category_mappings(db, mocker):

with mock.patch('fyle_integrations_platform_connector.apis.Projects.sync') as mock_call:
mock_call.side_effect = WrongParamsError(msg='invalid params', response='invalid params')
auto_create_project_mappings(workspace_id=workspace_id)
auto_create_category_mappings(workspace_id=workspace_id)

mock_call.side_effect = FyleInvalidTokenError(msg='Invalid Token for fyle', response='Invalid Token for fyle')
auto_create_project_mappings(workspace_id=workspace_id)
auto_create_category_mappings(workspace_id=workspace_id)

fyle_credentials = FyleCredential.objects.get(workspace_id=workspace_id)
fyle_credentials.delete()
Expand Down

0 comments on commit 69fb03f

Please sign in to comment.