2020-08-26 09:45:03 +02:00
|
|
|
from .module_tester import ModuleTester
|
|
|
|
from frank import Default, Daemon, Command
|
|
|
|
from frank.module.exceptions import InvalidCommand
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
def test_property_types():
|
2020-08-26 12:22:18 +02:00
|
|
|
"""
|
|
|
|
Test wether the cached_property's return the expected value
|
|
|
|
"""
|
|
|
|
|
2020-08-26 09:45:03 +02:00
|
|
|
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
|
|
|
|
))
|
|
|
|
|
2020-08-26 12:22:18 +02:00
|
|
|
assert isinstance(test_mod.daemons, list)
|
2020-08-26 09:45:03 +02:00
|
|
|
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)
|
2020-08-26 12:22:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_match():
|
|
|
|
test_mod = ModuleTester(None)
|
|
|
|
|
|
|
|
assert test_mod.match('tester')
|
|
|
|
assert not test_mod.match('testerrr')
|