コード例 #1
0
    def test_ini_noext(self):
        """Testing ini config file(s) without extension"""
        print "Running: %s - %s" % (self.id(), self.shortDescription())

        g.store_config(self.config, self.ini_file)
        self.assertTrue(os.path.exists(self.ini_file))
        g.store_config(self.config, self.ini_noext, config_type='ini')
        self.assertTrue(os.path.exists(self.ini_noext))

        print "--------------"
        g.show_file(self.ini_file)
        print "--------------"
        g.show_file(self.ini_noext)
        print "--------------"

        # read the config file
        config = g.load_config(self.ini_file)
        g.show_config(config)
        self.assertEqual(config['defaults']['this'], 'yada1')
        self.assertEqual(config['defaults']['that'], 'yada2')
        self.assertEqual(config['defaults']['this_and_that'],
                         'yada1 and yada2')
        self.assertEqual(config['globals']['the_other'], 'yada3')

        config_noext = g.load_config(self.ini_file, config_type='ini')
        g.show_config(config_noext)
        self.assertEqual(config_noext['defaults']['this'], 'yada1')
        self.assertEqual(config_noext['defaults']['that'], 'yada2')
        self.assertEqual(config_noext['defaults']['this_and_that'],
                         'yada1 and yada2')
        self.assertEqual(config_noext['globals']['the_other'], 'yada3')

        self.assertEqual(config, config_noext, 'config files are not the same')
コード例 #2
0
    def test_yaml_noext(self):
        """Testing yaml config file without extension"""
        print "Running: %s - %s" % (self.id(), self.shortDescription())

        g.show_config(self.config)

        # write the config files
        g.store_config(self.config, self.yaml_file)
        self.assertTrue(os.path.exists(self.yaml_file))
        g.store_config(self.config, self.yaml_noext, config_type='yaml')
        self.assertTrue(os.path.exists(self.yaml_noext))

        print "--------------"
        g.show_file(self.yaml_file)
        print "--------------"
        g.show_file(self.yaml_noext)
        print "--------------"

        # read the config file
        config = g.load_config(self.yaml_file)
        g.show_config(config)
        self.assertEqual(config['defaults']['this'], 'yada1')
        self.assertEqual(config['defaults']['that'], 'yada2')
        self.assertEqual(config['globals']['the_other'], 'yada3')

        config_noext = g.load_config(self.yaml_noext, config_type='yaml')
        g.show_config(config_noext)
        self.assertEqual(config_noext['defaults']['this'], 'yada1')
        self.assertEqual(config_noext['defaults']['that'], 'yada2')
        self.assertEqual(config_noext['globals']['the_other'], 'yada3')

        self.assertEqual(config, config_noext, 'config files are not the same')
コード例 #3
0
    def test_ini_mixedcase(self):
        """Testing ini mixed case in config file(s)"""
        print "Running: %s - %s" % (self.id(), self.shortDescription())

        g.store_config(self.config, self.ini_mixedcase_file)
        self.assertTrue(os.path.exists(self.ini_mixedcase_file))

        # read the config file
        config = g.load_config(self.ini_mixedcase_file)
        g.show_config(config)
        self.assertEqual(config['mixed']['mixed_CASE'], 'mixedCaseValue')
コード例 #4
0
    def test_ini(self):
        """Testing ini config file(s)"""
        print "Running: %s - %s" % (self.id(), self.shortDescription())

        g.store_config(self.config, self.ini_file)
        self.assertTrue(os.path.exists(self.ini_file))

        # read the config file
        config = g.load_config(self.ini_file)
        g.show_config(config)
        self.assertEqual(config['defaults']['this'], 'yada1')
        self.assertEqual(config['defaults']['that'], 'yada2')
        self.assertEqual(config['defaults']['this_and_that'],
                         'yada1 and yada2')
        self.assertEqual(config['globals']['the_other'], 'yada3')
コード例 #5
0
    def test_yaml(self):
        """Testing yaml config file"""
        print "Running: %s - %s" % (self.id(), self.shortDescription())

        # write the config file
        g.store_config(self.config, self.yaml_file)
        # TODO: does unittest have a file exists assert?
        self.assertTrue(os.path.exists(self.yaml_file))

        # read the config file
        config = g.load_config(self.yaml_file)
        g.show_config(config)
        self.assertEqual(config['defaults']['this'], 'yada1')
        self.assertEqual(config['defaults']['that'], 'yada2')
        self.assertEqual(config['globals']['the_other'], 'yada3')
コード例 #6
0
    def test_ini(self):
        """Testing ini config file(s)"""
        print "Running: %s - %s" % (self.id(), self.shortDescription())

        g.store_config(self.config, self.ini_file)
        self.assertTrue(os.path.exists(self.ini_file))

        # read the config file
        config = g.load_config(self.ini_file)
        g.show_config(config)
        self.assertEqual(config['defaults']['this'], 'yada1')
        self.assertEqual(config['defaults']['that'], 'yada2')
        self.assertEqual(config['defaults']['this_and_that'],
                         'yada1 and yada2')
        self.assertEqual(config['globals']['the_other'], 'yada3')
コード例 #7
0
    def test_yaml(self):
        """Testing yaml config file"""
        print "Running: %s - %s" % (self.id(), self.shortDescription())

        g.show_config(self.config)

        # write the config file
        g.store_config(self.config, self.yaml_file)
        self.assertTrue(os.path.exists(self.yaml_file))

        # read the config file
        config = g.load_config(self.yaml_file)
        g.show_config(config)
        self.assertEqual(config['defaults']['this'], 'yada1')
        self.assertEqual(config['defaults']['that'], 'yada2')
        self.assertEqual(config['globals']['the_other'], 'yada3')
コード例 #8
0
    def test_ini_novalue(self):
        """Testing ini config file(s) without values"""
        print "Running: %s - %s" % (self.id(), self.shortDescription())

        g.store_config(self.config_novalue, self.ini_novalue_file)
        self.assertTrue(os.path.exists(self.ini_novalue_file))

        print "--------------"
        g.show_file(self.ini_novalue_file)
        print "--------------"

        # read the config file
        config = g.load_config(self.ini_novalue_file)
        g.show_config(config)
        self.assertEqual(config['defaults'].get('this'), '')
        self.assertEqual(config['defaults'].get('that'), '')
        self.assertEqual(config['globals'].get('and_one_more_thing'), '')
        self.assertEqual(config['globals'].get('the_other'), '')