1 """ Steps that check results.
4 from nose.tools import * # for assert functions
6 def compare(operator, op1, op2):
7 if operator == 'less than':
9 elif operator == 'more than':
11 elif operator == 'exactly':
13 elif operator == 'at least':
15 elif operator == 'at most':
18 raise Exception("unknown operator '%s'" % operator)
20 @step(u'(?P<operator>less than|more than|exactly|at least|at most) (?P<number>\d+) results? (?:is|are) returned')
21 def validate_result_number(context, operator, number):
22 numres = len(context.response.result)
23 ok_(compare(operator, numres, int(number)),
24 "Bad number of results: expected %s %s, got %d." % (operator, number, numres))
27 @then(u'results contain')
28 def step_impl(context):
29 context.execute_steps("then at least 1 result is returned")
31 for line in context.table:
32 context.response.match_row(line)