# Path: exactonline/storage/base.py
# class MissingSetting(ValueError):
#     pass
# 
# Path: exactonline/storage/ini.py
# class IniStorage(ExactOnlineConfig, ConfigParser):
#     """
#     Configuration based on the SafeConfigParser and the
#     ExactOnlineConfig.
# 
#     Takes a ``filename_or_fp`` which can either be a filename or a file
#     pointer. If it is a filename, all set() operations are destructive:
#     the file will be automatically updated.
#     """
#     def __init__(self, filename_or_fp, **kwargs):
#         super(IniStorage, self).__init__(**kwargs)
# 
#         if hasattr(filename_or_fp, 'read'):
#             if hasattr(self, 'read_file'):
#                 self.read_file(filename_or_fp)
#             else:
#                 self.readfp(filename_or_fp)  # python<3.2
#             self.overwrite = False
#         else:
#             self.read([filename_or_fp])
#             self.overwrite = filename_or_fp
# 
#     def get(self, section, option, **kwargs):
#         """
#         Get method that raises MissingSetting if the value was unset.
# 
#         This differs from the SafeConfigParser which may raise either a
#         NoOptionError or a NoSectionError.
# 
#         We take extra **kwargs because the Python 3.5 configparser extends the
#         get method signature and it calls self with those parameters.
# 
#             def get(self, section, option, *, raw=False, vars=None,
#                     fallback=_UNSET):
#         """
#         try:
#             ret = super(ExactOnlineConfig, self).get(section, option, **kwargs)
#         except (NoOptionError, NoSectionError):
#             raise MissingSetting(option, section)
# 
#         return ret
# 
#     def set(self, section, option, value):
#         """
#         Set method that (1) auto-saves if possible and (2) auto-creates
#         sections.
#         """
#         try:
#             super(ExactOnlineConfig, self).set(section, option, value)
#         except NoSectionError:
#             self.add_section(section)
#             super(ExactOnlineConfig, self).set(section, option, value)
# 
#         # Save automatically!
#         self.save()
# 
#     def save(self):
#         if self.overwrite:
#             with open(self.overwrite, 'w') as output:
#                 self.write(output)


from unittest import TestCase, main
from io import StringIO
from os import path, unlink
from . import MissingSetting
from .ini import IniStorage
# vim: set ts=8 sw=4 sts=4 et ai tw=79:
"""
Test ini storage class to the Exact Online REST API Library.

This file is part of the Exact Online REST API Library in Python
(EORALP), licensed under the LGPLv3+.
Copyright (C) 2015-2021 Walter Doekes, OSSO B.V.
"""



class IniStorageTestCase(TestCase):
    def test_dont_die_if_config_doesnt_exist(self):
        try:

# Path: exactonline/storage/base.py
# class MissingSetting(ValueError):
#     pass
# 
# Path: exactonline/storage/ini.py
# class IniStorage(ExactOnlineConfig, ConfigParser):
#     """
#     Configuration based on the SafeConfigParser and the
#     ExactOnlineConfig.
# 
#     Takes a ``filename_or_fp`` which can either be a filename or a file
#     pointer. If it is a filename, all set() operations are destructive:
#     the file will be automatically updated.
#     """
#     def __init__(self, filename_or_fp, **kwargs):
#         super(IniStorage, self).__init__(**kwargs)
# 
#         if hasattr(filename_or_fp, 'read'):
#             if hasattr(self, 'read_file'):
#                 self.read_file(filename_or_fp)
#             else:
#                 self.readfp(filename_or_fp)  # python<3.2
#             self.overwrite = False
#         else:
#             self.read([filename_or_fp])
#             self.overwrite = filename_or_fp
# 
#     def get(self, section, option, **kwargs):
#         """
#         Get method that raises MissingSetting if the value was unset.
# 
#         This differs from the SafeConfigParser which may raise either a
#         NoOptionError or a NoSectionError.
# 
#         We take extra **kwargs because the Python 3.5 configparser extends the
#         get method signature and it calls self with those parameters.
# 
#             def get(self, section, option, *, raw=False, vars=None,
#                     fallback=_UNSET):
#         """
#         try:
#             ret = super(ExactOnlineConfig, self).get(section, option, **kwargs)
#         except (NoOptionError, NoSectionError):
#             raise MissingSetting(option, section)
# 
#         return ret
# 
#     def set(self, section, option, value):
#         """
#         Set method that (1) auto-saves if possible and (2) auto-creates
#         sections.
#         """
#         try:
#             super(ExactOnlineConfig, self).set(section, option, value)
#         except NoSectionError:
#             self.add_section(section)
#             super(ExactOnlineConfig, self).set(section, option, value)
# 
#         # Save automatically!
#         self.save()
# 
#     def save(self):
#         if self.overwrite:
#             with open(self.overwrite, 'w') as output:
#                 self.write(output)


# Path: exactonline/storage/storage_test.py
from unittest import TestCase, main
from io import StringIO
from os import path, unlink
from . import MissingSetting
from .ini import IniStorage

# vim: set ts=8 sw=4 sts=4 et ai tw=79:
"""
Test ini storage class to the Exact Online REST API Library.

This file is part of the Exact Online REST API Library in Python
(EORALP), licensed under the LGPLv3+.
Copyright (C) 2015-2021 Walter Doekes, OSSO B.V.
"""



class IniStorageTestCase(TestCase):
    def test_dont_die_if_config_doesnt_exist(self):
        try:

            config = IniStorage('storage-does-not-exist.ini')