Add unit test for treemodel nodes
This commit is contained in:
parent
f3566ebc34
commit
aeda10a3fe
0
gramps/gui/views/treemodels/test/__init__.py
Normal file
0
gramps/gui/views/treemodels/test/__init__.py
Normal file
47
gramps/gui/views/treemodels/test/node_test.py
Normal file
47
gramps/gui/views/treemodels/test/node_test.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#
|
||||||
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
|
#
|
||||||
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from ..treebasemodel import Node, NodeMap
|
||||||
|
|
||||||
|
class NodeTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_addremovechildren(self):
|
||||||
|
n = Node('1', '', 'key_to_sort_on', None, None)
|
||||||
|
nm = NodeMap()
|
||||||
|
nm.add_node(n)
|
||||||
|
|
||||||
|
n2 = Node('2', '', 'key_to_sort_on2', None, None)
|
||||||
|
n.add_child(n2, nm)
|
||||||
|
nm.add_node(n2)
|
||||||
|
|
||||||
|
n3 = Node('2', '', '', None, None)
|
||||||
|
n.add_child(n3, nm)
|
||||||
|
nm.add_node(n3)
|
||||||
|
|
||||||
|
n.remove_child(n3, nm)
|
||||||
|
nm.del_node(n3)
|
||||||
|
n.remove_child(n2, nm)
|
||||||
|
nm.del_node(n2)
|
||||||
|
self.assertEqual(len(n.children), 0)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user