Ejemplo n.º 1
0
 def test_006_lookup_defaulting(self):
     nvlist = NVList()
     default = random.randint(32, 128)
     with nvlist:
         found = nvlist.lookup_smart('this_key_should_not_be_available',
                                     default=default)
         assert found == default
Ejemplo n.º 2
0
    def test_004_add_lookup_smart(self):
        length = random.randint(32, 128)
        items = {
            'int': [random.randint(1, 65535), data_type_t.DATA_TYPE_UINT64],
            'string': [''.join([random.choice(string.ascii_letters) for x in range(length)]), data_type_t.DATA_TYPE_STRING],
            'bool': [bool(random.randint(0, 1)), data_type_t.DATA_TYPE_BOOLEAN]
        }

        nvlist = NVList()
        with nvlist:
            print "Adding items"
            for iname, data in items.items():
                nvlist.add(iname, data[1], data[0])
            print "Retreiving items"
            for iname, data in items.items():
                print "Checking: %s ( %r )" % (iname, data[0])
                value = nvlist.lookup_smart(iname, default=-1)
                assert value == data[0]
Ejemplo n.º 3
0
    def test_004_add_lookup_smart(self):
        length = random.randint(32, 128)
        items = {
            'int': [random.randint(1, 65535), data_type_t.DATA_TYPE_UINT64],
            'string': [
                ''.join([
                    random.choice(string.ascii_letters) for x in range(length)
                ]), data_type_t.DATA_TYPE_STRING
            ],
            'bool':
            [bool(random.randint(0, 1)), data_type_t.DATA_TYPE_BOOLEAN]
        }

        nvlist = NVList()
        with nvlist:
            print "Adding items"
            for iname, data in items.items():
                nvlist.add(iname, data[1], data[0])
            print "Retreiving items"
            for iname, data in items.items():
                print "Checking: %s ( %r )" % (iname, data[0])
                value = nvlist.lookup_smart(iname, default=-1)
                assert value == data[0]
Ejemplo n.º 4
0
 def test_005_lookup_unknown_key(self):
     nvlist = NVList()
     with nvlist:
         nvlist.lookup_smart('this_key_should_not_be_available')
Ejemplo n.º 5
0
 def test_006_lookup_defaulting(self):
     nvlist = NVList()
     default = random.randint(32, 128)
     with nvlist:
         found = nvlist.lookup_smart('this_key_should_not_be_available', default=default)
         assert found == default
Ejemplo n.º 6
0
 def test_005_lookup_unknown_key(self):
     nvlist = NVList()
     with nvlist:
         nvlist.lookup_smart('this_key_should_not_be_available')