# 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)


import vcr
import requests_mock
from tests.isolated_testcase import IsolatedTestCase


class TestAnswer(IsolatedTestCase):

    def setUp(self):
        # Ignore InvalidLinkBear
        self.answer_end_point = 'http://0.0.0.0:8000'
        extra_config = {
            'DEFAULT_CONFIG': {
                'answer': {
                    'ANSWER_END': self.answer_end_point,
                }
            }
        }
        super().setUp(extra_config=extra_config)

    @vcr.use_cassette('tests/cassettes/answer.yaml')
    def test_answer(self):
        self.assertCommand('!answer something', 'Dunno')
        self.push_message('!answer getting started with coala')
        self.assertIn('Please checkout the following links', self.pop_message())
        self.push_message('!answer shell autocompletion')
        self.assertIn('Please checkout the following links', self.pop_message())
        self.assertCommand('!plugin config answer',
                           str({'ANSWER_END': self.answer_end_point}))

    def test_invalid_json(self):
        with requests_mock.Mocker() as m:
            m.get('{}/answer?question=foo'.format(self.answer_end_point),
                  text='invalid')

# 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: tests/answer_test.py
import vcr
import requests_mock
from tests.isolated_testcase import IsolatedTestCase



class TestAnswer(IsolatedTestCase):

    def setUp(self):
        # Ignore InvalidLinkBear
        self.answer_end_point = 'http://0.0.0.0:8000'
        extra_config = {
            'DEFAULT_CONFIG': {
                'answer': {
                    'ANSWER_END': self.answer_end_point,
                }
            }
        }
        super().setUp(extra_config=extra_config)

    @vcr.use_cassette('tests/cassettes/answer.yaml')
    def test_answer(self):
        self.assertCommand('!answer something', 'Dunno')
        self.push_message('!answer getting started with coala')
        self.assertIn('Please checkout the following links', self.pop_message())
        self.push_message('!answer shell autocompletion')
        self.assertIn('Please checkout the following links', self.pop_message())
        self.assertCommand('!plugin config answer',
                           str({'ANSWER_END': self.answer_end_point}))

    def test_invalid_json(self):
        with requests_mock.Mocker() as m:
            m.get('{}/answer?question=foo'.format(self.answer_end_point),
                  text='invalid')

            self.assertCommand(