Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions test/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ def test_clean_callable_default(tmpconfig, func):
assert not hasattr(func, 'rate')
assert not hasattr(func, 'channel_rate')
assert not hasattr(func, 'global_rate')
assert not hasattr(func, 'echo')
assert not hasattr(func, 'allow_bots')
assert not hasattr(func, 'output_prefix')
assert not hasattr(func, 'event')
assert not hasattr(func, 'rule')
assert not hasattr(func, 'find_rules')
Expand All @@ -321,6 +324,9 @@ def test_clean_callable_command(tmpconfig, func):
setattr(func, 'commands', ['test'])
loader.clean_callable(func, tmpconfig)

assert hasattr(func, 'commands')
assert func.commands == ['test']

# Default values
assert hasattr(func, 'unblockable')
assert func.unblockable is False
Expand All @@ -334,10 +340,31 @@ def test_clean_callable_command(tmpconfig, func):
assert func.channel_rate == 0
assert hasattr(func, 'global_rate')
assert func.global_rate == 0
assert hasattr(func, 'echo')
assert func.echo is False
assert hasattr(func, 'allow_bots')
assert func.allow_bots is False
assert hasattr(func, 'output_prefix')
assert func.output_prefix == ''
assert hasattr(func, 'event')
assert func.event == ['PRIVMSG']
assert not hasattr(func, 'rule')

# idempotency
loader.clean_callable(func, tmpconfig)
assert func.commands == ['test']

assert func.unblockable is False
assert func.priority == 'medium'
assert func.thread is True
assert func.rate == 0
assert func.channel_rate == 0
assert func.global_rate == 0
assert func.echo is False
assert func.allow_bots is False
assert func.output_prefix == ''
assert func.event == ['PRIVMSG']


def test_clean_callable_event(tmpconfig, func):
setattr(func, 'event', ['low', 'UP', 'MiXeD'])
Expand All @@ -359,6 +386,12 @@ def test_clean_callable_event(tmpconfig, func):
assert func.channel_rate == 0
assert hasattr(func, 'global_rate')
assert func.global_rate == 0
assert hasattr(func, 'echo')
assert func.echo is False
assert hasattr(func, 'allow_bots')
assert func.allow_bots is False
assert hasattr(func, 'output_prefix')
assert func.output_prefix == ''

# idempotency
loader.clean_callable(func, tmpconfig)
Expand All @@ -370,6 +403,9 @@ def test_clean_callable_event(tmpconfig, func):
assert func.rate == 0
assert func.channel_rate == 0
assert func.global_rate == 0
assert func.echo is False
assert func.allow_bots is False
assert func.output_prefix == ''


def test_clean_callable_rule(tmpconfig, func):
Expand Down Expand Up @@ -398,6 +434,12 @@ def test_clean_callable_rule(tmpconfig, func):
assert func.channel_rate == 0
assert hasattr(func, 'global_rate')
assert func.global_rate == 0
assert hasattr(func, 'echo')
assert func.echo is False
assert hasattr(func, 'allow_bots')
assert func.allow_bots is False
assert hasattr(func, 'output_prefix')
assert func.output_prefix == ''

# idempotency
loader.clean_callable(func, tmpconfig)
Expand All @@ -411,6 +453,9 @@ def test_clean_callable_rule(tmpconfig, func):
assert func.rate == 0
assert func.channel_rate == 0
assert func.global_rate == 0
assert func.echo is False
assert func.allow_bots is False
assert func.output_prefix == ''


def test_clean_callable_rule_nick(tmpconfig, func):
Expand Down Expand Up @@ -474,6 +519,12 @@ def test_clean_callable_find_rules(tmpconfig, func):
assert func.channel_rate == 0
assert hasattr(func, 'global_rate')
assert func.global_rate == 0
assert hasattr(func, 'echo')
assert func.echo is False
assert hasattr(func, 'allow_bots')
assert func.allow_bots is False
assert hasattr(func, 'output_prefix')
assert func.output_prefix == ''

# idempotency
loader.clean_callable(func, tmpconfig)
Expand All @@ -489,6 +540,9 @@ def test_clean_callable_find_rules(tmpconfig, func):
assert func.rate == 0
assert func.channel_rate == 0
assert func.global_rate == 0
assert func.echo is False
assert func.allow_bots is False
assert func.output_prefix == ''


def test_clean_callable_search_rules(tmpconfig, func):
Expand Down Expand Up @@ -519,6 +573,12 @@ def test_clean_callable_search_rules(tmpconfig, func):
assert func.channel_rate == 0
assert hasattr(func, 'global_rate')
assert func.global_rate == 0
assert hasattr(func, 'echo')
assert func.echo is False
assert hasattr(func, 'allow_bots')
assert func.allow_bots is False
assert hasattr(func, 'output_prefix')
assert func.output_prefix == ''

# idempotency
loader.clean_callable(func, tmpconfig)
Expand All @@ -534,6 +594,9 @@ def test_clean_callable_search_rules(tmpconfig, func):
assert func.rate == 0
assert func.channel_rate == 0
assert func.global_rate == 0
assert func.echo is False
assert func.allow_bots is False
assert func.output_prefix == ''


def test_clean_callable_nickname_command(tmpconfig, func):
Expand All @@ -558,6 +621,12 @@ def test_clean_callable_nickname_command(tmpconfig, func):
assert func.channel_rate == 0
assert hasattr(func, 'global_rate')
assert func.global_rate == 0
assert hasattr(func, 'echo')
assert func.echo is False
assert hasattr(func, 'allow_bots')
assert func.allow_bots is False
assert hasattr(func, 'output_prefix')
assert func.output_prefix == ''

# idempotency
loader.clean_callable(func, tmpconfig)
Expand All @@ -568,6 +637,9 @@ def test_clean_callable_nickname_command(tmpconfig, func):
assert func.rate == 0
assert func.channel_rate == 0
assert func.global_rate == 0
assert func.echo is False
assert func.allow_bots is False
assert func.output_prefix == ''


def test_clean_callable_action_command(tmpconfig, func):
Expand Down Expand Up @@ -817,6 +889,12 @@ def test_clean_callable_intents(tmpconfig, func):
assert func.channel_rate == 0
assert hasattr(func, 'global_rate')
assert func.global_rate == 0
assert hasattr(func, 'echo')
assert func.echo is False
assert hasattr(func, 'allow_bots')
assert func.allow_bots is False
assert hasattr(func, 'output_prefix')
assert func.output_prefix == ''

# idempotency
loader.clean_callable(func, tmpconfig)
Expand All @@ -829,6 +907,9 @@ def test_clean_callable_intents(tmpconfig, func):
assert func.rate == 0
assert func.channel_rate == 0
assert func.global_rate == 0
assert func.echo is False
assert func.allow_bots is False
assert func.output_prefix == ''


def test_clean_callable_url(tmpconfig, func):
Expand All @@ -850,6 +931,12 @@ def test_clean_callable_url(tmpconfig, func):
assert func.channel_rate == 0
assert hasattr(func, 'global_rate')
assert func.global_rate == 0
assert hasattr(func, 'echo')
assert func.echo is False
assert hasattr(func, 'allow_bots')
assert func.allow_bots is False
assert hasattr(func, 'output_prefix')
assert func.output_prefix == ''

# idempotency
loader.clean_callable(func, tmpconfig)
Expand All @@ -859,3 +946,6 @@ def test_clean_callable_url(tmpconfig, func):
assert func.rate == 0
assert func.channel_rate == 0
assert func.global_rate == 0
assert func.echo is False
assert func.allow_bots is False
assert func.output_prefix == ''