Added example mod to README
This commit is contained in:
parent
0801762f07
commit
78290554bd
5 changed files with 96 additions and 4 deletions
|
|
@ -1,7 +1,9 @@
|
|||
from frank import Module, command, default
|
||||
from frank import Module, command, default, daemon
|
||||
|
||||
|
||||
class ModuleTester(Module):
|
||||
PREFIX = 'tester'
|
||||
|
||||
@command('test')
|
||||
async def test(cmd, author, channel, mid):
|
||||
pass
|
||||
|
|
@ -9,3 +11,7 @@ class ModuleTester(Module):
|
|||
@default()
|
||||
async def test2(prefix, cmd, author, channel, mid):
|
||||
pass
|
||||
|
||||
@daemon()
|
||||
async def test_daemon(self):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ import pytest
|
|||
|
||||
|
||||
def test_property_types():
|
||||
"""
|
||||
Test wether the cached_property's return the expected value
|
||||
"""
|
||||
|
||||
test_mod = ModuleTester(None)
|
||||
|
||||
assert isinstance(test_mod.default, Default)
|
||||
|
|
@ -15,7 +19,7 @@ def test_property_types():
|
|||
isinstance(item, Command) for item in test_mod.commands
|
||||
))
|
||||
|
||||
assert isinstance(test_mod.commands, list)
|
||||
assert isinstance(test_mod.daemons, list)
|
||||
assert all((
|
||||
isinstance(item, Daemon) for item in test_mod.daemons
|
||||
))
|
||||
|
|
@ -28,3 +32,10 @@ async def test_invalid_command():
|
|||
with pytest.raises(InvalidCommand):
|
||||
# None is just a placeholder here
|
||||
await test_mod('aninvalidcommand', None, None, None)
|
||||
|
||||
|
||||
def test_match():
|
||||
test_mod = ModuleTester(None)
|
||||
|
||||
assert test_mod.match('tester')
|
||||
assert not test_mod.match('testerrr')
|
||||
|
|
|
|||
Reference in a new issue