# Path: django_make_app/runner.py
# @click.group()
# def cli():
#     pass
# 
# YAML_FILENAME = u"app_schema.yaml"


import io
import os
import click
from unittest import TestCase
from click.testing import CliRunner
from django_make_app.runner import cli, YAML_FILENAME


class RunnerTestCase(TestCase):
    OK_CODE = 0
    CATCHALL_FOR_GENERAL_ERRORS_CODE = 1
    MISUSE_OF_SHELL_BUILTING_CODE = 2

    @staticmethod
    def _get_example_schema():
        templates_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "django_make_app", u"templates", u"example.yaml")

        with io.open(templates_dir, mode='r', encoding='utf-8') as the_file:
            content = the_file.read()

        return content

    def test_write_config(self):
        runner = CliRunner()

        write_only_help = runner.invoke(cli, ['write_config', '--help'])
        self.assertEqual(self.OK_CODE, write_only_help.exit_code)
        self.assertIn(u"write_config [OPTIONS]", write_only_help.output)

        write_real = runner.invoke(cli, ['write_config'])
        self.assertEqual(self.OK_CODE, write_real.exit_code)

        example_schema = self._get_example_schema()
        self.assertEqual(example_schema + "\n", write_real.output)

    def test_generate(self):

# Path: django_make_app/runner.py
# @click.group()
# def cli():
#     pass
# 
# YAML_FILENAME = u"app_schema.yaml"


# Path: tests/test_runner.py
import io
import os
import click
from unittest import TestCase
from click.testing import CliRunner
from django_make_app.runner import cli, YAML_FILENAME



class RunnerTestCase(TestCase):
    OK_CODE = 0
    CATCHALL_FOR_GENERAL_ERRORS_CODE = 1
    MISUSE_OF_SHELL_BUILTING_CODE = 2

    @staticmethod
    def _get_example_schema():
        templates_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "django_make_app", u"templates", u"example.yaml")

        with io.open(templates_dir, mode='r', encoding='utf-8') as the_file:
            content = the_file.read()

        return content

    def test_write_config(self):
        runner = CliRunner()

        write_only_help = runner.invoke(cli, ['write_config', '--help'])
        self.assertEqual(self.OK_CODE, write_only_help.exit_code)
        self.assertIn(u"write_config [OPTIONS]", write_only_help.output)

        write_real = runner.invoke(cli, ['write_config'])
        self.assertEqual(self.OK_CODE, write_real.exit_code)

        example_schema = self._get_example_schema()
        self.assertEqual(example_schema + "\n", write_real.output)

    def test_generate(self):

        runner = CliRunner()