Skip to content

Commit

Permalink
feature: 支持bk_agent_id (close TencentBlueKing#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhw8 committed Apr 8, 2022
1 parent 2f0500d commit ce02cad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions apps/backend/tests/view/test_get_gse_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

import copy

from django.db import transaction

from apps.backend.constants import REDIS_AGENT_CONF_KEY_TPL
from apps.backend.utils.redis import REDIS_INST
from apps.backend.views import generate_gse_config
Expand All @@ -32,8 +30,7 @@ def setUpTestData(cls):

super().setUpTestData()
host_model_data = copy.deepcopy(common_unit.host.HOST_MODEL_DATA)
with transaction.atomic():
cls.host = models.Host.objects.create(**host_model_data)
cls.host = models.Host.objects.create(**host_model_data)
# 此类查询在单元测试中会有如下报错, 因此将数据预先查询缓存
# TransactionManagementError "You can't execute queries until the end of the 'atomic' block" while using signals
# 参考:https://stackoverflow.com/questions/21458387
Expand Down
4 changes: 2 additions & 2 deletions apps/utils/unittest/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from django.conf import settings
from django.contrib.auth import get_user_model
from django.test import Client, RequestFactory, TestCase
from django.test import Client, RequestFactory, TransactionTestCase

from apps.utils.unittest import base

Expand Down Expand Up @@ -209,7 +209,7 @@ def tearDownClass(cls):
super().tearDownClass()


class CustomBaseTestCase(OverwriteSettingsMixin, AssertDataMixin, MockSuperUserMixin, TestCase):
class CustomBaseTestCase(OverwriteSettingsMixin, AssertDataMixin, MockSuperUserMixin, TransactionTestCase):
client_class = Client

@property
Expand Down

0 comments on commit ce02cad

Please sign in to comment.