Skip to content

Commit

Permalink
Updated duplicate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
keiffster committed Jul 5, 2017
1 parent b9cebdc commit 3cc7f08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
19 changes: 0 additions & 19 deletions src/programy/parser/pattern/nodes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,25 +282,6 @@ def _node_exists(self, new_node):
if existing_node.equivalent(new_node):
# Equivalent node already exists, use this one instead
return existing_node
"""
# TODO Test for set and word with the same name
# Will fail, need to store sets and words in different containers
if new_node.is_set:
for node in self._children:
if node.is_set:
if node.equivalent(new_node):
# Equivalent node already exists, use this one instead
return node
# TODO Test for bot and word with the same name
# Will fail, need to store bots and words in different containers
if new_node.is_bot:
for node in self._children:
if node.is_bot:
if node.equivalent(new_node):
# Equivalent node already exists, use this one instead
return node
"""

if new_node.is_word():
if new_node.word in self._children_words:
Expand Down
13 changes: 12 additions & 1 deletion src/test/parser/pattern/test_graph_duplicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
from programy.parser.exceptions import DuplicateGrammarException
from programy.parser.pattern.graph import PatternGraph
from programy.parser.template.nodes.base import TemplateNode
from programy.parser.pattern.nodes.bot import PatternBotNode
from programy.parser.pattern.nodes.word import PatternWordNode


class PatternGraphTests(PatternTestBaseClass):
class PatternGraphDuplicateTests(PatternTestBaseClass):

def test_duplicate_pattern(self):
graph = PatternGraph()
Expand Down Expand Up @@ -252,3 +254,12 @@ def test_duplicate_bot_and_word_otherwayround(self):
template_node = TemplateNode()

graph.add_pattern_to_graph(pattern_element, topic_element, that_element, template_node)

self.assertIsNotNone(graph.root.children)
self.assertEqual(2, len(graph.root.children))
self.assertIsInstance(graph.root.children[0], PatternWordNode)
self.assertIsInstance(graph.root.children[1], PatternBotNode)

self.assertEqual(1, len(graph.root._bot_properties))
values = graph.root._bot_properties.values()
self.assertIsInstance(list(values)[0], PatternBotNode)

0 comments on commit 3cc7f08

Please sign in to comment.