Skip to content

Commit

Permalink
Test that replication method was not called when there are no princip…
Browse files Browse the repository at this point in the history
…als in group to migrate
  • Loading branch information
lpichler committed Nov 13, 2024
1 parent 4c35dad commit 5d56e24
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/migration_tool/tests_migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
from uuid import uuid4

from django.test import TestCase, override_settings
from functools import partial

from api.models import Tenant
from management.models import *
from migration_tool.migrate import migrate_data
from migration_tool.migrate import migrate_data, migrate_groups_for_tenant
from management.group.definer import seed_group, clone_default_group_in_public_schema


Expand Down Expand Up @@ -107,6 +108,18 @@ def setUp(self):
# tenant 2 - org_id=7654321
another_tenant = Tenant.objects.create(org_id="7654321")

root_workspace_another_tenant = Workspace.objects.create(
type=Workspace.Types.ROOT, tenant=another_tenant, name="Root Workspace"
)
Workspace.objects.create(
type=Workspace.Types.DEFAULT,
tenant=another_tenant,
name="Default Workspace",
parent=root_workspace_another_tenant,
)

Group.objects.create(name="another_group", tenant=another_tenant)

# setup data for another tenant 7654321
self.role_b = Role.objects.create(name="role_b", tenant=another_tenant)
self.access_b = Access.objects.create(permission=permission2, role=self.role_b, tenant=another_tenant)
Expand All @@ -117,6 +130,14 @@ def setUp(self):
# create custom default group
self.custom_default_group = clone_default_group_in_public_schema(default_group, self.tenant)

@override_settings(REPLICATION_TO_RELATION_ENABLED=True, PRINCIPAL_USER_DOMAIN="redhat", READ_ONLY_API_MODE=True)
@patch("migration_tool.migrate.RelationApiDualWriteGroupHandler.replicate")
def test_migration_of_data_no_replication_event_to_migrate_groups(self, replicate_method):
"""Test that we get the correct access for a principal."""
kwargs = {"exclude_apps": ["app1"], "orgs": ["7654321"]}
migrate_data(**kwargs)
replicate_method.assert_not_called()

@override_settings(REPLICATION_TO_RELATION_ENABLED=True, PRINCIPAL_USER_DOMAIN="redhat", READ_ONLY_API_MODE=True)
@patch("management.relation_replicator.logging_replicator.logger")
def test_migration_of_data(self, logger_mock):
Expand Down

0 comments on commit 5d56e24

Please sign in to comment.