# Path: cum/config.py
# class BaseConfig(object):
# class MadokamiConfig(object):
#     def __init__(self):
#     def __setattr__(self, name, value):
#     def default_download_directory(self):
#     def load(self):
#     def serialize(self):
#     def write(self):
#     def __init__(self, config, dict):
#     def login(self):
# def get():
# def initialize(directory=None):
# 
# Path: cum/cum.py
# class CumGroup(click.Group):
#     def command(self, check_db=True, *args, **kwargs):
#         def decorator(f):
#             def wrapper(*args, **kwargs):
# def edit_defaults():
# def cli(cum_directory=None):
# def chapters(alias):
# def config_command(mode, setting, value):
# def download(aliases):
# def edit(alias, setting, value):
# def follow(urls, directory, download, ignore):
# def follows():
# def get(input, directory):
# def ignore(alias, chapters):
# def latest(alias, relative):
# def new():
# def open(alias):
# def repair_db():
# def unfollow(alias):
# def unignore(alias, chapters):
# def update(fast):


from click.testing import CliRunner
from cum import config, cum
from shutil import copyfile
        from cum import db, scrapers
import os
import tempfile
import unittest
class CumTest(unittest.TestCase):
    """Base class for all cum test cases."""
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.madokami_password = os.environ.get('MADOKAMI_PASSWORD', None)
        self.madokami_username = os.environ.get('MADOKAMI_USERNAME', None)

    def copy_broken_config(self):
        """Copies a pre-defined broken configuration file into the current
        directory.
        """
        test_directory = os.path.dirname(os.path.realpath(__file__))
        broken_config_path = os.path.join(test_directory, 'broken_config.json')
        target_config_path = os.path.join(self.directory.name, 'config.json')
        copyfile(broken_config_path, target_config_path)

    def copy_broken_database(self):
        """Copies a pre-defined broken database into the current directory."""
        test_directory = os.path.dirname(os.path.realpath(__file__))
        broken_db_path = os.path.join(test_directory, 'broken_database.db')
        target_db_path = os.path.join(self.directory.name, 'cum.db')
        copyfile(broken_db_path, target_db_path)

    @property
    def no_madokami_login(self):
        return not (self.madokami_username and self.madokami_password)

    def setUp(self):
        self.directory = tempfile.TemporaryDirectory()
        config.initialize(self.directory.name)

# Path: cum/config.py
# class BaseConfig(object):
# class MadokamiConfig(object):
#     def __init__(self):
#     def __setattr__(self, name, value):
#     def default_download_directory(self):
#     def load(self):
#     def serialize(self):
#     def write(self):
#     def __init__(self, config, dict):
#     def login(self):
# def get():
# def initialize(directory=None):
# 
# Path: cum/cum.py
# class CumGroup(click.Group):
#     def command(self, check_db=True, *args, **kwargs):
#         def decorator(f):
#             def wrapper(*args, **kwargs):
# def edit_defaults():
# def cli(cum_directory=None):
# def chapters(alias):
# def config_command(mode, setting, value):
# def download(aliases):
# def edit(alias, setting, value):
# def follow(urls, directory, download, ignore):
# def follows():
# def get(input, directory):
# def ignore(alias, chapters):
# def latest(alias, relative):
# def new():
# def open(alias):
# def repair_db():
# def unfollow(alias):
# def unignore(alias, chapters):
# def update(fast):


# Path: tests/cumtest.py
from click.testing import CliRunner
from cum import config, cum
from shutil import copyfile
        from cum import db, scrapers
import os
import tempfile
import unittest

class CumTest(unittest.TestCase):
    """Base class for all cum test cases."""
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.madokami_password = os.environ.get('MADOKAMI_PASSWORD', None)
        self.madokami_username = os.environ.get('MADOKAMI_USERNAME', None)

    def copy_broken_config(self):
        """Copies a pre-defined broken configuration file into the current
        directory.
        """
        test_directory = os.path.dirname(os.path.realpath(__file__))
        broken_config_path = os.path.join(test_directory, 'broken_config.json')
        target_config_path = os.path.join(self.directory.name, 'config.json')
        copyfile(broken_config_path, target_config_path)

    def copy_broken_database(self):
        """Copies a pre-defined broken database into the current directory."""
        test_directory = os.path.dirname(os.path.realpath(__file__))
        broken_db_path = os.path.join(test_directory, 'broken_database.db')
        target_db_path = os.path.join(self.directory.name, 'cum.db')
        copyfile(broken_db_path, target_db_path)

    @property
    def no_madokami_login(self):
        return not (self.madokami_username and self.madokami_password)

    def setUp(self):
        self.directory = tempfile.TemporaryDirectory()
        config.initialize(self.directory.name)

        config.get().download_directory = self.directory.name