mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-06 20:06:12 +08:00
auto fix by pre-commit hooks
This commit is contained in:
parent
ebcf1cc300
commit
1543ba21d2
@ -7,10 +7,10 @@ from ..config import (
|
||||
NoSuchUserException,
|
||||
config,
|
||||
)
|
||||
from ..config.db_config import SubscribeDupException
|
||||
from ..platform import check_sub_target, platform_manager
|
||||
from ..types import Target as T_Target
|
||||
from ..types import WeightConfig
|
||||
from ..config.db_config import SubscribeDupException
|
||||
from .jwt import pack_jwt
|
||||
from .token_manager import token_manager
|
||||
|
||||
|
@ -23,9 +23,11 @@ def _get_time():
|
||||
cur_time = time(hour=dt.hour, minute=dt.minute, second=dt.second)
|
||||
return cur_time
|
||||
|
||||
|
||||
class SubscribeDupException(Exception):
|
||||
...
|
||||
|
||||
|
||||
class DBConfig:
|
||||
def __init__(self):
|
||||
self.add_target_hook: Optional[Callable[[str, T_Target], Awaitable]] = None
|
||||
@ -79,7 +81,7 @@ class DBConfig:
|
||||
try:
|
||||
await session.commit()
|
||||
except IntegrityError as e:
|
||||
if len(e.args) > 0 and 'UNIQUE constraint failed' in e.args[0]:
|
||||
if len(e.args) > 0 and "UNIQUE constraint failed" in e.args[0]:
|
||||
raise SubscribeDupException()
|
||||
raise e
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
from nonebug.app import App
|
||||
import pytest
|
||||
from nonebug.app import App
|
||||
from sqlalchemy.ext.asyncio.session import AsyncSession
|
||||
from sqlalchemy.sql.functions import func
|
||||
from sqlmodel.sql.expression import select
|
||||
@ -72,11 +72,11 @@ async def test_add_subscribe(app: App, init_scheduler):
|
||||
assert conf.categories == [1]
|
||||
assert conf.tags == ["tag"]
|
||||
|
||||
|
||||
async def test_add_dup_sub(init_scheduler):
|
||||
|
||||
from nonebot_bison.config.db_config import config
|
||||
from nonebot_bison.config.db_config import SubscribeDupException, config
|
||||
from nonebot_bison.types import Target as TTarget
|
||||
from nonebot_bison.config.db_config import SubscribeDupException
|
||||
|
||||
await config.add_subscribe(
|
||||
user=123,
|
||||
@ -99,6 +99,7 @@ async def test_add_dup_sub(init_scheduler):
|
||||
tags=[],
|
||||
)
|
||||
|
||||
|
||||
async def test_del_subsribe(init_scheduler):
|
||||
from nonebot_bison.config.db_config import config
|
||||
from nonebot_bison.config.db_model import Subscribe, Target, User
|
||||
|
Loading…
x
Reference in New Issue
Block a user