示例#1
0
    def test_subblock_view_nested(self):
        cb = ConfigBlock()

        b_name = 'block'
        o_name = 'other_block'
        n_name = b_name + ConfigBlock.BLOCK_SEP + o_name
        ka = 'ka'
        kb = 'kb'
        kc = 'kc'
        va = 'va'
        vb = 'vb'
        vc = 'vc'

        cb.set_value(n_name + ConfigBlock.BLOCK_SEP + ka, va)
        cb.set_value(n_name + ConfigBlock.BLOCK_SEP + kb, vb)
        cb.set_value(o_name + ConfigBlock.BLOCK_SEP + kc, vc)
        sb = cb.subblock_view(n_name)

        nose.tools.assert_true(sb.has_value(ka))
        nose.tools.assert_false(sb.has_value(kc))

        cb.set_value(n_name + ConfigBlock.BLOCK_SEP + ka, vb)
        nose.tools.assert_equal(sb.get_value(ka), vb)
        sb.set_value(ka, va)
        nose.tools.assert_equal(cb.get_value(n_name + ConfigBlock.BLOCK_SEP + ka), va)

        sb.unset_value(kb)
        nose.tools.assert_false(cb.has_value(n_name + ConfigBlock.BLOCK_SEP + kb))

        cb.set_value(n_name + ConfigBlock.BLOCK_SEP + kc, vc)
        sb_keys = sb.available_keys()
        nose.tools.assert_set_equal(set(sb_keys), {ka, kc})
示例#2
0
    def test_subblock_view_nested(self):
        cb = ConfigBlock()

        b_name = 'block'
        o_name = 'other_block'
        n_name = b_name + ConfigBlock.BLOCK_SEP + o_name
        ka = 'ka'
        kb = 'kb'
        kc = 'kc'
        va = 'va'
        vb = 'vb'
        vc = 'vc'

        cb.set_value(n_name + ConfigBlock.BLOCK_SEP + ka, va)
        cb.set_value(n_name + ConfigBlock.BLOCK_SEP + kb, vb)
        cb.set_value(o_name + ConfigBlock.BLOCK_SEP + kc, vc)
        sb = cb.subblock_view(n_name)

        nose.tools.assert_true(sb.has_value(ka))
        nose.tools.assert_false(sb.has_value(kc))

        cb.set_value(n_name + ConfigBlock.BLOCK_SEP + ka, vb)
        nose.tools.assert_equal(sb.get_value(ka), vb)
        sb.set_value(ka, va)
        nose.tools.assert_equal(
            cb.get_value(n_name + ConfigBlock.BLOCK_SEP + ka), va)

        sb.unset_value(kb)
        nose.tools.assert_false(
            cb.has_value(n_name + ConfigBlock.BLOCK_SEP + kb))

        cb.set_value(n_name + ConfigBlock.BLOCK_SEP + kc, vc)
        sb_keys = sb.available_keys()
        nose.tools.assert_set_equal(set(sb_keys), {ka, kc})
示例#3
0
 def test_subblock_view_match(self):
     cb = ConfigBlock()
     bname = 'block'
     va = 'va'
     cb.set_value(bname, va)
     sb = cb.subblock_view(bname)
     keys = sb.available_keys()
     nose.tools.assert_equal(len(keys), 0)
示例#4
0
 def test_subblock_view_match(self):
     cb = ConfigBlock()
     bname = 'block'
     va = 'va'
     cb.set_value(bname, va)
     sb = cb.subblock_view(bname)
     keys = sb.available_keys()
     nose.tools.assert_equal(len(keys), 0)
示例#5
0
 def test_subblock_view_prefix_match(self):
     cb = ConfigBlock()
     bname = 'block'
     ka = 'ka'
     va = 'va'
     # intentionally not adding block separator
     cb.set_value(bname + ka, va)
     sb = cb.subblock_view(bname)
     keys = sb.available_keys()
     nose.tools.assert_equal(len(keys), 0)
示例#6
0
 def test_subblock_view_prefix_match(self):
     cb = ConfigBlock()
     bname = 'block'
     ka = 'ka'
     va = 'va'
     # intentionally not adding block separator
     cb.set_value(bname + ka, va)
     sb = cb.subblock_view(bname)
     keys = sb.available_keys()
     nose.tools.assert_equal(len(keys), 0)