def test_set_get(self):
        self.assertEqual(os.path.exists(self.filepath), False)
        os.environ['CALVIN_CONFIG_PATH'] = self.filepath

        _conf = CalvinConfig()
        _conf.add_section("test")

        for a in range(10):
            _conf.set("test", "BANAN%d" % a, str(a))
            self.assertEqual(_conf.get("test", "BANAN%d" % a), str(a))

        for a in range(10):
            _conf.set("test", "BANAN%d" % a, a)
            self.assertEqual(_conf.get("test", "BANAN%d" % a), a)

        for a in range(10):
            _conf.set("test", "BANAN%d" % a, range(10))
            self.assertEqual(_conf.get("test", "BANAN%d" % a), range(10))

        # Should this two become the same ? No.
        for a in range(10):
            _conf.set("test", "BANAN%d" % a, dict(zip(range(10), range(10))))
            self.assertNotEqual(_conf.get("test", "BANAN%d" % a), dict(zip([str(x) for x in range(10)], range(10))))

        for a in range(10):
            _conf.set("test", "BANAN%d" % a, dict(zip([str(x) for x in range(10)], range(10))))
            self.assertEqual(_conf.get("test", "BANAN%d" % a), dict(zip([str(x) for x in range(10)], range(10))))

        for a in range(10):
            _conf.set("test", "BANAN%d" % a, dict(zip([str(x) for x in range(10)], [range(10)])))
            self.assertEqual(_conf.get("test", "BANAN%d" % a), dict(zip([str(x) for x in range(10)], [range(10)])))
Esempio n. 2
0
    def test_lists(self):
        self.assertEqual(os.path.exists(self.filepath), False)
        os.environ['CALVIN_CONFIG_PATH'] = self.filepath

        _conf = CalvinConfig()
        _conf.add_section("test")

        test_item = [str(x) for x in range(10)]
        _conf.set("test", "BANAN2", test_item)
        self.assertEqual(_conf.get("test", "BANAN2"), test_item)
    def test_lists(self):
        self.assertEqual(os.path.exists(self.filepath), False)
        os.environ['CALVIN_CONFIG_PATH'] = self.filepath

        _conf = CalvinConfig()
        _conf.add_section("test")

        test_item = [str(x) for x in range(10)]
        _conf.set("test", "BANAN2", test_item)
        self.assertEqual(_conf.get("test", "BANAN2"), test_item)
Esempio n. 4
0
    def test_env_override_list_append(self):
        self.assertEqual(os.path.exists(self.filepath), False)
        os.environ['CALVIN_CONFIG_PATH'] = self.filepath

        _conf = CalvinConfig()
        _conf.add_section("test")

        test_item = [str(x) for x in range(10)]
        _conf.set("test", "KAKA", test_item)
        os.environ['CALVIN_KAKA'] = "HEJ"
        self.assertEqual(_conf.get("test", "KAKA"), "HEJ")

        test_item = range(10)
        test_item2 = ["HEJ", "hej", "HEJ"]
        _conf.set("test", "KAKA", test_item)
        os.environ['CALVIN_KAKA'] = os.pathsep.join(test_item2)
        self.assertEqual(_conf.get("test", "KAKA"), test_item2 + test_item)

        test_item = [str(x) for x in range(10)]
        _conf.set("test", "KAKA", test_item)
        os.environ['CALVIN_KAKA'] = '["HEJ", "hej", "HEJ"]'
        self.assertEqual(_conf.get("test", "KAKA"), test_item2 + test_item)
    def test_env_override_list_append(self):
        self.assertEqual(os.path.exists(self.filepath), False)
        os.environ['CALVIN_CONFIG_PATH'] = self.filepath

        _conf = CalvinConfig()
        _conf.add_section("test")

        test_item = [str(x) for x in range(10)]
        _conf.set("test", "KAKA", test_item)
        os.environ['CALVIN_KAKA'] = "HEJ"
        self.assertEqual(_conf.get("test", "KAKA"), "HEJ")

        test_item = range(10)
        test_item2 = ["HEJ", "hej", "HEJ"]
        _conf.set("test", "KAKA", test_item)
        os.environ['CALVIN_KAKA'] = os.pathsep.join(test_item2)
        self.assertEqual(_conf.get("test", "KAKA"), test_item2 + test_item)

        test_item = [str(x) for x in range(10)]
        _conf.set("test", "KAKA", test_item)
        os.environ['CALVIN_KAKA'] = '["HEJ", "hej", "HEJ"]'
        self.assertEqual(_conf.get("test", "KAKA"), test_item2 + test_item)
Esempio n. 6
0
    def test_set_get(self):
        self.assertEqual(os.path.exists(self.filepath), False)
        os.environ['CALVIN_CONFIG_PATH'] = self.filepath

        _conf = CalvinConfig()
        _conf.add_section("test")

        for a in range(10):
            _conf.set("test", "BANAN%d" % a, str(a))
            self.assertEqual(_conf.get("test", "BANAN%d" % a), str(a))

        for a in range(10):
            _conf.set("test", "BANAN%d" % a, a)
            self.assertEqual(_conf.get("test", "BANAN%d" % a), a)

        for a in range(10):
            _conf.set("test", "BANAN%d" % a, range(10))
            self.assertEqual(_conf.get("test", "BANAN%d" % a), range(10))

        # Should this two become the same ? No.
        for a in range(10):
            _conf.set("test", "BANAN%d" % a, dict(zip(range(10), range(10))))
            self.assertNotEqual(
                _conf.get("test", "BANAN%d" % a),
                dict(zip([str(x) for x in range(10)], range(10))))

        for a in range(10):
            _conf.set("test", "BANAN%d" % a,
                      dict(zip([str(x) for x in range(10)], range(10))))
            self.assertEqual(_conf.get("test", "BANAN%d" % a),
                             dict(zip([str(x) for x in range(10)], range(10))))

        for a in range(10):
            _conf.set("test", "BANAN%d" % a,
                      dict(zip([str(x) for x in range(10)], [range(10)])))
            self.assertEqual(
                _conf.get("test", "BANAN%d" % a),
                dict(zip([str(x) for x in range(10)], [range(10)])))