From 076d514cd24c99ace54cf10c16ae10064de0a4a1 Mon Sep 17 00:00:00 2001 From: Marc Hulsman Date: Thu, 12 Jun 2014 22:49:53 +0100 Subject: [PATCH] Add unit test for treemodel nodes --- gramps/gui/views/treemodels/test/__init__.py | 0 gramps/gui/views/treemodels/test/node_test.py | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 gramps/gui/views/treemodels/test/__init__.py create mode 100644 gramps/gui/views/treemodels/test/node_test.py diff --git a/gramps/gui/views/treemodels/test/__init__.py b/gramps/gui/views/treemodels/test/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/gramps/gui/views/treemodels/test/node_test.py b/gramps/gui/views/treemodels/test/node_test.py new file mode 100644 index 000000000..73d88091b --- /dev/null +++ b/gramps/gui/views/treemodels/test/node_test.py @@ -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()