How to use the errbot.backends.test.TestOccupant function in errbot

To help you get started, we’ve selected a few errbot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github errbotio / errbot / tests / base_backend_tests.py View on Github external
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
github errbotio / errbot / tests / base_backend_tests.py View on Github external
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': ('*',)}},
github errbotio / errbot / tests / simple_identifiers_tests.py View on Github external
def test_mucidentifier_eq():
    a = TestOccupant("foo", "room")
    b = TestOccupant("foo", "room")
    assert a == b
github errbotio / errbot / tests / muc_tests.py View on Github external
def test_occupants(testbot):  # noqa
    room = testbot.bot.rooms()[0]
    assert len(room.occupants) == 1
    assert TestOccupant('err', 'testroom') in room.occupants
github errbotio / errbot / tests / base_backend_tests.py View on Github external
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
github errbotio / errbot / tests / simple_identifiers_tests.py View on Github external
def test_mucidentifier_ineq2():
    a = TestOccupant("foo", "room1")
    b = TestOccupant("foo", "room2")
    assert not a == b
    assert a != b
github errbotio / errbot / tests / base_backend_tests.py View on Github external
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',)}},
github errbotio / errbot / tests / simple_identifiers_tests.py View on Github external
def test_mucidentifier_ineq1():
    a = TestOccupant("foo", "room")
    b = TestOccupant("bar", "room")
    assert not a == b
    assert a != b
github errbotio / errbot / tests / simple_identifiers_tests.py View on Github external
def test_mucidentifier_ineq1():
    a = TestOccupant("foo", "room")
    b = TestOccupant("bar", "room")
    assert not a == b
    assert a != b
github errbotio / errbot / tests / simple_identifiers_tests.py View on Github external
def test_mucidentifier_eq():
    a = TestOccupant("foo", "room")
    b = TestOccupant("foo", "room")
    assert a == b