Fix expected_data
expected_data would fail in combination with Intent tests, this
differentiates it from the other rules
Add message type as "__type__" in the data for processing using
expected_data.
@@ -250,6 +250,9 @@ class SkillTest(object):
while not evaluation_rule.all_succeeded():
try:
event = q.get(timeout=1)
+ if ':' in event.type:
+ event.data['__type__'] = event.type.split(':')[1]
+ else:
event.data['__type__'] = event.type
evaluation_rule.evaluate(event.data)
@@ -310,8 +313,10 @@ class EvaluationRule(object):
# Check for expected data structure
if test_case.get('expected_data'):
+ _d = ['and']
for item in test_case['expected_data'].items():
- _x.append(['equal', str(item[0]), str(item[1])])
+ _d.append(['equal', str(item[0]), str(item[1])])
+ self.rule.append(_d)
if _x != ['and']:
self.rule.append(_x)
@@ -388,7 +393,6 @@ class EvaluationRule(object):
Returns:
Bool: True if a partial evaluation succeeded
"""
-
if rule[0] == 'equal':
if self._get_field_value(rule[1], msg) != rule[2]:
return False
