# Path: grazyna/db.py
# def get_session(engine):
#     return sessionmaker(
#         bind=engine,
#         class_=Session,
#         expire_on_commit=False
#     )()
# 
# Path: grazyna/irc/sender.py
# class IrcSender(object):
#     transport = None
#     whois_heap = None
# 
#     def __init__(self):
#         self.whois_heap = {}
# 
#     def send(self, *args):
#         string = ' '.join(
#             str(arg).replace('\r', '').replace('\n', '')
#             for arg in args
#         )[:510] + '\r\n'
#         self.transport.write(string.encode())
# 
#     def send_msg(self, *args):
#         """add ':' to last argument"""
#         new_args = list(args)
#         new_args[-1] = ':' + str(new_args[-1])
#         self.send(*new_args)
# 
#     def say(self, nick_chan, msg):
#         self.send_msg('PRIVMSG', nick_chan, msg)
# 
#     def notice(self, nick, msg):
#         self.send_msg('NOTICE', nick, msg)
# 
#     def reply(self, nick, msg, chan=None):
#         msg = msg if not chan else '%s: %s' % (nick, msg)
#         self.say(chan or nick, msg)
# 
#     def kick(self, nick, chan, why=''):
#         self.send_msg('KICK', chan, nick, why or nick)
# 
#     def mode(self, chan, flag, arg):
#         self.send('MODE', chan, flag, arg)
# 
#     @asyncio.coroutine
#     def whois(self, nick):
#         """
# 
#         :type nick: str
#         :return: WhoisData
#         """
#         self.whois_heap[nick] = future = WhoisFuture()
#         self.send('WHOIS', nick)
#         result = yield from future
#         return result
# 
#     def time_ban(self, time, nick, chan, why='', prefix=None):
#         """
# 
#         :type time: int
#         :type nick: str
#         :type chan: str
#         :type why: str
#         :type prefix: str or NoneType
#         """
# 
#         if time <= 0:
#             return
# 
#         prefix = prefix or nick + '!*@*'
#         self.mode(chan, '+b', prefix)
#         self.kick(nick, chan, why)
# 
#         @asyncio.coroutine
#         def timer():
#             yield from asyncio.sleep(time)
#             self.mode(chan, '-b', prefix)
# 
#         asyncio.async(timer())
# 
# Path: grazyna/config.py
# def create_empty_config():
#     return MyConfigParser(
#         comment_prefixes=[';', '//'],
#         dict_type=dict,
#     )
# 
# Path: grazyna/test_mocks/importer.py
# class Importer(object):
#     protocol = None
#     is_loaded = False
#     is_canceled = True
#     whois_heap = {}
# 
#     def __init__(self, protocol):
#         self.protocol = protocol
#         self.execute = AsyncMock()
#         self.load = Mock()
#         self.reload = Mock()
#         self.remove = Mock()
# 
#     def load_all(self):
#         self.is_loaded = True
# 
#     def cancel_tasks(self):
#         self.is_canceled = True


from grazyna.db import get_session
from grazyna.irc.sender import IrcSender as DefaultIrcSender
from grazyna.config import create_empty_config
from grazyna.test_mocks.importer import Importer
from unittest.mock import Mock
from asyncio import BaseTransport
    messages = None
    config = None
    db = None
    transport = None
    ping_counter = 0

    def __init__(self):
        super().__init__()
        self.messages = []
        self.config = config = create_empty_config()
        self.transport = Mock(spec=BaseTransport)
        self.importer = Importer(self)
        config.read_dict(dict(
            main={
                'nick': 'bot',
                'importer': 'grazyna.test_mocks.importer.Importer',
                'command-prefix': '.',
                'time_to_block': '30',
                'executed_commands_per_time': '20',
                'db_uri': 'sqlite://',
            },
            auth=dict(
                module='grazyna.auths.NonAuth',
            )
        ))

    def send(self, *args):
        self.messages.append(Message(*args))

    def get_session(self):

# Path: grazyna/db.py
# def get_session(engine):
#     return sessionmaker(
#         bind=engine,
#         class_=Session,
#         expire_on_commit=False
#     )()
# 
# Path: grazyna/irc/sender.py
# class IrcSender(object):
#     transport = None
#     whois_heap = None
# 
#     def __init__(self):
#         self.whois_heap = {}
# 
#     def send(self, *args):
#         string = ' '.join(
#             str(arg).replace('\r', '').replace('\n', '')
#             for arg in args
#         )[:510] + '\r\n'
#         self.transport.write(string.encode())
# 
#     def send_msg(self, *args):
#         """add ':' to last argument"""
#         new_args = list(args)
#         new_args[-1] = ':' + str(new_args[-1])
#         self.send(*new_args)
# 
#     def say(self, nick_chan, msg):
#         self.send_msg('PRIVMSG', nick_chan, msg)
# 
#     def notice(self, nick, msg):
#         self.send_msg('NOTICE', nick, msg)
# 
#     def reply(self, nick, msg, chan=None):
#         msg = msg if not chan else '%s: %s' % (nick, msg)
#         self.say(chan or nick, msg)
# 
#     def kick(self, nick, chan, why=''):
#         self.send_msg('KICK', chan, nick, why or nick)
# 
#     def mode(self, chan, flag, arg):
#         self.send('MODE', chan, flag, arg)
# 
#     @asyncio.coroutine
#     def whois(self, nick):
#         """
# 
#         :type nick: str
#         :return: WhoisData
#         """
#         self.whois_heap[nick] = future = WhoisFuture()
#         self.send('WHOIS', nick)
#         result = yield from future
#         return result
# 
#     def time_ban(self, time, nick, chan, why='', prefix=None):
#         """
# 
#         :type time: int
#         :type nick: str
#         :type chan: str
#         :type why: str
#         :type prefix: str or NoneType
#         """
# 
#         if time <= 0:
#             return
# 
#         prefix = prefix or nick + '!*@*'
#         self.mode(chan, '+b', prefix)
#         self.kick(nick, chan, why)
# 
#         @asyncio.coroutine
#         def timer():
#             yield from asyncio.sleep(time)
#             self.mode(chan, '-b', prefix)
# 
#         asyncio.async(timer())
# 
# Path: grazyna/config.py
# def create_empty_config():
#     return MyConfigParser(
#         comment_prefixes=[';', '//'],
#         dict_type=dict,
#     )
# 
# Path: grazyna/test_mocks/importer.py
# class Importer(object):
#     protocol = None
#     is_loaded = False
#     is_canceled = True
#     whois_heap = {}
# 
#     def __init__(self, protocol):
#         self.protocol = protocol
#         self.execute = AsyncMock()
#         self.load = Mock()
#         self.reload = Mock()
#         self.remove = Mock()
# 
#     def load_all(self):
#         self.is_loaded = True
# 
#     def cancel_tasks(self):
#         self.is_canceled = True


# Path: grazyna/test_mocks/sender.py
from grazyna.db import get_session
from grazyna.irc.sender import IrcSender as DefaultIrcSender
from grazyna.config import create_empty_config
from grazyna.test_mocks.importer import Importer
from unittest.mock import Mock
from asyncio import BaseTransport

    messages = None
    config = None
    db = None
    transport = None
    ping_counter = 0

    def __init__(self):
        super().__init__()
        self.messages = []
        self.config = config = create_empty_config()
        self.transport = Mock(spec=BaseTransport)
        self.importer = Importer(self)
        config.read_dict(dict(
            main={
                'nick': 'bot',
                'importer': 'grazyna.test_mocks.importer.Importer',
                'command-prefix': '.',
                'time_to_block': '30',
                'executed_commands_per_time': '20',
                'db_uri': 'sqlite://',
            },
            auth=dict(
                module='grazyna.auths.NonAuth',
            )
        ))

    def send(self, *args):
        self.messages.append(Message(*args))

    def get_session(self):

        return get_session(self.db).scope()