Skip to content

Commit

Permalink
feat: 默认使用 fake 适配器 (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 authored Apr 16, 2024
1 parent daf3d1e commit b00fbdb
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/
### Added

- 使用 Pydantic 2.0
- 默认使用 fake 适配器

### Fixed

Expand Down
58 changes: 55 additions & 3 deletions src/utils/plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,70 @@

RUNNER = """import json
import os
from nonebot import init, load_plugin, require, logger
from typing import override
from nonebot import init, load_plugin, logger, require
from nonebot.drivers import (
ASGIMixin,
HTTPClientMixin,
Request,
Response,
WebSocketClientMixin,
)
from nonebot.drivers import Driver as BaseDriver
from pydantic import BaseModel
class Driver(BaseDriver, ASGIMixin, HTTPClientMixin, WebSocketClientMixin):
@property
@override
def type(self) -> str:
return "fake"
@property
@override
def logger(self):
return logger
@override
def run(self, *args, **kwargs):
super().run(*args, **kwargs)
@property
@override
def server_app(self):
raise NotImplementedError
@property
@override
def asgi(self):
raise NotImplementedError
@override
def setup_http_server(self, setup):
raise NotImplementedError
@override
def setup_websocket_server(self, setup):
raise NotImplementedError
@override
async def request(self, setup: Request) -> Response:
raise NotImplementedError
@override
async def websocket(self, setup: Request) -> Response:
raise NotImplementedError
class SetEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
return list(obj)
return json.JSONEncoder.default(self, obj)
init()
init(driver="runner")
plugin = load_plugin("{}")
if not plugin:
Expand Down

0 comments on commit b00fbdb

Please sign in to comment.