This repository has been archived on 2021-03-28. You can view files and clone it, but cannot push or open issues/pull-requests.
2020-08-27 09:41:03 +02:00
|
|
|
# =====IMPORTS=====
|
2020-08-27 13:06:22 +02:00
|
|
|
# Third-party imports
|
|
|
|
import pytest
|
|
|
|
|
2020-08-27 09:41:03 +02:00
|
|
|
# Own imports
|
|
|
|
from frank import default, command, daemon
|
|
|
|
|
|
|
|
|
|
|
|
class TestDecorators:
|
|
|
|
"""
|
|
|
|
This test makes sure the decorated functions return the same result as
|
|
|
|
their non-decorated counterparts
|
|
|
|
"""
|
|
|
|
|
|
|
|
def default_no_dec(self):
|
|
|
|
return 'default'
|
|
|
|
|
|
|
|
@default()
|
|
|
|
def default_dec(self):
|
|
|
|
return self.default_no_dec()
|
|
|
|
|
|
|
|
def command_no_dec(self):
|
|
|
|
return 'command'
|
|
|
|
|
|
|
|
@command('cmd')
|
|
|
|
def command_dec(self):
|
|
|
|
return self.command_no_dec()
|
|
|
|
|
|
|
|
def daemon_no_dec(self):
|
|
|
|
return 'daemon'
|
|
|
|
|
|
|
|
@daemon()
|
2020-08-27 13:06:22 +02:00
|
|
|
async def daemon_dec(self):
|
2020-08-27 09:41:03 +02:00
|
|
|
return self.daemon_no_dec()
|
|
|
|
|
|
|
|
def test_default(self):
|
|
|
|
assert self.default_no_dec() == self.default_dec()
|
|
|
|
|
|
|
|
def test_command(self):
|
|
|
|
assert self.command_no_dec() == self.command_dec()
|
|
|
|
|
2020-08-27 13:06:22 +02:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
async def test_daemon(self):
|
|
|
|
assert self.daemon_no_dec() == await self.daemon_dec()
|