mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-07 20:33:01 +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,
|
NoSuchUserException,
|
||||||
config,
|
config,
|
||||||
)
|
)
|
||||||
|
from ..config.db_config import SubscribeDupException
|
||||||
from ..platform import check_sub_target, platform_manager
|
from ..platform import check_sub_target, platform_manager
|
||||||
from ..types import Target as T_Target
|
from ..types import Target as T_Target
|
||||||
from ..types import WeightConfig
|
from ..types import WeightConfig
|
||||||
from ..config.db_config import SubscribeDupException
|
|
||||||
from .jwt import pack_jwt
|
from .jwt import pack_jwt
|
||||||
from .token_manager import token_manager
|
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)
|
cur_time = time(hour=dt.hour, minute=dt.minute, second=dt.second)
|
||||||
return cur_time
|
return cur_time
|
||||||
|
|
||||||
|
|
||||||
class SubscribeDupException(Exception):
|
class SubscribeDupException(Exception):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
class DBConfig:
|
class DBConfig:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.add_target_hook: Optional[Callable[[str, T_Target], Awaitable]] = None
|
self.add_target_hook: Optional[Callable[[str, T_Target], Awaitable]] = None
|
||||||
@ -79,7 +81,7 @@ class DBConfig:
|
|||||||
try:
|
try:
|
||||||
await session.commit()
|
await session.commit()
|
||||||
except IntegrityError as e:
|
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 SubscribeDupException()
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from nonebug.app import App
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from nonebug.app import App
|
||||||
from sqlalchemy.ext.asyncio.session import AsyncSession
|
from sqlalchemy.ext.asyncio.session import AsyncSession
|
||||||
from sqlalchemy.sql.functions import func
|
from sqlalchemy.sql.functions import func
|
||||||
from sqlmodel.sql.expression import select
|
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.categories == [1]
|
||||||
assert conf.tags == ["tag"]
|
assert conf.tags == ["tag"]
|
||||||
|
|
||||||
|
|
||||||
async def test_add_dup_sub(init_scheduler):
|
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.types import Target as TTarget
|
||||||
from nonebot_bison.config.db_config import SubscribeDupException
|
|
||||||
|
|
||||||
await config.add_subscribe(
|
await config.add_subscribe(
|
||||||
user=123,
|
user=123,
|
||||||
@ -99,6 +99,7 @@ async def test_add_dup_sub(init_scheduler):
|
|||||||
tags=[],
|
tags=[],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_del_subsribe(init_scheduler):
|
async def test_del_subsribe(init_scheduler):
|
||||||
from nonebot_bison.config.db_config import config
|
from nonebot_bison.config.db_config import config
|
||||||
from nonebot_bison.config.db_model import Subscribe, Target, User
|
from nonebot_bison.config.db_model import Subscribe, Target, User
|
||||||
|
Loading…
x
Reference in New Issue
Block a user