Revision 9c709b31 test/ganeti.utils.algo_unittest.py
b/test/ganeti.utils.algo_unittest.py | ||
---|---|---|
339 | 339 |
[(i, ) for i in range(200)] + [(10, )]) |
340 | 340 |
|
341 | 341 |
|
342 |
class TestFlatToDict(unittest.TestCase): |
|
343 |
def testNormal(self): |
|
344 |
data = [ |
|
345 |
("lv/xenvg", {"foo": "bar", "bar": "baz"}), |
|
346 |
("lv/xenfoo", {"foo": "bar", "baz": "blubb"}), |
|
347 |
("san/foo", {"ip": "127.0.0.1", "port": 1337}), |
|
348 |
("san/blubb/blibb", 54), |
|
349 |
] |
|
350 |
reference = { |
|
351 |
"lv": { |
|
352 |
"xenvg": {"foo": "bar", "bar": "baz"}, |
|
353 |
"xenfoo": {"foo": "bar", "baz": "blubb"}, |
|
354 |
}, |
|
355 |
"san": { |
|
356 |
"foo": {"ip": "127.0.0.1", "port": 1337}, |
|
357 |
"blubb": {"blibb": 54}, |
|
358 |
}, |
|
359 |
} |
|
360 |
self.assertEqual(algo.FlatToDict(data), reference) |
|
361 |
|
|
362 |
def testUnlikeDepth(self): |
|
363 |
data = [ |
|
364 |
("san/foo", {"ip": "127.0.0.1", "port": 1337}), |
|
365 |
("san/foo/blubb", 23), # Another foo entry under san |
|
366 |
("san/blubb/blibb", 54), |
|
367 |
] |
|
368 |
self.assertRaises(AssertionError, algo.FlatToDict, data) |
|
369 |
|
|
370 |
|
|
342 | 371 |
if __name__ == "__main__": |
343 | 372 |
testutils.GanetiTestProgram() |
Also available in: Unified diff