Skip to content

Commit

Permalink
feat: update tenant user status in periodic task
Browse files Browse the repository at this point in the history
  • Loading branch information
rolin999 committed Nov 28, 2024
1 parent 2aedd84 commit f9f77a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/bk-user/bkuser/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
},
"periodic_update_tenant_user_status": {
"task": "bkuser.apps.tenant.periodic_tasks.update_expired_tenant_user_status",
"schedule": crontab(minute="0", hour="8"),
"schedule": crontab(minute="0", hour="3"),
},
}
# Celery 消息队列配置
Expand Down
21 changes: 14 additions & 7 deletions src/bk-user/tests/apps/tenant/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@
from django.utils import timezone

from tests.test_utils.helpers import generate_random_string
from tests.test_utils.tenant import create_tenant


@pytest.fixture
def not_expired_tenant_user(bk_user):
data_source_user = DataSourceUser.objects.get(username=bk_user.username)
def not_expired_tenant_user(bare_local_data_source, random_tenant):
data_source_user = DataSourceUser.objects.create(
username=generate_random_string(length=8),
full_name=generate_random_string(length=8),
data_source=bare_local_data_source,
)
return TenantUser.objects.create(
id=generate_random_string(),
tenant=create_tenant(generate_random_string()),
tenant=random_tenant,
data_source=data_source_user.data_source,
data_source_user=data_source_user,
status=TenantUserStatus.ENABLED,
Expand All @@ -41,11 +44,15 @@ def not_expired_tenant_user(bk_user):


@pytest.fixture
def expired_tenant_user(bk_user):
data_source_user = DataSourceUser.objects.get(username=bk_user.username)
def expired_tenant_user(bare_local_data_source, random_tenant):
data_source_user = DataSourceUser.objects.create(
username=generate_random_string(length=8),
full_name=generate_random_string(length=8),
data_source=bare_local_data_source,
)
return TenantUser.objects.create(
id=generate_random_string(),
tenant=create_tenant(generate_random_string()),
tenant=random_tenant,
data_source=data_source_user.data_source,
data_source_user=data_source_user,
status=TenantUserStatus.ENABLED,
Expand Down

0 comments on commit f9f77a5

Please sign in to comment.