# Path: tests/isolated_testcase.py
# class IsolatedTestCase(FullStackTest):
# 
#     file_path = Path(__file__).parent / '..' / 'plugins' / 'labhub.plug'
#     renamed_file_path = Path(__file__).parent / '..' / 'plugins' / 'hidden'
# 
#     @classmethod
#     def setUpClass(cls, extra_config=None):
#         os.rename(cls.file_path, cls.renamed_file_path)
# 
#     @classmethod
#     def tearDownClass(cls):
#         os.rename(cls.renamed_file_path, cls.file_path)
# 
#     def setUp(self, extra_config=None):
#         super().setUp(extra_plugin_dir='plugins',
#                       loglevel=logging.ERROR,
#                       extra_config=extra_config)
# 
# Path: plugins/explain.py
# class Explain(BotPlugin):
#     """
#     Explain various terms
#     """
# 
#     files = glob.glob('plugins/templates/explain/*.jinja2.md')
#     KNOWN_KEYS = []
#     for fname in files:
#         KNOWN_KEYS.append(fname.replace(
#             'plugins/templates/explain/', ''
#         ).replace('.jinja2.md', ''))
# 
#     ERROR_MSG = (
#         'Sorry, I only know about these things:\n- ' +
#         '\n- '.join(KNOWN_KEYS)
#     )
# 
#     @re_botcmd(pattern=r'^explain\s+(\w+)(?:\s+to\s+@?([\w-]+))?$',
#                re_cmd_name_help='explain <term>',
#                flags=re.IGNORECASE)
#     def explain(self, msg, match):
#         """Explain various terms."""  # Ignore QuotesBear
#         user = msg.frm.nick
#         response = ''
#         filename = 'explain/{}.jinja2.md'.format(match.group(1).lower())
#         if match.group(1).lower() in self.KNOWN_KEYS:
#             if match.group(2):
#                 response += '@{}: \n'.format(match.group(2))
#             response += tenv().get_template(filename).render(
#                 username=user,
#                 target=match.group(2),
#                 bot_prefix=self.bot_config.BOT_PREFIX,
#             )
#         else:
#             response = self.ERROR_MSG
# 
#         return response


import errbot.rendering
from tests.isolated_testcase import IsolatedTestCase
from plugins.explain import Explain



text = errbot.rendering.text()


class ExplainTest(IsolatedTestCase):

    def test_explain(self):
        self.assertCommand('!explain REView', 'For a good review,')
        self.assertCommand('!explain gOOgle', 'use google')

# Path: tests/isolated_testcase.py
# class IsolatedTestCase(FullStackTest):
# 
#     file_path = Path(__file__).parent / '..' / 'plugins' / 'labhub.plug'
#     renamed_file_path = Path(__file__).parent / '..' / 'plugins' / 'hidden'
# 
#     @classmethod
#     def setUpClass(cls, extra_config=None):
#         os.rename(cls.file_path, cls.renamed_file_path)
# 
#     @classmethod
#     def tearDownClass(cls):
#         os.rename(cls.renamed_file_path, cls.file_path)
# 
#     def setUp(self, extra_config=None):
#         super().setUp(extra_plugin_dir='plugins',
#                       loglevel=logging.ERROR,
#                       extra_config=extra_config)
# 
# Path: plugins/explain.py
# class Explain(BotPlugin):
#     """
#     Explain various terms
#     """
# 
#     files = glob.glob('plugins/templates/explain/*.jinja2.md')
#     KNOWN_KEYS = []
#     for fname in files:
#         KNOWN_KEYS.append(fname.replace(
#             'plugins/templates/explain/', ''
#         ).replace('.jinja2.md', ''))
# 
#     ERROR_MSG = (
#         'Sorry, I only know about these things:\n- ' +
#         '\n- '.join(KNOWN_KEYS)
#     )
# 
#     @re_botcmd(pattern=r'^explain\s+(\w+)(?:\s+to\s+@?([\w-]+))?$',
#                re_cmd_name_help='explain <term>',
#                flags=re.IGNORECASE)
#     def explain(self, msg, match):
#         """Explain various terms."""  # Ignore QuotesBear
#         user = msg.frm.nick
#         response = ''
#         filename = 'explain/{}.jinja2.md'.format(match.group(1).lower())
#         if match.group(1).lower() in self.KNOWN_KEYS:
#             if match.group(2):
#                 response += '@{}: \n'.format(match.group(2))
#             response += tenv().get_template(filename).render(
#                 username=user,
#                 target=match.group(2),
#                 bot_prefix=self.bot_config.BOT_PREFIX,
#             )
#         else:
#             response = self.ERROR_MSG
# 
#         return response


# Path: tests/explain_test.py
import errbot.rendering
from tests.isolated_testcase import IsolatedTestCase
from plugins.explain import Explain




text = errbot.rendering.text()


class ExplainTest(IsolatedTestCase):

    def test_explain(self):
        self.assertCommand('!explain REView', 'For a good review,')
        self.assertCommand('!explain gOOgle', 'use google')

        self.assertCommand('!explain not_found',