-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7aa4b62
commit dde6ed0
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import unittest | ||
|
||
from rail import Tree | ||
|
||
class TestTree(unittest.TestCase): | ||
def setUp(self): | ||
self.tree = Tree(name='test tree') | ||
self.tree.addChild('test child') | ||
|
||
def test_tree(self): | ||
self.assertEqual(self.tree.name, 'test tree') | ||
self.assertEqual(self.tree.parent, None) | ||
self.assertEqual(self.tree['test child'].name, 'test child') | ||
self.assertEqual(self.tree['test child'].parent, self.tree) | ||
|
||
def test_path(self): | ||
self.assertEqual(self.tree['test child'].path(), '/test tree/test child') | ||
|
||
def test_to_dict_list(self): | ||
self.assertEqual(self.tree.to_dict_list(), {'name': 'test tree', 'children': [{'name': 'test child', 'children': []}]}) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|