def test_cache_add(self): tag_name = "torpedo" parent_xpath="/soccer/country/Russia/RFPL/Moscow" json = '[{"title":"Moscow","key":"/soccer/country/Russia/RFPL/Moscow","isFolder":false,"isLazy":false,"tooltip":"/soccer/country/Russia/RFPL/Moscow","href":null,"icon":"","addClass":null,"noLink":false,"activate":true,"focus":false,"expand":true,"select":false,"hideCheckbox":false,"unselectable":false,"children":[{"title":"CSKA","key":"/soccer/country/Russia/RFPL/Moscow/CSKA","isFolder":false,"isLazy":false,"tooltip":"/soccer/country/Russia/RFPL/Moscow/CSKA","href":null,"icon":"","addClass":null,"noLink":false,"activate":false,"focus":false,"expand":true,"select":false,"hideCheckbox":false,"unselectable":false}]}]' cache_tree = CacheTree(json) cache_tree.add_new_node(parent_xpath, tag_name) tree_json = cache_tree.get_json() print("Added '{}' into '{}', JSON:{}".format(tag_name, parent_xpath, tree_json)) self.assertEqual('[{"title": "Moscow", "tooltip": "/soccer/country/Russia/RFPL/Moscow", "key": "/soccer/country/Russia/RFPL/Moscow", "expand": true, "icon": "../../css/warning-icon.png", "children": [{"title": "CSKA", "tooltip": "/soccer/country/Russia/RFPL/Moscow/CSKA", "key": "/soccer/country/Russia/RFPL/Moscow/CSKA", "expand": true, "icon": "", "children": []}, {"title": "torpedo", "tooltip": "/soccer/country/Russia/RFPL/Moscow/torpedo", "key": "/soccer/country/Russia/RFPL/Moscow/torpedo", "expand": true, "icon": "../../css/add-icon.png", "children": []}]}]', tree_json)