File: text_test.py

package info (click to toggle)
errbot 6.2.0%2Bds-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,856 kB
  • sloc: python: 11,572; makefile: 163; sh: 97
file content (37 lines) | stat: -rw-r--r-- 1,047 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import logging
import os
import sys
from tempfile import mkdtemp

import pytest

from errbot.backends.text import TextBackend
from errbot.bootstrap import bot_config_defaults


@pytest.fixture
def text_backend():
    tempdir = mkdtemp()

    # reset the config every time
    sys.modules.pop("errbot.config-template", None)
    __import__("errbot.config-template")
    config = sys.modules["errbot.config-template"]
    bot_config_defaults(config)
    config.BOT_DATA_DIR = tempdir
    config.BOT_LOG_FILE = os.path.join(tempdir, "log.txt")
    config.BOT_EXTRA_PLUGIN_DIR = []
    config.BOT_LOG_LEVEL = logging.DEBUG
    config.BOT_PREFIX = "!"
    config.BOT_IDENTITY["username"] = "@testme"
    config.BOT_ADMINS = ["@test_admin"]

    return TextBackend(config)


def test_change_presence(text_backend, caplog):
    with caplog.at_level(logging.DEBUG):
        text_backend.change_presence("online", "I'm online")
    assert len(caplog.messages) == 1
    a_message = caplog.messages[0]
    assert a_message.startswith("*** Changed presence")