summaryrefslogtreecommitdiffstats
path: root/tests/test_ipalib/test_config.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-12-22 15:41:24 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-12-22 15:41:24 -0700
commit5b637f6a18a647a0ff084b2932faa1a4a887a5c2 (patch)
tree17f3fdb8e1c00a6f14f2ffa2b9b5d4b45c6e48c8 /tests/test_ipalib/test_config.py
parent885efbe085fcc177241a4553bde45f29241376e0 (diff)
downloadfreeipa-5b637f6a18a647a0ff084b2932faa1a4a887a5c2.tar.gz
freeipa-5b637f6a18a647a0ff084b2932faa1a4a887a5c2.tar.xz
freeipa-5b637f6a18a647a0ff084b2932faa1a4a887a5c2.zip
Removed depreciated code from config.py; removed corresponding unit tests
Diffstat (limited to 'tests/test_ipalib/test_config.py')
-rw-r--r--tests/test_ipalib/test_config.py162
1 files changed, 1 insertions, 161 deletions
diff --git a/tests/test_ipalib/test_config.py b/tests/test_ipalib/test_config.py
index ddfbb708b..e17c4799e 100644
--- a/tests/test_ipalib/test_config.py
+++ b/tests/test_ipalib/test_config.py
@@ -31,88 +31,7 @@ from tests.util import TempDir, TempHome
from ipalib import config, constants
-def test_Environment():
- """
- Test the `ipalib.config.Environment` class.
- """
- # This has to be the same as iter_cnt
- control_cnt = 0
- class prop_class:
- def __init__(self, val):
- self._val = val
- def get_value(self):
- return self._val
-
- class iter_class(prop_class):
- # Increment this for each time iter_class yields
- iter_cnt = 0
- def get_value(self):
- for item in self._val:
- self.__class__.iter_cnt += 1
- yield item
-
- # Tests for basic functionality
- basic_tests = (
- ('a', 1),
- ('b', 'basic_foo'),
- ('c', ('basic_bar', 'basic_baz')),
- )
- # Tests with prop classes
- prop_tests = (
- ('d', prop_class(2), 2),
- ('e', prop_class('prop_foo'), 'prop_foo'),
- ('f', prop_class(('prop_bar', 'prop_baz')), ('prop_bar', 'prop_baz')),
- )
- # Tests with iter classes
- iter_tests = (
- ('g', iter_class((3, 4, 5)), (3, 4, 5)),
- ('h', iter_class(('iter_foo', 'iter_bar', 'iter_baz')),
- ('iter_foo', 'iter_bar', 'iter_baz')
- ),
- )
-
- # Set all the values
- env = config.Environment()
- for name, val in basic_tests:
- env[name] = val
- for name, val, dummy in prop_tests:
- env[name] = val
- for name, val, dummy in iter_tests:
- env[name] = val
-
- # Test if the values are correct
- for name, val in basic_tests:
- assert env[name] == val
- for name, dummy, val in prop_tests:
- assert env[name] == val
- # Test if the get_value() function is called only when needed
- for name, dummy, correct_values in iter_tests:
- values_in_env = []
- for val in env[name]:
- control_cnt += 1
- assert iter_class.iter_cnt == control_cnt
- values_in_env.append(val)
- assert tuple(values_in_env) == correct_values
-
- # Test __setattr__()
- env.spam = 'ham'
-
- assert env.spam == 'ham'
- assert env['spam'] == 'ham'
- assert env.get('spam') == 'ham'
- assert env.get('nonexistent') == None
- assert env.get('nonexistent', 42) == 42
-
- # Test if we throw AttributeError exception when trying to overwrite
- # existing value, or delete it
- raises(AttributeError, setitem, env, 'a', 1)
- raises(AttributeError, setattr, env, 'a', 1)
- raises(AttributeError, delitem, env, 'a')
- raises(AttributeError, delattr, env, 'a')
- raises(AttributeError, config.Environment.update, env, dict(a=1000))
- # This should be silently ignored
- env.update(dict(a=1000), True)
- assert env.a != 1000
+
# Random base64-encoded data to simulate a misbehaving config file.
@@ -557,82 +476,3 @@ class test_Env(ClassChecker):
for key in keys:
o[key] = 'the value'
assert list(o) == sorted(keys + default_keys)
-
-
-def test_set_default_env():
- """
- Test the `ipalib.config.set_default_env` function.
- """
-
- # Make sure we don't overwrite any properties
- d = dict(
- query_dns = False,
- server = ('first', 'second'),
- realm = 'myrealm',
- # test right conversions
- server_context = 'off',
- )
- env = config.Environment()
- config.set_default_env(env)
- env.update(d)
- assert env['server_context'] == False
- assert env['query_dns'] == False
-
- # Make sure the servers is overwrote properly (that it is still LazyProp)
- iter = env['server']
- assert iter.next() == 'first'
- assert iter.next() == 'second'
-
-
-def test_LazyProp():
- """
- Test the `ipalib.config.LazyProp` class.
- """
-
- def dummy():
- return 1
-
- # Basic sanity testing with no initial value
- prop = config.LazyProp(int, dummy)
- assert prop.get_value() == 1
- prop.set_value(2)
- assert prop.get_value() == 2
-
- # Basic sanity testing with initial value
- prop = config.LazyProp(int, dummy, 3)
- assert prop.get_value() == 3
- prop.set_value(4)
- assert prop.get_value() == 4
-
-
-def test_LazyIter():
- """
- Test the `ipalib.config.LazyIter` class.
- """
-
- def dummy():
- yield 1
- yield 2
-
- # Basic sanity testing with no initial value
- prop = config.LazyIter(int, dummy)
- iter = prop.get_value()
- assert iter.next() == 1
- assert iter.next() == 2
- raises(StopIteration, iter.next)
-
- # Basic sanity testing with initial value
- prop = config.LazyIter(int, dummy, 0)
- iter = prop.get_value()
- assert iter.next() == 0
- assert iter.next() == 1
- assert iter.next() == 2
- raises(StopIteration, iter.next)
-
-
-def test_read_config():
- """
- Test the `ipalib.config.read_config` class.
- """
-
- raises(AssertionError, config.read_config, 1)