Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dummy = DummyBackend({'BOT_PREFIX_OPTIONAL_ON_CHAT': True})
m = makemessage(dummy, "return_args_as_str one two")
dummy.callback_message(m)
assert "one two" == dummy.pop_message().body
# Groupchat should still require the prefix
m.frm = TestOccupant("someone", "room")
room = TestRoom("room", bot=dummy)
m.to = room
dummy.callback_message(m)
with pytest.raises(Empty):
dummy.pop_message(block=False)
m = makemessage(dummy, "!return_args_as_str one two",
from_=TestOccupant("someone", "room"),
to=room)
dummy.callback_message(m)
assert "one two" == dummy.pop_message().body
message=makemessage(dummy_backend, "!command",
from_=TestOccupant("someone", "room"),
to=TestRoom("room", bot=dummy_backend)),
acl={'command': {'allowrooms': ('room',)}},
expected_response="Regular command"
),
dict(
message=makemessage(dummy_backend, "!command",
from_=TestOccupant("someone", "room_1"),
to=TestRoom("room1", bot=dummy_backend)),
acl={'command': {'allowrooms': ('room_*',)}},
expected_response="Regular command"
),
dict(
message=makemessage(dummy_backend, "!command",
from_=TestOccupant("someone", "room"),
to=TestRoom("room", bot=dummy_backend)),
acl={'command': {'allowrooms': ('anotherroom@localhost',)}},
expected_response="You're not allowed to access this command from this room",
),
dict(
message=makemessage(dummy_backend, "!command",
from_=TestOccupant("someone", "room"),
to=TestRoom("room", bot=dummy_backend)),
acl={'command': {'denyrooms': ('room',)}},
expected_response="You're not allowed to access this command from this room",
),
dict(
message=makemessage(dummy_backend, "!command",
from_=TestOccupant("someone", "room"),
to=TestRoom("room", bot=dummy_backend)),
acl={'command': {'denyrooms': ('*',)}},
def test_mucidentifier_eq():
a = TestOccupant("foo", "room")
b = TestOccupant("foo", "room")
assert a == b
def test_occupants(testbot): # noqa
room = testbot.bot.rooms()[0]
assert len(room.occupants) == 1
assert TestOccupant('err', 'testroom') in room.occupants
def test_callback_message_with_prefix_optional():
dummy = DummyBackend({'BOT_PREFIX_OPTIONAL_ON_CHAT': True})
m = makemessage(dummy, "return_args_as_str one two")
dummy.callback_message(m)
assert "one two" == dummy.pop_message().body
# Groupchat should still require the prefix
m.frm = TestOccupant("someone", "room")
room = TestRoom("room", bot=dummy)
m.to = room
dummy.callback_message(m)
with pytest.raises(Empty):
dummy.pop_message(block=False)
m = makemessage(dummy, "!return_args_as_str one two",
from_=TestOccupant("someone", "room"),
to=room)
dummy.callback_message(m)
assert "one two" == dummy.pop_message().body
def test_mucidentifier_ineq2():
a = TestOccupant("foo", "room1")
b = TestOccupant("foo", "room2")
assert not a == b
assert a != b
dict(
message=makemessage(dummy_backend, "!command"),
acl={'command': {'allowprivate': True}},
acl_default={'allowmuc': False, 'allowprivate': False},
expected_response="Regular command"
),
dict(
message=makemessage(dummy_backend, "!command",
from_=TestOccupant("someone", "room"),
to=TestRoom("room", bot=dummy_backend)),
acl={'command': {'allowrooms': ('room',)}},
expected_response="Regular command"
),
dict(
message=makemessage(dummy_backend, "!command",
from_=TestOccupant("someone", "room_1"),
to=TestRoom("room1", bot=dummy_backend)),
acl={'command': {'allowrooms': ('room_*',)}},
expected_response="Regular command"
),
dict(
message=makemessage(dummy_backend, "!command",
from_=TestOccupant("someone", "room"),
to=TestRoom("room", bot=dummy_backend)),
acl={'command': {'allowrooms': ('anotherroom@localhost',)}},
expected_response="You're not allowed to access this command from this room",
),
dict(
message=makemessage(dummy_backend, "!command",
from_=TestOccupant("someone", "room"),
to=TestRoom("room", bot=dummy_backend)),
acl={'command': {'denyrooms': ('room',)}},
def test_mucidentifier_ineq1():
a = TestOccupant("foo", "room")
b = TestOccupant("bar", "room")
assert not a == b
assert a != b
def test_mucidentifier_ineq1():
a = TestOccupant("foo", "room")
b = TestOccupant("bar", "room")
assert not a == b
assert a != b
def test_mucidentifier_eq():
a = TestOccupant("foo", "room")
b = TestOccupant("foo", "room")
assert a == b