Skip to content

Commit

Permalink
#91 increase test coverage for node
Browse files Browse the repository at this point in the history
  • Loading branch information
akorosov committed Mar 9, 2018
1 parent 0f2fc9d commit fac580a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
25 changes: 0 additions & 25 deletions nansat/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,31 +169,6 @@ def delNode(self, tag, options=None):
for i in sorted(ideleted, reverse=True):
self.children.pop(i)

def find_dom_child(self, dom, tagName, n=0):
'''Recoursively find child of the dom'''
children = dom.childNodes
theChild = None

chn = 0
for child in children:
print(child, child.nodeType, chn)
if child.nodeType == 1:
print(child.tagName)
if str(child.tagName) == tagName:
print(child.tagName, tagName, 'OK')
if chn == n:
theChild = child
chn += 1

if theChild is not None:
break

if child.hasChildNodes():
print('has childs')
theChild = self.find_dom_child(child, tagName, n)

return theChild

def nodeList(self, tag):
'''
Produce a list of subnodes with the same tag.
Expand Down
13 changes: 13 additions & 0 deletions nansat/tests/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ def test_creation(self):
tag = 'Root'
value = ' Value '
anAttr = 'elValue'
new_value = 'New Value'
node = Node(tag, value=value, anAttr=anAttr)
self.assertEqual(node.tag, tag)
self.assertDictEqual(node.attributes, {'anAttr': anAttr})
self.assertEqual(node.value, value.strip())
self.assertEqual(node[tag], value.strip())
node[tag] = new_value
self.assertEqual(node.value, new_value)

def test_getAttributeList(self):
tag = 'Root'
Expand Down Expand Up @@ -145,3 +149,12 @@ def test_search_node(self):
root += firstLevel3
self.assertEqual(root.node(firstLevelTag,0), firstLevel)
self.assertEqual(root.node(firstLevelTag,1), firstLevel2)

def test_str(self):
tag = 'Root'
value = 'Value'
node = Node(tag, value=value)
self.assertEqual(str(node), '%s\n value: [%s]' % (tag, value))

if __name__ == "__main__":
unittest.main()
1 change: 0 additions & 1 deletion nansat/tests/test_vrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,5 @@ def test_make_filename(self):
self.assertTrue(os.path.exists(filename3))



if __name__ == "__main__":
unittest.main()

0 comments on commit fac580a

Please sign in to comment.