# 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/exceptions.py
# class CumException(Exception):
# class LoginError(CumException):
# class ScrapingError(CumException):
# class ConfigError(CumException):
#     def __init__(self, message=''):
#     def __str__(self):
#     def __init__(self, config, cursor, message=''):


from cum import config
from cum import exceptions
import cumtest


class TestCLIConfig(cumtest.CumCLITest):
    def test_config_corrupt(self):
        self.copy_broken_config()
        with self.assertRaises(exceptions.ConfigError):
            config.initialize(self.directory.name)

    def test_config_corrupt_output(self):
        MESSAGES = ['10:   "download_directory": "invalid",',
                    '11:   "madokami": {',
                    '12:     "password": "invalid",',
                    '13:     "username": "invalid"',
                    '14:     I am so broken',
                    '        ^',
                    '==> Error reading config: Expecting \',\' delimiter']

        self.copy_broken_config()
        result = self.invoke('config', 'initialise', self.directory.name)
        self.assertEqual(result.exit_code, 1)
        for message in MESSAGES:
            self.assertIn(message, result.output)

    @cumtest.skipIfNoMadokamiLogin
    def test_config_get(self):

# 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/exceptions.py
# class CumException(Exception):
# class LoginError(CumException):
# class ScrapingError(CumException):
# class ConfigError(CumException):
#     def __init__(self, message=''):
#     def __str__(self):
#     def __init__(self, config, cursor, message=''):


# Path: tests/test_cli_config.py
from cum import config
from cum import exceptions
import cumtest



class TestCLIConfig(cumtest.CumCLITest):
    def test_config_corrupt(self):
        self.copy_broken_config()
        with self.assertRaises(exceptions.ConfigError):
            config.initialize(self.directory.name)

    def test_config_corrupt_output(self):
        MESSAGES = ['10:   "download_directory": "invalid",',
                    '11:   "madokami": {',
                    '12:     "password": "invalid",',
                    '13:     "username": "invalid"',
                    '14:     I am so broken',
                    '        ^',
                    '==> Error reading config: Expecting \',\' delimiter']

        self.copy_broken_config()
        result = self.invoke('config', 'initialise', self.directory.name)
        self.assertEqual(result.exit_code, 1)
        for message in MESSAGES:
            self.assertIn(message, result.output)

    @cumtest.skipIfNoMadokamiLogin
    def test_config_get(self):

        MESSAGES = ['download_directory = ' + config.get().download_directory,