Merge lp:~jml/libdep-service/update-e2e-check into lp:libdep-service

Proposed by Jonathan Lange
Status: Merged
Approved by: James Westby
Approved revision: 68
Merged at revision: 66
Proposed branch: lp:~jml/libdep-service/update-e2e-check
Merge into: lp:libdep-service
Diff against target: 49 lines (+16/-4)
1 file modified
bin/end-to-end-check (+16/-4)
To merge this branch: bzr merge lp:~jml/libdep-service/update-e2e-check
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+130806@code.launchpad.net

Commit message

Make e2e check more flexible

Description of the change

Uses a matcher for the e2e check so that we aren't constantly baffled
by slight changes in returned data.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/end-to-end-check'
2--- bin/end-to-end-check 2012-09-14 14:34:46 +0000
3+++ bin/end-to-end-check 2012-10-22 12:48:23 +0000
4@@ -2,13 +2,24 @@
5
6 import argparse
7 import json
8+from operator import itemgetter
9 import time
10 import urllib2
11 import sys
12
13+from testtools.matchers import (
14+ AfterPreprocessing,
15+ Contains,
16+ KeysEqual,
17+ MatchesAll,
18+ )
19+
20
21 QUERY = 'libs=libc.so.6&libs=notalibrary'
22-RESULT = {"libc.so.6": ["libc6", "libc6 (>= 2.13)", "libc6-amd64", "libc6-i386"]}
23+# Using only testtools 0.9.14 matchers, as that's what's on emim.
24+RESULT = MatchesAll(
25+ KeysEqual('libc.so.6'),
26+ AfterPreprocessing(itemgetter('libc.so.6'), Contains('libc6')))
27
28
29 def make_arg_parser():
30@@ -39,15 +50,16 @@
31 return json.loads(result)
32
33
34-def check_query_results(warn_duration, error_duration, expected_result,
35+def check_query_results(warn_duration, error_duration, result_matcher,
36 function, *args, **kwargs):
37 start_time = time.time()
38 result = function(*args, **kwargs)
39 duration = time.time() - start_time
40+ mismatch = result_matcher.match(result)
41 # XXX: If we could guarantee matchers gave a one-line output, we would
42 # probably use matchers for this rather than assuming simple equality.
43- if result != expected_result:
44- return 2, "ERROR: Got %r, expected %r" % (result, expected_result)
45+ if mismatch:
46+ return 2, "ERROR: %s" % (mismatch.describe().replace('\n', '; '),)
47 elif duration > error_duration:
48 return 2, "ERROR: Check took %0.3fs. Must be less than %0.3fs" % (
49 duration, error_duration)

Subscribers

People subscribed via source and target branches