Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests and script for admin subscription creation #508

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading