示例#1
0
 def test_available_keys(self):
     cb = ConfigBlock()
     cb.set_value("foo", 1)
     cb.set_value('bar', 'baz')
     r = cb.available_keys()
     nose.tools.assert_set_equal(set(r), {'foo', 'bar'},
                                 "Returned key list was incorrect.")
示例#2
0
    def test_write_fail(self):
        cb = ConfigBlock()
        cb.set_value('foo', 'bar')

        nose.tools.assert_raises(VitalConfigBlockIoException,
                                 cb.write,
                                 '/not/valid')
示例#3
0
 def test_read_only_unset(self):
     cb = ConfigBlock()
     cb.set_value('a', '1')
     cb.mark_read_only('a')
     cb.unset_value('a')
     nose.tools.assert_true(cb.has_value('a'))
     nose.tools.assert_equal(cb.get_value('a'), '1')
示例#4
0
 def test_read_only_unset(self):
     cb = ConfigBlock()
     cb.set_value('a', '1')
     cb.mark_read_only('a')
     cb.unset_value('a')
     nose.tools.assert_true(cb.has_value('a'))
     nose.tools.assert_equal(cb.get_value('a'), '1')
示例#5
0
    def test_write_fail(self):
        cb = ConfigBlock()
        cb.set_value('foo', 'bar')

        nose.tools.assert_raises(VitalConfigBlockIoException,
                                 cb.write,
                                 '/not/valid')
示例#6
0
    def get_configuration(self):
        """
        :return: the current tool configuration
        :rtype: ConfigBlock
        """
        c = ConfigBlock("track_features")
        c.set_value(
            "image_list_file",
            self.image_list_filepath or "",
            "Path to an input file containing new-line separated paths " "to sequential image files",
        )
        c.set_value(
            "mask_list_file",
            self.mask_list_filepath or "",
            "Optional path to an input file containing new-line "
            "separated paths to mask images. This list should be "
            "parallel in association to files specified in "
            "``image_list_file``. Mask image must be the same size as "
            "the image they are associated with.\n"
            "\n"
            "Leave this blank if no image masking is desired.",
        )
        c.set_value(
            "invert_masks",
            str(self.invert_masks).lower(),
            "If true, all mask images will be inverted after loading. "
            "This is useful if mask images read in use positive "
            "values to indicated masked areas instead of non-masked "
            "areas.",
        )
        c.set_value(
            "expect_multichannel_masks",
            str(self.expect_multichannel_masks).lower(),
            "A majority of the time, mask images are a single channel, "
            "however it is feasibly possible that certain "
            "implementations may use multi-channel masks. If this is "
            "true we will expect multiple-channel mask images, "
            "warning when a single-channel mask is provided. If this "
            "is false we error upon seeing a multi-channel mask "
            "image.",
        )
        c.set_value(
            "output_tracks_file",
            self.output_tracks_filepath or "",
            "Path to a file to write output tracks to. If this " "file exists, it will be overwritten.",
        )
        # Required algorithm does not have an implemented interface yet
        # c.set_value("output_homography_file",
        #             self.output_homography_filepath or "",
        #             "Optional path to a file to write source-to-reference "
        #             "homographies for each frame. Leave blank to disable this "
        #             "output. The output_homography_generator algorithm type "
        #             "only needs to be set if this is set.")

        self.algo_convert_img.get_config(c)
        self.algo_image_io.get_config(c)
        self.algo_track_features.get_config(c)

        return c
示例#7
0
 def test_read_only_unset(self):
     cb = ConfigBlock()
     cb.set_value('a', '1')
     cb.mark_read_only('a')
     nose.tools.assert_raises(VitalConfigBlockReadOnlyException,
                              cb.unset_value, 'a')
     nose.tools.assert_true(cb.has_value('a'))
     nose.tools.assert_equal(cb.get_value('a'), '1')
示例#8
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)
示例#9
0
    def test_read_only(self):
        cb = ConfigBlock()

        cb.set_value('a', '1')
        cb.mark_read_only('a')
        nose.tools.assert_equal(cb.get_value('a'), '1')
        cb.set_value('a', '2')
        nose.tools.assert_equal(cb.get_value('a'), '1')
示例#10
0
    def test_read_only(self):
        cb = ConfigBlock()

        cb.set_value('a', '1')
        cb.mark_read_only('a')
        nose.tools.assert_equal(cb.get_value('a'), '1')
        cb.set_value('a', '2')
        nose.tools.assert_equal(cb.get_value('a'), '1')
示例#11
0
 def test_available_keys(self):
     cb = ConfigBlock()
     cb.set_value("foo", 1)
     cb.set_value('bar', 'baz')
     r = cb.available_keys()
     nose.tools.assert_set_equal(set(r),
                                 {'foo', 'bar'},
                                 "Returned key list was incorrect.")
示例#12
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)
示例#13
0
    def test_get_value(self):
        cb = ConfigBlock()

        cb.set_value('a', 'b')
        cb.set_value('longer_value:foo', "BarBazThing")

        nose.tools.assert_equal(cb.get_value('a'), 'b')
        nose.tools.assert_equal(cb.get_value('longer_value:foo'),
                                'BarBazThing')
示例#14
0
    def test_get_value(self):
        cb = ConfigBlock()

        cb.set_value('a', 'b')
        cb.set_value('longer_value:foo', "BarBazThing")

        nose.tools.assert_equal(cb.get_value('a'), 'b')
        nose.tools.assert_equal(cb.get_value('longer_value:foo'),
                                'BarBazThing')
示例#15
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)
示例#16
0
    def test_set_conf(self):
        ci = ConvertImage('ci')
        nt.assert_false(ci)
        nt.assert_is_none(ci.impl_name())

        c = ConfigBlock()
        c.set_value('ci:type', 'bypass')
        ci.set_config(c)
        nt.assert_true(ci)
        nt.assert_equal(ci.impl_name(), 'bypass')
示例#17
0
 def test_read_only_unset(self):
     cb = ConfigBlock()
     cb.set_value('a', '1')
     cb.mark_read_only('a')
     nose.tools.assert_raises(
         VitalConfigBlockReadOnlyException,
         cb.unset_value, 'a'
     )
     nose.tools.assert_true(cb.has_value('a'))
     nose.tools.assert_equal(cb.get_value('a'), '1')
    def test_check_conf(self):
        ci = ConvertImage('ci')
        c = ConfigBlock()
        nt.assert_false(ci.check_config(c))

        c.set_value('ci:type', '')
        nt.assert_false(ci.check_config(c))

        c.set_value('ci:type', 'not_an_impl')
        nt.assert_false(ci.check_config(c))
示例#19
0
    def test_set_conf(self):
        ci = ConvertImage('ci')
        nt.assert_false(ci)
        nt.assert_is_none(ci.impl_name())

        c = ConfigBlock()
        c.set_value('ci:type', 'bypass')
        ci.set_config(c)
        nt.assert_true(ci)
        nt.assert_equal(ci.impl_name(), 'bypass')
示例#20
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)
示例#21
0
    def test_check_conf(self):
        ci = ConvertImage('ci')
        c = ConfigBlock()
        nt.assert_false(ci.check_config(c))

        c.set_value('ci:type', '')
        nt.assert_false(ci.check_config(c))

        c.set_value('ci:type', 'not_an_impl')
        nt.assert_false(ci.check_config(c))
示例#22
0
    def get_configuration(self):
        """
        :return: the current tool configuration
        :rtype: ConfigBlock
        """
        c = ConfigBlock("track_features")
        c.set_value(
            "image_list_file", self.image_list_filepath or "",
            "Path to an input file containing new-line separated paths "
            "to sequential image files")
        c.set_value(
            "mask_list_file", self.mask_list_filepath or "",
            "Optional path to an input file containing new-line "
            "separated paths to mask images. This list should be "
            "parallel in association to files specified in "
            "``image_list_file``. Mask image must be the same size as "
            "the image they are associated with.\n"
            "\n"
            "Leave this blank if no image masking is desired.")
        c.set_value(
            "invert_masks",
            str(self.invert_masks).lower(),
            "If true, all mask images will be inverted after loading. "
            "This is useful if mask images read in use positive "
            "values to indicated masked areas instead of non-masked "
            "areas.")
        c.set_value(
            "expect_multichannel_masks",
            str(self.expect_multichannel_masks).lower(),
            "A majority of the time, mask images are a single channel, "
            "however it is feasibly possible that certain "
            "implementations may use multi-channel masks. If this is "
            "true we will expect multiple-channel mask images, "
            "warning when a single-channel mask is provided. If this "
            "is false we error upon seeing a multi-channel mask "
            "image.")
        c.set_value(
            "output_tracks_file", self.output_tracks_filepath or "",
            "Path to a file to write output tracks to. If this "
            "file exists, it will be overwritten.")
        # Required algorithm does not have an implemented interface yet
        # c.set_value("output_homography_file",
        #             self.output_homography_filepath or "",
        #             "Optional path to a file to write source-to-reference "
        #             "homographies for each frame. Leave blank to disable this "
        #             "output. The output_homography_generator algorithm type "
        #             "only needs to be set if this is set.")

        self.algo_convert_img.get_config(c)
        self.algo_image_io.get_config(c)
        self.algo_track_features.get_config(c)

        return c
示例#23
0
    def test_unset_value(self):
        cb = ConfigBlock()

        cb.set_value('a', '1')
        cb.set_value('b', '2')

        cb.unset_value('a')

        nose.tools.assert_false(cb.has_value('a'))
        nose.tools.assert_is_none(cb.get_value('a'))

        nose.tools.assert_equal(cb.get_value('b'), '2')
        nose.tools.assert_true(cb.has_value('b'))
示例#24
0
    def test_get_value_nested(self):
        cb = ConfigBlock()

        k1 = 'a'
        k2 = 'b'
        v = 'c'

        cb.set_value(k1 + ConfigBlock.BLOCK_SEP + k2, v)
        nose.tools.assert_equal(cb.get_value(k1 + ConfigBlock.BLOCK_SEP + k2),
                                v)

        sb = cb.subblock(k1)
        nose.tools.assert_equal(sb.get_value(k2), v)
示例#25
0
    def test_get_value_nested(self):
        cb = ConfigBlock()

        k1 = 'a'
        k2 = 'b'
        v = 'c'

        cb.set_value(k1 + ConfigBlock.BLOCK_SEP + k2, v)
        nose.tools.assert_equal(cb.get_value(k1 + ConfigBlock.BLOCK_SEP + k2),
                                v)

        sb = cb.subblock(k1)
        nose.tools.assert_equal(sb.get_value(k2), v)
示例#26
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})
示例#27
0
    def test_unset_value(self):
        cb = ConfigBlock()

        cb.set_value('a', '1')
        cb.set_value('b', '2')

        cb.unset_value('a')

        nose.tools.assert_false(cb.has_value('a'))
        nose.tools.assert_raises(VitalConfigBlockNoSuchValueException,
                                 cb.get_value, 'a')

        nose.tools.assert_equal(cb.get_value('b'), '2')
        nose.tools.assert_true(cb.has_value('b'))
示例#28
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})
示例#29
0
    def test_unset_value(self):
        cb = ConfigBlock()

        cb.set_value('a', '1')
        cb.set_value('b', '2')

        cb.unset_value('a')

        nose.tools.assert_false(cb.has_value('a'))
        nose.tools.assert_raises(
            VitalConfigBlockNoSuchValueException,
            cb.get_value, 'a'
        )

        nose.tools.assert_equal(cb.get_value('b'), '2')
        nose.tools.assert_true(cb.has_value('b'))
示例#30
0
    def test_merge_config(self):
        cb1 = ConfigBlock()
        cb2 = ConfigBlock()
        ka = 'ka'
        kb = 'kb'
        kc = 'kc'
        va = 'va'
        vb = 'vb'
        vc = 'vc'

        cb1.set_value(ka, va)
        cb1.set_value(kb, va)
        cb2.set_value(kb, vb)
        cb2.set_value(kc, vc)

        cb1.merge_config(cb2)

        nose.tools.assert_equal(cb1.get_value(ka), va)
        nose.tools.assert_equal(cb1.get_value(kb), vb)
        nose.tools.assert_equal(cb1.get_value(kc), vc)
示例#31
0
    def test_merge_config(self):
        cb1 = ConfigBlock()
        cb2 = ConfigBlock()
        ka = 'ka'
        kb = 'kb'
        kc = 'kc'
        va = 'va'
        vb = 'vb'
        vc = 'vc'

        cb1.set_value(ka, va)
        cb1.set_value(kb, va)
        cb2.set_value(kb, vb)
        cb2.set_value(kc, vc)

        cb1.merge_config(cb2)

        nose.tools.assert_equal(cb1.get_value(ka), va)
        nose.tools.assert_equal(cb1.get_value(kb), vb)
        nose.tools.assert_equal(cb1.get_value(kc), vc)
示例#32
0
    def test_image_load_save_diff(self):
        fd, tmp_filename = tempfile.mkstemp()

        c = ConfigBlock()
        c.set_value('iio:type', 'vxl')
        iio = ImageIo('iio')
        iio.set_config(c)

        nt.assert_true(osp.isfile(self.test_image_filepath),
                       "Couldn't find image file")
        ic_orig = iio.load(self.test_image_filepath)
        iio.save(ic_orig, tmp_filename)
        ic_test = iio.load(tmp_filename)

        nt.assert_equal(ic_orig.size(), ic_test.size())
        nt.assert_equal(ic_orig.width(), ic_test.width())
        nt.assert_equal(ic_orig.height(), ic_test.height())
        nt.assert_equal(ic_orig.depth(), ic_test.depth())

        os.remove(tmp_filename)
        os.close(fd)
示例#33
0
    def test_subblock_nested(self):
        cb = ConfigBlock()

        block_name = 'block'
        other_name = 'other'
        nestd_name = block_name + ConfigBlock.BLOCK_SEP + other_name

        ka = 'ka'
        kb = 'kb'
        va = 'va'
        vb = 'vb'

        cb.set_value(nestd_name + ConfigBlock.BLOCK_SEP + ka, va)
        cb.set_value(nestd_name + ConfigBlock.BLOCK_SEP + kb, vb)

        sb = cb.subblock(nestd_name)

        nose.tools.assert_true(sb.has_value(ka))
        nose.tools.assert_equal(sb.get_value(ka), va)
        nose.tools.assert_true(sb.has_value(kb))
        nose.tools.assert_equal(sb.get_value(kb), vb)
示例#34
0
    def test_subblock_nested(self):
        cb = ConfigBlock()

        block_name = 'block'
        other_name = 'other'
        nestd_name = block_name + ConfigBlock.BLOCK_SEP + other_name

        ka = 'ka'
        kb = 'kb'
        va = 'va'
        vb = 'vb'

        cb.set_value(nestd_name + ConfigBlock.BLOCK_SEP + ka, va)
        cb.set_value(nestd_name + ConfigBlock.BLOCK_SEP + kb, vb)

        sb = cb.subblock(nestd_name)

        nose.tools.assert_true(sb.has_value(ka))
        nose.tools.assert_equal(sb.get_value(ka), va)
        nose.tools.assert_true(sb.has_value(kb))
        nose.tools.assert_equal(sb.get_value(kb), vb)
示例#35
0
    def test_image_load_save_diff(self):
        fd, tmp_filename = tempfile.mkstemp()

        c = ConfigBlock()
        c.set_value('iio:type', 'vxl')
        iio = ImageIo('iio')
        iio.set_config(c)

        nt.assert_true(osp.isfile(self.test_image_filepath),
                       "Couldn't find image file")
        ic_orig = iio.load(self.test_image_filepath)
        iio.save(ic_orig, tmp_filename)
        ic_test = iio.load(tmp_filename)

        nt.assert_equal(ic_orig.size(), ic_test.size())
        nt.assert_equal(ic_orig.width(), ic_test.width())
        nt.assert_equal(ic_orig.height(), ic_test.height())
        nt.assert_equal(ic_orig.depth(), ic_test.depth())

        os.remove(tmp_filename)
        os.close(fd)
示例#36
0
def default_config_block():
    c = ConfigBlock()

    c.set_value(
        'image_list_file', '',
        'Path to an input file containing new-line separated paths to '
        'sequential image files')
    c.set_value(
        'mask_list_file', '',
        'Optional path to an input file containing new-line '
        'separated paths to mask images. This list should be '
        'parallel in association to files specified in '
        '``image_list_file``. Mask image must be the same size as '
        'the image they are associated with.\n'
        '\n'
        'Leave this blank if no image masking is desired.')
    c.set_value(
        'output_tracks_file', '',
        'Path to a file to write output tracks to. If this file '
        'exists, it will be overwritten.')

    image_reader, image_converter, feature_tracker = base_algorithms()
    image_reader.get_config(c)
    image_converter.get_config(c)
    feature_tracker.get_config(c)

    return c
示例#37
0
def default_config_block():
    c = ConfigBlock()

    c.set_value('image_list_file',
                '',
                'Path to an input file containing new-line separated paths to '
                'sequential image files')
    c.set_value('mask_list_file',
                '',
                'Optional path to an input file containing new-line '
                'separated paths to mask images. This list should be '
                'parallel in association to files specified in '
                '``image_list_file``. Mask image must be the same size as '
                'the image they are associated with.\n'
                '\n'
                'Leave this blank if no image masking is desired.')
    c.set_value('output_tracks_file',
                '',
                'Path to a file to write output tracks to. If this file '
                'exists, it will be overwritten.')

    image_reader, image_converter, feature_tracker = base_algorithms()
    image_reader.get_config(c)
    image_converter.get_config(c)
    feature_tracker.get_config(c)

    return c
示例#38
0
    def test_get_value_bool(self):
        cb = ConfigBlock()

        cb.set_value('a', 'true')
        nose.tools.assert_true(cb.get_value_bool('a'))

        cb.set_value('b', 'false')
        nose.tools.assert_false(cb.get_value_bool('b'))

        cb.set_value('a', 'yes')
        nose.tools.assert_true(cb.get_value_bool('a'))

        cb.set_value('b', 'no')
        nose.tools.assert_false(cb.get_value_bool('b'))
示例#39
0
    def test_get_value_bool(self):
        cb = ConfigBlock()

        cb.set_value('a', 'true')
        nose.tools.assert_true(cb.get_value_bool('a'))

        cb.set_value('b', 'false')
        nose.tools.assert_false(cb.get_value_bool('b'))

        cb.set_value('a', 'yes')
        nose.tools.assert_true(cb.get_value_bool('a'))

        cb.set_value('b', 'no')
        nose.tools.assert_false(cb.get_value_bool('b'))
示例#40
0
 def test_set_value(self):
     cb = ConfigBlock()
     # Basic value string
     cb.set_value('foo', 'bar')
     # Should attempt casting non-string to string
     cb.set_value('bar', 124789)
     # Setting with a description
     cb.set_value('baz', 'a', "This is a description")
示例#41
0
 def test_set_value(self):
     cb = ConfigBlock()
     # Basic value string
     cb.set_value('foo', 'bar')
     # Should attempt casting non-string to string
     cb.set_value('bar', 124789)
     # Setting with a description
     cb.set_value('baz', 'a', "This is a description")
示例#42
0
    def test_subblock(self):
        cb = ConfigBlock()

        block_name = 'block'
        other_name = 'other_block'
        ka = 'keya'
        kb = 'keyb'
        kc = 'keyc'
        va = 'va'
        vb = 'vb'
        vc = 'vc'

        cb.set_value(block_name + ConfigBlock.BLOCK_SEP + ka, va)
        cb.set_value(block_name + ConfigBlock.BLOCK_SEP + kb, vb)
        cb.set_value(other_name + ConfigBlock.BLOCK_SEP + kc, vc)

        sb = cb.subblock(block_name)

        nose.tools.assert_true(sb.has_value(ka))
        nose.tools.assert_equal(sb.get_value(ka), va)
        nose.tools.assert_true(sb.has_value(kb))
        nose.tools.assert_equal(sb.get_value(kb), vb)
        nose.tools.assert_false(sb.has_value(kc))
示例#43
0
    def test_subblock(self):
        cb = ConfigBlock()

        block_name = 'block'
        other_name = 'other_block'
        ka = 'keya'
        kb = 'keyb'
        kc = 'keyc'
        va = 'va'
        vb = 'vb'
        vc = 'vc'

        cb.set_value(block_name + ConfigBlock.BLOCK_SEP + ka, va)
        cb.set_value(block_name + ConfigBlock.BLOCK_SEP + kb, vb)
        cb.set_value(other_name + ConfigBlock.BLOCK_SEP + kc, vc)

        sb = cb.subblock(block_name)

        nose.tools.assert_true(sb.has_value(ka))
        nose.tools.assert_equal(sb.get_value(ka), va)
        nose.tools.assert_true(sb.has_value(kb))
        nose.tools.assert_equal(sb.get_value(kb), vb)
        nose.tools.assert_false(sb.has_value(kc))
示例#44
0
    def test_has_value(self):
        cb = ConfigBlock()

        cb.set_value('foo', 'bar')
        cb.set_value('bar', 124789)
        cb.set_value('baz', 'a', "This is a description")

        nose.tools.assert_true(cb.has_value("foo"))
        nose.tools.assert_true(cb.has_value('bar'))
        nose.tools.assert_true(cb.has_value('baz'))

        nose.tools.assert_false(cb.has_value('a'))
        nose.tools.assert_false(cb.has_value('not a value'))
示例#45
0
    def test_has_value(self):
        cb = ConfigBlock()

        cb.set_value('foo', 'bar')
        cb.set_value('bar', 124789)
        cb.set_value('baz', 'a', "This is a description")

        nose.tools.assert_true(cb.has_value("foo"))
        nose.tools.assert_true(cb.has_value('bar'))
        nose.tools.assert_true(cb.has_value('baz'))

        nose.tools.assert_false(cb.has_value('a'))
        nose.tools.assert_false(cb.has_value('not a value'))
示例#46
0
    def test_set_value_description(self):
        cb = ConfigBlock()
        bname = 'sub'
        ka = 'ka'
        kb = 'kb'
        kc = 'kc'
        va = 'va'
        vb = 'vb'
        vc = 'vc'
        da = 'da'
        db = 'db'

        cb.set_value(ka, va, da)
        cb.set_value(bname + ConfigBlock.BLOCK_SEP + kb, vb, db)
        cb.set_value(kc, vc)
        sb = cb.subblock('sub')

        nose.tools.assert_equal(cb.get_description(ka), da)
        nose.tools.assert_equal(sb.get_description(kb), db)
        nose.tools.assert_equal(cb.get_description(kc), "")
示例#47
0
    def test_set_value_description(self):
        cb = ConfigBlock()
        bname = 'sub'
        ka = 'ka'
        kb = 'kb'
        kc = 'kc'
        va = 'va'
        vb = 'vb'
        vc = 'vc'
        da = 'da'
        db = 'db'

        cb.set_value(ka, va, da)
        cb.set_value(bname + ConfigBlock.BLOCK_SEP + kb, vb, db)
        cb.set_value(kc, vc)
        sb = cb.subblock('sub')

        nose.tools.assert_equal(cb.get_description(ka), da)
        nose.tools.assert_equal(sb.get_description(kb), db)
        nose.tools.assert_equal(cb.get_description(kc), "")
示例#48
0
    def test_get_value(self):
        cb = ConfigBlock()

        cb.set_value('a', 'b')
        nose.tools.assert_equal(cb.get_value('a'), 'b')