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

fix project root __init__.py; fix lint, tests #75

Merged
merged 1 commit into from
Jul 5, 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import logging
import urllib
from abc import ABC, abstractmethod
from typing import ClassVar
from typing import ClassVar, Type

from django.conf import settings
from django.utils.translation import gettext as _
Expand Down Expand Up @@ -64,7 +64,7 @@ def get_client_class(self, es_client_type):
class BaseLogSearch(ABC):
_es_index: str = settings.ACCESS_LOG_CONFIG["es_index"]
_es_time_field_name: str = settings.ACCESS_LOG_CONFIG["es_time_field_name"]
_es_client_class: ClassVar[BaseESClient]
_es_client_class: ClassVar[Type[BaseESClient]]

# FIXME: change api_id to gateway_id
def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class BaseDoc:
resource_id: Optional[int] = None
resource_doc_id: Optional[int] = None
resource_doc_swagger_id: Optional[int] = None
has_changed: bool = True
alex-smile marked this conversation as resolved.
Show resolved Hide resolved

@property
def doc_key(self) -> Optional[str]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ def _iter_convert(self):

def get_kubernetes_resources(self) -> Iterable[KubernetesResource]:
if self.include_config:
assert self._gateway_config
yield self._gateway_config

if self.include_stage:
assert self._stage
yield self._stage

if self.include_service:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def apply_resource(self, resource: KubernetesResource) -> bool:
self._registry_dict[self._get_key(resource.kind, resource.metadata.name)] = deepcopy(resource)
return True

def sync_resources_by_key_prefix(self, resources: List[KubernetesResource]) -> List[KubernetesResource]:
def sync_resources_by_key_prefix(self, resources: Iterable[KubernetesResource]) -> List[KubernetesResource]:
self.delete_resources_by_key_prefix()

for resource in resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"""
请求Elasticsearch辅助Client
"""
from typing import ClassVar
from typing import ClassVar, Type

from django.conf import settings

Expand All @@ -28,10 +28,9 @@


class BaseSearchClient:

_es_index = settings.BK_ESB_ACCESS_LOG_CONFIG["es_index"]
_es_time_field_name = settings.BK_ESB_ACCESS_LOG_CONFIG["es_time_field_name"]
_es_client_class: ClassVar[BaseESClient]
_es_client_class: ClassVar[Type[BaseESClient]]

def __init__(self):
self._es_client = self._es_client_class(self._es_index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from unittest.mock import MagicMock

import pytest
from tests.utils.testing import get_response_json

from apigateway.apps.docs.esb.component import views
from apigateway.tests.utils.testing import get_response_json


class TestAPIViewSet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
# to the current version of the project delivered to anyone in the future.
#
import pytest
from tests.utils.testing import get_response_json

from apigateway.apps.docs.esb.doc import views
from apigateway.tests.utils.testing import get_response_json

pytestmark = pytest.mark.django_db

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#
import pytest
from django.conf import settings
from tests.utils.testing import get_response_json

from apigateway.apps.docs.esb.system import views
from apigateway.tests.utils.testing import get_response_json

pytestmark = pytest.mark.django_db

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
# to the current version of the project delivered to anyone in the future.
#
import pytest
from tests.utils.testing import get_response_json

from apigateway.apps.docs.gateway.gateway import views
from apigateway.tests.utils.testing import get_response_json


class TestGatewayViewSet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
# to the current version of the project delivered to anyone in the future.
#
import pytest
from tests.utils.testing import get_response_json

from apigateway.apps.docs.gateway.resource import views
from apigateway.tests.utils.testing import get_response_json


class TestResourceViewSet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# We undertake not to change the open source license (MIT license) applicable
# to the current version of the project delivered to anyone in the future.
#
from utils.jinja2 import render_to_string

from apigateway.apps.docs.gateway.resource_doc.constants import BKAPI_AUTHORIZATION_DESCRIPTION_ZH
from apigateway.utils.jinja2 import render_to_string


def test_bkapi_authorization_description():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
# to the current version of the project delivered to anyone in the future.
#
import pytest
from tests.utils.testing import get_response_json

from apigateway.apps.docs.gateway.resource_doc import views
from apigateway.tests.utils.testing import get_response_json


class TestResourceDocViewSet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
# to the current version of the project delivered to anyone in the future.
#
import pytest
from tests.utils.testing import get_response_json

from apigateway.apps.docs.gateway.sdk import views
from apigateway.apps.docs.gateway.sdk.helpers import DummyResourceForSDK
from apigateway.tests.utils.testing import get_response_json


class TestSDKViewSet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
# to the current version of the project delivered to anyone in the future.
#
import pytest
from tests.utils.testing import get_response_json

from apigateway.apps.docs.gateway.stage import views
from apigateway.tests.utils.testing import get_response_json


class TestStageViewSet:
Expand Down