# Path: modules/utils/text.py
# def clean_text(text):
# 
# Path: modules/user_date.py
# async def main(bot, *args, **kwargs):
# 
# Path: modules/user_g.py
# def main(bot, *args, **kwargs):


import unittest
from unittest.mock import patch, MagicMock
from freezegun import freeze_time
from modules.utils import text
from modules import user_cowsay, user_date, user_g
# -*- coding: utf-8 -*-



class BaseModuleTestCase(unittest.TestCase):

    def setUp(self):
        self.bot = MagicMock()


class UserCowsayTestCase(BaseModuleTestCase):

    @patch('os.popen')
    def test_run_module_with_args_should_call_bot_send(self, popen):
        user_cowsay.main(self.bot, 'test', 'message')
        self.assertEqual(self.bot.send.call_count, 1)

    def test_run_module_without_args_should_return_none(self):
        user_cowsay.main(self.bot)
        self.assertEqual(self.bot.send.call_count, 0)


class UserDateTestCase(BaseModuleTestCase):

    @freeze_time('2015-12-14 12:13:14')
    def test_run_module_without_args_should_return_current_datetime(self):
        self.assertEqual(user_date.main(self.bot), '2015-12-14 12:13:14')

    def test_run_module_with_args_should_return_dating_text(self):

# Path: modules/utils/text.py
# def clean_text(text):
# 
# Path: modules/user_date.py
# async def main(bot, *args, **kwargs):
# 
# Path: modules/user_g.py
# def main(bot, *args, **kwargs):


# Path: tests/test_modules.py
import unittest
from unittest.mock import patch, MagicMock
from freezegun import freeze_time
from modules.utils import text
from modules import user_cowsay, user_date, user_g

# -*- coding: utf-8 -*-



class BaseModuleTestCase(unittest.TestCase):

    def setUp(self):
        self.bot = MagicMock()


class UserCowsayTestCase(BaseModuleTestCase):

    @patch('os.popen')
    def test_run_module_with_args_should_call_bot_send(self, popen):
        user_cowsay.main(self.bot, 'test', 'message')
        self.assertEqual(self.bot.send.call_count, 1)

    def test_run_module_without_args_should_return_none(self):
        user_cowsay.main(self.bot)
        self.assertEqual(self.bot.send.call_count, 0)


class UserDateTestCase(BaseModuleTestCase):

    @freeze_time('2015-12-14 12:13:14')
    def test_run_module_without_args_should_return_current_datetime(self):
        self.assertEqual(user_date.main(self.bot), '2015-12-14 12:13:14')

    def test_run_module_with_args_should_return_dating_text(self):

        self.assertEqual(user_date.main(self.bot, 'username'), 'обдумав свои чувства, пригласил на свидание username')