# Path: magnate/config.py
# STATE_DIR = os.path.expanduser('~/.stellarmagnate')
# USER_DIR = os.path.expanduser('~/.stellarmagnate')
# SYSTEM_CONFIG_FILE = '/etc/stellarmagnate/magnate.cfg'
# USER_CONFIG_FILE = os.path.join(STATE_DIR, 'magnate.cfg')
# LOG_FILE = os.path.join(STATE_DIR, 'magnate.log')
# DEFAULT_CONFIG = """
# # Directory in which the game data lives.  The data is further divided into subdirectories herein:
# # base/   Commodity names and price ranges, ship types, locations, and such.
# # schema/ schema for the data files in base *deprecated*, moving to voluptuous
# # assets/ Images and other binary files
# data_dir: {data_dir}/base
# 
# # Game state dir
# # Saves, logs, and other data that changes during operation are saved as subdirs of this
# state_dir: {state_dir}
# 
# # Name of the User Interface plugin to use
# ui_plugin: urwid
# 
# # Whether to use uvloop instead of the stdlib asyncio event loop
# use_uvloop: False
# 
# # Configuration of logging output.  This is given directly to twiggy.dict_cnfig()
# logging:
#   version: "1.0"
#   outputs:
#     logfile:
#       output: twiggy.outputs.FileOutput
#       args:
#         - {log_file}
#   emitters:
#     all:
#       level: WARNING
#       output_name: logfile
#       filters: []
# """.format(data_dir='/usr/share/stellarmagnate', log_file=LOG_FILE, state_dir=STATE_DIR)
# TESTING_CONFIG = """
# data_dir: {base_dir}
# logging:
#   version: "1.0"
#   outputs:
#     logfile:
#       output: twiggy.outputs.FileOutput
#       args:
#         - {log_file}
#   emitters:
#     all:
#       level: DEBUG
#       output_name: logfile
# """.format(base_dir=os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'data')),
#            log_file=LOG_FILE)
# CONFIG_SCHEMA = Schema({
#     'data_dir': All(str, Length(min=1)),
#     'state_dir': All(str, Length(min=1)),
#     'ui_plugin': All(str, Length(min=1, max=128)),
#     'use_uvloop': bool,
#     # The logging param is passed directly to twiggy.dict_config() which does its own validation
#     'logging': dict,
#     }, required=False)
# def _find_config(conf_files=tuple()):
# def _merge_mapping(merge_to, merge_from, inplace=False):
# def _read_config(paths, testing=False):
# def read_config(conf_files=tuple(), testing=False):
# def write_default_config(filename):
# 
# Path: magnate/errors.py
# class MagnateError(Exception):
# class MagnateConfigError(MagnateError):
# class MagnateSaveError(MagnateError):
# class MagnateNoSaveGame(MagnateSaveError):
# class MagnateInvalidSaveGame(MagnateSaveError):


import os.path
import pytest
import twiggy
from collections.abc import MutableMapping
from magnate import config as c
from magnate import errors
# The idiom for unittests is to use classes for organization
# pylint: disable=no-self-use





class Test_MergeMapping:
    data_set = (
            # Disjoint keys
            ({'test': 'disjoint'}, {'sets': 'have both'}, {'test': 'disjoint', 'sets': 'have both'}),
            # Overwrite a single key
            ({'test': 'old'}, {'test': 'new'}, {'test': 'new'}),
            # Recursive
            ({'test': {'one': 1, 'two': 2}}, {'test': {'one': 'hombre', 'three': 3}},
                {'test': {'one': 'hombre', 'two': 2, 'three': 3}}),
            )

    @pytest.mark.parametrize('merge_to, merge_from, expect', data_set)
    def test_new_mapping(self, merge_to, merge_from, expect):

# Path: magnate/config.py
# STATE_DIR = os.path.expanduser('~/.stellarmagnate')
# USER_DIR = os.path.expanduser('~/.stellarmagnate')
# SYSTEM_CONFIG_FILE = '/etc/stellarmagnate/magnate.cfg'
# USER_CONFIG_FILE = os.path.join(STATE_DIR, 'magnate.cfg')
# LOG_FILE = os.path.join(STATE_DIR, 'magnate.log')
# DEFAULT_CONFIG = """
# # Directory in which the game data lives.  The data is further divided into subdirectories herein:
# # base/   Commodity names and price ranges, ship types, locations, and such.
# # schema/ schema for the data files in base *deprecated*, moving to voluptuous
# # assets/ Images and other binary files
# data_dir: {data_dir}/base
# 
# # Game state dir
# # Saves, logs, and other data that changes during operation are saved as subdirs of this
# state_dir: {state_dir}
# 
# # Name of the User Interface plugin to use
# ui_plugin: urwid
# 
# # Whether to use uvloop instead of the stdlib asyncio event loop
# use_uvloop: False
# 
# # Configuration of logging output.  This is given directly to twiggy.dict_cnfig()
# logging:
#   version: "1.0"
#   outputs:
#     logfile:
#       output: twiggy.outputs.FileOutput
#       args:
#         - {log_file}
#   emitters:
#     all:
#       level: WARNING
#       output_name: logfile
#       filters: []
# """.format(data_dir='/usr/share/stellarmagnate', log_file=LOG_FILE, state_dir=STATE_DIR)
# TESTING_CONFIG = """
# data_dir: {base_dir}
# logging:
#   version: "1.0"
#   outputs:
#     logfile:
#       output: twiggy.outputs.FileOutput
#       args:
#         - {log_file}
#   emitters:
#     all:
#       level: DEBUG
#       output_name: logfile
# """.format(base_dir=os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'data')),
#            log_file=LOG_FILE)
# CONFIG_SCHEMA = Schema({
#     'data_dir': All(str, Length(min=1)),
#     'state_dir': All(str, Length(min=1)),
#     'ui_plugin': All(str, Length(min=1, max=128)),
#     'use_uvloop': bool,
#     # The logging param is passed directly to twiggy.dict_config() which does its own validation
#     'logging': dict,
#     }, required=False)
# def _find_config(conf_files=tuple()):
# def _merge_mapping(merge_to, merge_from, inplace=False):
# def _read_config(paths, testing=False):
# def read_config(conf_files=tuple(), testing=False):
# def write_default_config(filename):
# 
# Path: magnate/errors.py
# class MagnateError(Exception):
# class MagnateConfigError(MagnateError):
# class MagnateSaveError(MagnateError):
# class MagnateNoSaveGame(MagnateSaveError):
# class MagnateInvalidSaveGame(MagnateSaveError):


# Path: tests/units/test_config.py
import os.path
import pytest
import twiggy
from collections.abc import MutableMapping
from magnate import config as c
from magnate import errors

# The idiom for unittests is to use classes for organization
# pylint: disable=no-self-use





class Test_MergeMapping:
    data_set = (
            # Disjoint keys
            ({'test': 'disjoint'}, {'sets': 'have both'}, {'test': 'disjoint', 'sets': 'have both'}),
            # Overwrite a single key
            ({'test': 'old'}, {'test': 'new'}, {'test': 'new'}),
            # Recursive
            ({'test': {'one': 1, 'two': 2}}, {'test': {'one': 'hombre', 'three': 3}},
                {'test': {'one': 'hombre', 'two': 2, 'three': 3}}),
            )

    @pytest.mark.parametrize('merge_to, merge_from, expect', data_set)
    def test_new_mapping(self, merge_to, merge_from, expect):

        returned_mapping = c._merge_mapping(merge_to, merge_from)