Ejemplo n.º 1
0
 def test_namespace06(self):
     '''
     '''
     log = logging.getLogger(__name__)
     log.debug("BEGIN: unittest.TestCase.id=%r", unittest.TestCase.id(self))
     name = 'foo'
     cr = configuration.ConfigNamespace(name, foo={'value': 5}, bar=7)
     self.assertFalse(cr.has_property('Idonotexist'))
Ejemplo n.º 2
0
 def test_namespace01(self):
     '''
     '''
     log = logging.getLogger(__name__)
     log.debug("BEGIN: unittest.TestCase.id=%r", unittest.TestCase.id(self))
     name = 'foo'
     cr = configuration.ConfigNamespace(name)
     self.assertEqual(cr.name, name)
Ejemplo n.º 3
0
 def test_namespace08(self):
     '''
     '''
     log = logging.getLogger(__name__)
     log.debug("BEGIN: unittest.TestCase.id=%r", unittest.TestCase.id(self))
     name = 'foo'
     cr = configuration.ConfigNamespace(name)
     cr.add_properties(properties={'foo': {'value': 5}, 'bar': 7})
     self.assertEqual(cr.foo.value, 5)
Ejemplo n.º 4
0
 def test_namespace07(self):
     '''
     '''
     log = logging.getLogger(__name__)
     log.debug("BEGIN: unittest.TestCase.id=%r", unittest.TestCase.id(self))
     name = 'foo'
     cr = configuration.ConfigNamespace(name, foo={'value': 5}, bar=7)
     cr.add_property('baz', value=9)
     self.assertEqual(cr.baz.value, 9)
Ejemplo n.º 5
0
 def test_namespace03(self):
     '''
     '''
     log = logging.getLogger(__name__)
     log.debug("BEGIN: unittest.TestCase.id=%r", unittest.TestCase.id(self))
     name = 'foo'
     cr = configuration.ConfigNamespace(name, foo={'value': 5}, bar=7)
     self.assertEqual(cr.name, name)
     self.assertEqual(cr.foo.name, 'foo')
     self.assertEqual(cr.foo.value, 5)
Ejemplo n.º 6
0
 def test_namespace13(self):
     '''
     '''
     log = logging.getLogger(__name__)
     log.debug("BEGIN: unittest.TestCase.id=%r", unittest.TestCase.id(self))
     name = 'foo'
     cr = configuration.ConfigNamespace(name, foo={'value': 5}, bar=7)
     eok = False
     try:
         cr.add_properties(properties={'foo': {'value': 5}})
     except ConfigNamespaceDuplicateProperty:
         eok = True
     self.assertTrue(eok)
Ejemplo n.º 7
0
 def test_namespace12(self):
     '''
     '''
     log = logging.getLogger(__name__)
     log.debug("BEGIN: unittest.TestCase.id=%r", unittest.TestCase.id(self))
     name = 'foo'
     cr = configuration.ConfigNamespace(name)
     eok = False
     try:
         cr.add_properties(properties={'foo': {'value': 5}, '!badname': 7})
     except ConfigPropertyBadName:
         eok = True
     self.assertTrue(eok)
Ejemplo n.º 8
0
 def test_namespace09(self):
     '''
     '''
     log = logging.getLogger(__name__)
     log.debug("BEGIN: unittest.TestCase.id=%r", unittest.TestCase.id(self))
     name = 'foo'
     cr = configuration.ConfigNamespace(name)
     cr.add_properties(properties={'foo': {'value': 5}, 'bar': 7})
     act = "%r" % (cr, )
     log.debug("(1) ACTUAL=" + act)
     exp = ("ConfigNamespace(bar=<class "
            "'dlapp.configuration.ConfigPropertyRecordExt'>(bar , 7 ,"
            " callback=None , validate=None), foo=<class "
            "'dlapp.configuration.ConfigPropertyRecordExt'>(foo , 5 ,"
            " callback=None , validate=None), name='foo')")
     self.assertEqual(act, exp)
Ejemplo n.º 9
0
 def test_namespace04(self):
     '''
     Clear the singleton configuration manager.
     Get a configuration namespace (triggering instantiation of a
     new configuration manager).
     Use the add_properties() interface.
     Test the correct properties were added.
     '''
     log = logging.getLogger(__name__)
     log.debug("BEGIN: unittest.TestCase.id=%r", unittest.TestCase.id(self))
     name = 'foo'
     cr = configuration.ConfigNamespace(name, foo={'value': 5}, bar=7)
     eok = False
     try:
         cr.has_property('!bad')
     except ConfigPropertyBadName:
         eok = True
     self.assertTrue(eok)
Ejemplo n.º 10
0
 def test_namespace02(self):
     '''
     Clear the singleton configuration manager.
     Get a configuration namespace (triggering instantiation of a
     new configuration manager).
     Add a property record without value, callable or validate arguments.
     Test the exception raised when a configuration record value is
     unset and the value is read.
     '''
     log = logging.getLogger(__name__)
     log.debug("BEGIN: unittest.TestCase.id=%r", unittest.TestCase.id(self))
     name = '!badname'
     eok = False
     try:
         configuration.ConfigNamespace(name)
     except ConfigNamespaceBadName:
         eok = True
     self.assertTrue(eok)