black'd
This commit is contained in:
parent
a512896ff5
commit
a810d5bdc3
3 changed files with 13 additions and 9 deletions
|
@ -3,8 +3,8 @@ from typing import Union
|
||||||
|
|
||||||
import dataset
|
import dataset
|
||||||
|
|
||||||
from butterrobot.config import DATABASE_PATH, SECRET_KEY
|
from butterrobot.config import SECRET_KEY, DATABASE_PATH
|
||||||
from butterrobot.objects import Channel, ChannelPlugin, User
|
from butterrobot.objects import User, Channel, ChannelPlugin
|
||||||
|
|
||||||
db = dataset.connect(DATABASE_PATH)
|
db = dataset.connect(DATABASE_PATH)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class Query:
|
||||||
yield cls.obj(**row)
|
yield cls.obj(**row)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get(cls, **kwargs) -> "class":
|
def get(cls, **kwargs):
|
||||||
"""
|
"""
|
||||||
Returns the object representation of an specific row in a table.
|
Returns the object representation of an specific row in a table.
|
||||||
Allows retrieving object by multiple columns.
|
Allows retrieving object by multiple columns.
|
||||||
|
@ -153,7 +153,9 @@ class ChannelPluginQuery(Query):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_from_channel_id(cls, channel_id):
|
def get_from_channel_id(cls, channel_id):
|
||||||
yield from [cls.obj(**row) for row in db[cls.tablename].find(channel_id=channel_id)]
|
yield from [
|
||||||
|
cls.obj(**row) for row in db[cls.tablename].find(channel_id=channel_id)
|
||||||
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def delete_by_channel(cls, channel_id):
|
def delete_by_channel(cls, channel_id):
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Platform:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def parse_incoming_message(cls, request) -> 'Message':
|
def parse_incoming_message(cls, request):
|
||||||
"""
|
"""
|
||||||
Parses the incoming request and returns a :class:`butterrobot.objects.Message` instance.
|
Parses the incoming request and returns a :class:`butterrobot.objects.Message` instance.
|
||||||
"""
|
"""
|
||||||
|
@ -52,7 +52,7 @@ class Platform:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def parse_channel_from_message(cls, channel_raw) -> 'Channel':
|
def parse_channel_from_message(cls, channel_raw):
|
||||||
"""
|
"""
|
||||||
Extracts the Channel raw data from the message received in the incoming webhook.
|
Extracts the Channel raw data from the message received in the incoming webhook.
|
||||||
"""
|
"""
|
||||||
|
@ -62,6 +62,6 @@ class Platform:
|
||||||
class PlatformMethods:
|
class PlatformMethods:
|
||||||
@classmethod
|
@classmethod
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def send_message(cls, message: 'Message'):
|
def send_message(cls, message):
|
||||||
"""Method used to send a message via the platform"""
|
"""Method used to send a message via the platform"""
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -7,9 +7,11 @@ def test_channel_has_enabled_plugin_ok():
|
||||||
platform_channel_id="debug",
|
platform_channel_id="debug",
|
||||||
channel_raw={},
|
channel_raw={},
|
||||||
plugins={
|
plugins={
|
||||||
"enabled": ChannelPlugin(id=1, channel_id="test", plugin_id="enabled", enabled=True),
|
"enabled": ChannelPlugin(
|
||||||
|
id=1, channel_id="test", plugin_id="enabled", enabled=True
|
||||||
|
),
|
||||||
"existant": ChannelPlugin(id=2, channel_id="test", plugin_id="existant"),
|
"existant": ChannelPlugin(id=2, channel_id="test", plugin_id="existant"),
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
assert not channel.has_enabled_plugin("non.existant")
|
assert not channel.has_enabled_plugin("non.existant")
|
||||||
assert not channel.has_enabled_plugin("existant")
|
assert not channel.has_enabled_plugin("existant")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue