Skip to content

Commit

Permalink
Tests and script for admin subscription creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 committed Oct 18, 2023
1 parent 5cd6ef4 commit 9d5d48a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
13 changes: 13 additions & 0 deletions scripts/python/create-admin-subscriptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Create admin subscriptions for existing workspaces

from apps.workspaces.tasks import async_create_admin_subcriptions
from apps.workspaces.models import Workspace

workspaces = Workspace.objects.all()

for workspace in workspaces:
try:
async_create_admin_subcriptions(workspace.id)
except Exception as e:
print('Error while creating admin subscriptions for workspace - {} with ID - {}'.format(workspace.name, workspace.id))
print(e.__dict__)
6 changes: 5 additions & 1 deletion tests/test_fyle/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
import pytest

from apps.fyle.models import Expense, ExpenseGroup, ExpenseGroupSettings
from apps.fyle.tasks import create_expense_groups, post_accounting_export_summary, import_and_export_expenses
from apps.fyle.tasks import (
create_expense_groups,
post_accounting_export_summary,
import_and_export_expenses
)
from apps.fyle.actions import mark_expenses_as_skipped
from apps.tasks.models import TaskLog
from apps.workspaces.models import FyleCredential, Workspace
Expand Down
17 changes: 15 additions & 2 deletions tests/test_workspaces/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
from apps.fyle.models import ExpenseGroupSettings
from apps.tasks.models import TaskLog
from apps.workspaces.models import WorkspaceGeneralSettings, WorkspaceSchedule
from apps.workspaces.tasks import run_email_notification, run_sync_schedule, \
schedule_sync, async_add_admins_to_workspace
from apps.workspaces.tasks import (
run_email_notification,
run_sync_schedule,
schedule_sync,
async_add_admins_to_workspace,
async_create_admin_subcriptions
)
from apps.users.models import User

from tests.test_workspaces.fixtures import data
Expand Down Expand Up @@ -102,3 +107,11 @@ def test_email_notification(db):
attribute.save()

run_email_notification(workspace_id=workspace_id)


def test_async_create_admin_subcriptions(db, mocker):
mocker.patch(
'fyle.platform.apis.v1beta.admin.Subscriptions.post',
return_value={}
)
async_create_admin_subcriptions(3)

0 comments on commit 9d5d48a

Please sign in to comment.