# Path: HPCStats/Conf/HPCStatsConf.py
# class HPCStatsConf(ConfigParser.ConfigParser, object):
# 
#     def __init__(self, filename, cluster):
# 
#         super(HPCStatsConf, self).__init__()
# 
#         self.cluster = cluster
#         self.filename = filename
# 
#     def read(self):
#         """Check if configuration file exists and then read it. Raises
#            HPCStatsConfigurationException if configuration file does not exist.
#         """
# 
#         if not os.path.exists(self.filename):
#             raise HPCStatsConfigurationException(
#                     "file %s does not exist" % (self.filename))
# 
#         super(HPCStatsConf, self).read(self.filename)
# 
#     def get(self, section, option, option_type=str):
#         """Try to get option value in section of configuration. Raise
#            HPCStatsConfigurationException if not found.
#         """
#         try:
#             if option_type is bool:
#                 return super(HPCStatsConf, self).getboolean(section, option)
#             if option_type is int:
#                 return super(HPCStatsConf, self).getint(section, option)
#             else:
#                 return super(HPCStatsConf, self).get(section, option)
#         except ConfigParser.NoSectionError:
#             raise HPCStatsConfigurationException( \
#                     "section %s not found" % (section))
#         except ConfigParser.NoOptionError:
#             raise HPCStatsConfigurationException( \
#                     "option %s not found in section %s" % (option, section))
# 
#     def get_default(self, section, option, default, option_type=str):
#         """Try to get option value in section of configuration. Return default
#            if not found.
#         """
#         try:
#             return self.get(section, option, option_type)
#         except HPCStatsConfigurationException:
#             return default
# 
#     def get_list(self, section, option):
#         """Returns a comma separated multi-values parameter formatted into a
#            list. If the parameter is not set, it returns an empty list."""
#         items = self.get_default(section, option, '')
#         return [ item.strip()
#                  for item in items.split(',')
#                  if item.strip() != '' ]
# 
#     def get_clusters_list(self):
#         """Returns the list of clusters in configuration file. If any problem
#            is encountered, HPCStatsConfigurationException is raised.
#         """
#         try:
#             cluster_list_str = self.get("clusters","clusters")
#         except ConfigParser.NoSectionError:
#             raise HPCStatsConfigurationException(
#                     "section clusters is not present in configuration file")
#         except ConfigParser.NoOptionError:
#             raise HPCStatsConfigurationException(
#                     "option clusters is not present in configuration file")
#         return cluster_list_str.split(",")
# 
#     def check_cluster(self):
#         """Check for presence of cluster in configuration file. If any problem
#            is encountered, HPCStatsConfigurationException is raised.
#         """
# 
#         clusters = self.get_clusters_list()
#         if self.cluster not in clusters:
#             raise HPCStatsConfigurationException(
#                     "cluster %s is not present in configuration file" \
#                       % self.cluster)
# 
# Path: HPCStats/Tests/Mocks/MockConfigParser.py
# class MockConfigParser():
# 
#     def __init__(self):
#         self.conf = None
# 
#     def read(self, filename):
#         pass
# 
#     def get(self, section, option):
#         if section not in self.conf.keys():
#             raise NoSectionError(section)
#         if option not in self.conf[section].keys():
#             raise NoOptionError(section, option)
#         return self.conf[section][option]
# 
#     def getint(self, section, option):
#         value = self.get(section, option)
#         if type(value) is not int:
#             raise ValueError( \
#               "invalid literal for int() with base 10: '%s'" \
#                 % (value))
#         return value
# 
#     def getboolean(self, section, option):
#         value = self.get(section, option)
#         if type(value) is not bool:
#             raise ValueError("invalid boolean: '%s'" % (value))
#         return value
# 
#     def sections(self):
# 
#         return self.conf.keys()
# 
#     def options(self, section):
# 
#         return self.conf[section].keys()
# 
# Path: HPCStats/Tests/Utils.py
# class HPCStatsTestCase(unittest.TestCase):
# 
#     def __init__(self, methodName="runTest"):
# 
#         super(HPCStatsTestCase,self).__init__(methodName)
# 
# def loadtestcase(testcase):
#     suite = unittest.TestLoader().loadTestsFromTestCase(testcase)
#     unittest.TextTestRunner(verbosity=2).run(suite)


import copy
from HPCStats.Conf.HPCStatsConf import HPCStatsConf
from HPCStats.Tests.Mocks.MockConfigParser import MockConfigParser
from HPCStats.Tests.Utils import HPCStatsTestCase, loadtestcase
#
# HPCStats is free software: you can redistribute in and/or
# modify it under the terms of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with HPCStats. If not, see
# <http://www.gnu.org/licenses/>.
#
# On Calibre systems, the complete text of the GNU General
# Public License can be found in `/usr/share/common-licenses/GPL'.



CONFIG = {
  'sectiona': {
    'option_str':  'test_value',
    'option_int':  123,
    'option_bool': False,
    'option_list': 'john,doe',
  },
}

module = "HPCStats.Conf.HPCStatsConf"


# Path: HPCStats/Conf/HPCStatsConf.py
# class HPCStatsConf(ConfigParser.ConfigParser, object):
# 
#     def __init__(self, filename, cluster):
# 
#         super(HPCStatsConf, self).__init__()
# 
#         self.cluster = cluster
#         self.filename = filename
# 
#     def read(self):
#         """Check if configuration file exists and then read it. Raises
#            HPCStatsConfigurationException if configuration file does not exist.
#         """
# 
#         if not os.path.exists(self.filename):
#             raise HPCStatsConfigurationException(
#                     "file %s does not exist" % (self.filename))
# 
#         super(HPCStatsConf, self).read(self.filename)
# 
#     def get(self, section, option, option_type=str):
#         """Try to get option value in section of configuration. Raise
#            HPCStatsConfigurationException if not found.
#         """
#         try:
#             if option_type is bool:
#                 return super(HPCStatsConf, self).getboolean(section, option)
#             if option_type is int:
#                 return super(HPCStatsConf, self).getint(section, option)
#             else:
#                 return super(HPCStatsConf, self).get(section, option)
#         except ConfigParser.NoSectionError:
#             raise HPCStatsConfigurationException( \
#                     "section %s not found" % (section))
#         except ConfigParser.NoOptionError:
#             raise HPCStatsConfigurationException( \
#                     "option %s not found in section %s" % (option, section))
# 
#     def get_default(self, section, option, default, option_type=str):
#         """Try to get option value in section of configuration. Return default
#            if not found.
#         """
#         try:
#             return self.get(section, option, option_type)
#         except HPCStatsConfigurationException:
#             return default
# 
#     def get_list(self, section, option):
#         """Returns a comma separated multi-values parameter formatted into a
#            list. If the parameter is not set, it returns an empty list."""
#         items = self.get_default(section, option, '')
#         return [ item.strip()
#                  for item in items.split(',')
#                  if item.strip() != '' ]
# 
#     def get_clusters_list(self):
#         """Returns the list of clusters in configuration file. If any problem
#            is encountered, HPCStatsConfigurationException is raised.
#         """
#         try:
#             cluster_list_str = self.get("clusters","clusters")
#         except ConfigParser.NoSectionError:
#             raise HPCStatsConfigurationException(
#                     "section clusters is not present in configuration file")
#         except ConfigParser.NoOptionError:
#             raise HPCStatsConfigurationException(
#                     "option clusters is not present in configuration file")
#         return cluster_list_str.split(",")
# 
#     def check_cluster(self):
#         """Check for presence of cluster in configuration file. If any problem
#            is encountered, HPCStatsConfigurationException is raised.
#         """
# 
#         clusters = self.get_clusters_list()
#         if self.cluster not in clusters:
#             raise HPCStatsConfigurationException(
#                     "cluster %s is not present in configuration file" \
#                       % self.cluster)
# 
# Path: HPCStats/Tests/Mocks/MockConfigParser.py
# class MockConfigParser():
# 
#     def __init__(self):
#         self.conf = None
# 
#     def read(self, filename):
#         pass
# 
#     def get(self, section, option):
#         if section not in self.conf.keys():
#             raise NoSectionError(section)
#         if option not in self.conf[section].keys():
#             raise NoOptionError(section, option)
#         return self.conf[section][option]
# 
#     def getint(self, section, option):
#         value = self.get(section, option)
#         if type(value) is not int:
#             raise ValueError( \
#               "invalid literal for int() with base 10: '%s'" \
#                 % (value))
#         return value
# 
#     def getboolean(self, section, option):
#         value = self.get(section, option)
#         if type(value) is not bool:
#             raise ValueError("invalid boolean: '%s'" % (value))
#         return value
# 
#     def sections(self):
# 
#         return self.conf.keys()
# 
#     def options(self, section):
# 
#         return self.conf[section].keys()
# 
# Path: HPCStats/Tests/Utils.py
# class HPCStatsTestCase(unittest.TestCase):
# 
#     def __init__(self, methodName="runTest"):
# 
#         super(HPCStatsTestCase,self).__init__(methodName)
# 
# def loadtestcase(testcase):
#     suite = unittest.TestLoader().loadTestsFromTestCase(testcase)
#     unittest.TextTestRunner(verbosity=2).run(suite)


# Path: HPCStats/Tests/tests_HPCStatsConf.py
import copy
from HPCStats.Conf.HPCStatsConf import HPCStatsConf
from HPCStats.Tests.Mocks.MockConfigParser import MockConfigParser
from HPCStats.Tests.Utils import HPCStatsTestCase, loadtestcase

#
# HPCStats is free software: you can redistribute in and/or
# modify it under the terms of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with HPCStats. If not, see
# <http://www.gnu.org/licenses/>.
#
# On Calibre systems, the complete text of the GNU General
# Public License can be found in `/usr/share/common-licenses/GPL'.



CONFIG = {
  'sectiona': {
    'option_str':  'test_value',
    'option_int':  123,
    'option_bool': False,
    'option_list': 'john,doe',
  },
}

module = "HPCStats.Conf.HPCStatsConf"


class TestsHPCStatsConf(HPCStatsTestCase):