Added first module unit tests; started changelog
This commit is contained in:
parent
cccdd667fb
commit
0801762f07
8 changed files with 54 additions and 47 deletions
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
11
tests/module_tester.py
Normal file
11
tests/module_tester.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from frank import Module, command, default
|
||||
|
||||
|
||||
class ModuleTester(Module):
|
||||
@command('test')
|
||||
async def test(cmd, author, channel, mid):
|
||||
pass
|
||||
|
||||
@default()
|
||||
async def test2(prefix, cmd, author, channel, mid):
|
||||
pass
|
||||
30
tests/test_module.py
Normal file
30
tests/test_module.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from .module_tester import ModuleTester
|
||||
from frank import Default, Daemon, Command
|
||||
from frank.module.exceptions import InvalidCommand
|
||||
import pytest
|
||||
|
||||
|
||||
def test_property_types():
|
||||
test_mod = ModuleTester(None)
|
||||
|
||||
assert isinstance(test_mod.default, Default)
|
||||
assert hasattr(test_mod.default, 'help_str')
|
||||
|
||||
assert isinstance(test_mod.commands, list)
|
||||
assert all((
|
||||
isinstance(item, Command) for item in test_mod.commands
|
||||
))
|
||||
|
||||
assert isinstance(test_mod.commands, list)
|
||||
assert all((
|
||||
isinstance(item, Daemon) for item in test_mod.daemons
|
||||
))
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_invalid_command():
|
||||
test_mod = ModuleTester(None)
|
||||
|
||||
with pytest.raises(InvalidCommand):
|
||||
# None is just a placeholder here
|
||||
await test_mod('aninvalidcommand', None, None, None)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
def test_success():
|
||||
pass
|
||||
Reference in a new issue