Skip to content

Commit

Permalink
import Pytest fixtures moved to test_imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuushhh committed Nov 3, 2023
1 parent ff4b9d4 commit 0cc5809
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 91 deletions.
91 changes: 0 additions & 91 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from rest_framework.test import APIClient
from fyle.platform.platform import Platform
from fyle_rest_auth.models import User, AuthToken
from fyle_accounting_mappings.models import DestinationAttribute

from apps.fyle.helpers import get_access_token
from apps.workspaces.models import (
Expand Down Expand Up @@ -276,93 +275,3 @@ def add_accounting_export_summary():
successful_accounting_export_count = 5,
failed_accounting_export_count = 5
)


@pytest.fixture()
@pytest.mark.django_db(databases=['default'])
def add_project_mappings():
"""
Pytest fixtue to add project mappings to a workspace
"""
workspace_ids = [
1, 2, 3
]
for workspace_id in workspace_ids:
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='PROJECT',
display_name='Direct Mail Campaign',
value='Direct Mail Campaign',
destination_id='10064',
detail='Sage 300 Project - Direct Mail Campaign, Id - 10064',
active=True
)
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='PROJECT',
display_name='Platform APIs',
value='Platform APIs',
destination_id='10081',
detail='Sage 300 Project - Platform APIs, Id - 10081',
active=True
)


@pytest.fixture()
@pytest.mark.django_db(databases=['default'])
def add_cost_center_mappings():
"""
Pytest fixtue to add cost center mappings to a workspace
"""
workspace_ids = [
1, 2, 3
]
for workspace_id in workspace_ids:
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='COST_CENTER',
display_name='Direct Mail Campaign',
value='Direct Mail Campaign',
destination_id='10064',
detail='Cost Center - Direct Mail Campaign, Id - 10064',
active=True
)
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='COST_CENTER',
display_name='Platform APIs',
value='Platform APIs',
destination_id='10081',
detail='Cost Center - Platform APIs, Id - 10081',
active=True
)


@pytest.fixture()
@pytest.mark.django_db(databases=['default'])
def add_merchant_mappings():
"""
Pytest fixture to add merchant mappings to a workspace
"""
workspace_ids = [
1, 2, 3
]
for workspace_id in workspace_ids:
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='MERCHANT',
display_name='Direct Mail Campaign',
value='Direct Mail Campaign',
destination_id='10064',
detail='Merchant - Direct Mail Campaign, Id - 10064',
active=True
)
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='MERCHANT',
display_name='Platform APIs',
value='Platform APIs',
destination_id='10081',
detail='Merchant - Platform APIs, Id - 10081',
active=True
)
96 changes: 96 additions & 0 deletions tests/test_mappings/test_imports/test_modules/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""
Fixture configuration for import tests
"""
import pytest

from fyle_accounting_mappings.models import DestinationAttribute


@pytest.fixture()
@pytest.mark.django_db(databases=['default'])
def add_project_mappings():
"""
Pytest fixtue to add project mappings to a workspace
"""
workspace_ids = [
1, 2, 3
]
for workspace_id in workspace_ids:
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='PROJECT',
display_name='Direct Mail Campaign',
value='Direct Mail Campaign',
destination_id='10064',
detail='Sage 300 Project - Direct Mail Campaign, Id - 10064',
active=True
)
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='PROJECT',
display_name='Platform APIs',
value='Platform APIs',
destination_id='10081',
detail='Sage 300 Project - Platform APIs, Id - 10081',
active=True
)


@pytest.fixture()
@pytest.mark.django_db(databases=['default'])
def add_cost_center_mappings():
"""
Pytest fixtue to add cost center mappings to a workspace
"""
workspace_ids = [
1, 2, 3
]
for workspace_id in workspace_ids:
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='COST_CENTER',
display_name='Direct Mail Campaign',
value='Direct Mail Campaign',
destination_id='10064',
detail='Cost Center - Direct Mail Campaign, Id - 10064',
active=True
)
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='COST_CENTER',
display_name='Platform APIs',
value='Platform APIs',
destination_id='10081',
detail='Cost Center - Platform APIs, Id - 10081',
active=True
)


@pytest.fixture()
@pytest.mark.django_db(databases=['default'])
def add_merchant_mappings():
"""
Pytest fixture to add merchant mappings to a workspace
"""
workspace_ids = [
1, 2, 3
]
for workspace_id in workspace_ids:
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='MERCHANT',
display_name='Direct Mail Campaign',
value='Direct Mail Campaign',
destination_id='10064',
detail='Merchant - Direct Mail Campaign, Id - 10064',
active=True
)
DestinationAttribute.objects.create(
workspace_id=workspace_id,
attribute_type='MERCHANT',
display_name='Platform APIs',
value='Platform APIs',
destination_id='10081',
detail='Merchant - Platform APIs, Id - 10081',
active=True
)

0 comments on commit 0cc5809

Please sign in to comment.