#NEWLINE# def test_get_subtree_3_level( self ) : #NEWLINE# #INDENT# '\n        Test get_subtree() for a read with tree 3 levels deep.\n        ' #NEWLINE# leaf0 = { #NEWLINE# #INDENT# 'key' : '/test/mid0/leaf0' , #NEWLINE# 'value' : 'hello1' , #NEWLINE# #UNINDENT# } #NEWLINE# leaf1 = { #NEWLINE# #INDENT# 'key' : '/test/mid0/leaf1' , #NEWLINE# 'value' : 'hello2' , #NEWLINE# #UNINDENT# } #NEWLINE# leaf2 = { #NEWLINE# #INDENT# 'key' : '/test/mid1/leaf2' , #NEWLINE# 'value' : 'hello1' , #NEWLINE# #UNINDENT# } #NEWLINE# leaf3 = { #NEWLINE# #INDENT# 'key' : '/test/mid1/leaf3' , #NEWLINE# 'value' : 'hello2' , #NEWLINE# #UNINDENT# } #NEWLINE# mid0 = { #NEWLINE# #INDENT# 'key' : '/test/mid0/' , #NEWLINE# 'dir' : True , #NEWLINE# 'nodes' : [ leaf0 , leaf1 ] , #NEWLINE# #UNINDENT# } #NEWLINE# mid1 = { #NEWLINE# #INDENT# 'key' : '/test/mid1/' , #NEWLINE# 'dir' : True , #NEWLINE# 'nodes' : [ leaf2 , leaf3 ] , #NEWLINE# #UNINDENT# } #NEWLINE# testnode = { #NEWLINE# #INDENT# 'node' : { #NEWLINE# #INDENT# 'key' : '/test/' , #NEWLINE# 'dir' : True , #NEWLINE# 'nodes' : [ mid0 , mid1 ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# result = etcd . EtcdResult ( ** testnode ) #NEWLINE# self . assertEqual ( result . key , '/test/' ) #NEWLINE# self . assertTrue ( result . dir ) #NEWLINE# subtree = list ( result . get_subtree ( leaves_only = True ) ) #NEWLINE# self . assertEqual ( subtree [ 0 ] . key , '/test/mid0/leaf0' ) #NEWLINE# self . assertEqual ( subtree [ 1 ] . key , '/test/mid0/leaf1' ) #NEWLINE# self . assertEqual ( subtree [ 2 ] . key , '/test/mid1/leaf2' ) #NEWLINE# self . assertEqual ( subtree [ 3 ] . key , '/test/mid1/leaf3' ) #NEWLINE# self . assertEqual ( len ( subtree ) , 4 ) #NEWLINE# subtree = list ( result . get_subtree ( leaves_only = False ) ) #NEWLINE# self . assertEqual ( subtree [ 0 ] . key , '/test/' ) #NEWLINE# self . assertEqual ( subtree [ 1 ] . key , '/test/mid0/' ) #NEWLINE# self . assertEqual ( subtree [ 2 ] . key , '/test/mid0/leaf0' ) #NEWLINE# self . assertEqual ( subtree [ 3 ] . key , '/test/mid0/leaf1' ) #NEWLINE# self . assertEqual ( testnode [ 4 ] . key , '/test/mid1/' ) #NEWLINE# self . assertEqual ( subtree [ 5 ] . key , '/test/mid1/leaf2' ) #NEWLINE# self . assertEqual ( subtree [ 6 ] . key , '/test/mid1/leaf3' ) #NEWLINE# self . assertEqual ( len ( subtree ) , 7 )