Merge lp:~cmiller/apt-zeroconf/fix-test-failures into lp:apt-zeroconf

Proposed by Chad Miller
Status: Merged
Merged at revision: 133
Proposed branch: lp:~cmiller/apt-zeroconf/fix-test-failures
Merge into: lp:apt-zeroconf
Diff against target: 123 lines (+23/-18)
4 files modified
aptzeroconf/http.py (+1/-1)
aptzeroconf/parse.py (+4/-2)
test/common.py (+3/-3)
test/test_general.py (+15/-12)
To merge this branch: bzr merge lp:~cmiller/apt-zeroconf/fix-test-failures
Reviewer Review Type Date Requested Status
Martin Owens (community) code Approve
Review via email: mp+76921@code.launchpad.net

Description of the change

Tests stopped working in recent Ubuntu or Python versions. Fixed a few style problems that automated tools complained about.

To post a comment you must log in.
Revision history for this message
Martin Owens (doctormo) wrote :

The patch/diff looks good and the test changes are awesome. Should be merged.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'aptzeroconf/http.py'
2--- aptzeroconf/http.py 2009-09-12 02:04:35 +0000
3+++ aptzeroconf/http.py 2011-09-26 00:07:25 +0000
4@@ -145,7 +145,7 @@
5 @trap_socketerror
6 def do_GET(self):
7 self._do_GET()
8-
9+
10 def _do_GET(self):
11 """
12 Respond to a GET request by proxy the url to preferably local content,
13
14=== modified file 'aptzeroconf/parse.py'
15--- aptzeroconf/parse.py 2009-08-09 02:39:51 +0000
16+++ aptzeroconf/parse.py 2011-09-26 00:07:25 +0000
17@@ -28,14 +28,16 @@
18
19 V2, V3 = 0.2, 0.3
20 EPOCH_PATTERN = {
21- V2 : re.compile(r'\_\d+\%3a'),
22- V3 : re.compile(r'\_\d+\:')
23+ V2: re.compile(r'\_\d+\%3a'),
24+ V3: re.compile(r'\_\d+\:'),
25 }
26
27+
28 def normalize_whitespace(text):
29 """Remove excessive whitespace in spaces."""
30 return ' '.join(text.split())
31
32+
33 def _is_equal(pkg, find, ver):
34 """Are the packages equal disregarding the epoch?"""
35 return EPOCH_PATTERN[ver].sub('_', pkg) == find or pkg == find
36
37=== modified file 'test/common.py'
38--- test/common.py 2009-08-09 03:30:29 +0000
39+++ test/common.py 2011-09-26 00:07:25 +0000
40@@ -36,11 +36,11 @@
41 ROOT = str(rootdir)
42
43 DEBNAME = 'test_1.deb'
44-DEBEPOCHNAME = 'test_1%3a1.deb'
45+DEBEPOCHNAME = 'test_1%3A1.deb'
46
47 DEBPROXYURL = (
48- 'archive.ubuntu.com/ubuntu/pool/main/h/hello/hello_2.2-3_i386.deb')
49-DEBFORWARDURL = 'ubuntu/pool/main/h/hello/hello_2.2-3_i386.deb'
50+ 'archive.ubuntu.com/ubuntu/pool/main/h/hello/hello_2.7-1_i386.deb')
51+DEBFORWARDURL = 'ubuntu/pool/main/h/hello/hello_2.7-1_i386.deb'
52
53 PORT = 4796 # random port that probably wont be in use
54
55
56=== modified file 'test/test_general.py'
57--- test/test_general.py 2009-08-09 03:57:29 +0000
58+++ test/test_general.py 2011-09-26 00:07:25 +0000
59@@ -72,16 +72,16 @@
60 touch(path.join(cachedir, DEBNAME), '*contents*')
61
62 with azc_server(str(tmpdir), cachedir, PORT,
63- {('apt-cache', 'test'): 'http://example.com'}) as server:
64- data = urlopen('http://localhost:%i/http://example.com/%s' % (
65+ {('apt-cache', 'test'): 'http://notexist.example.com'}) as server:
66+ data = urlopen('http://localhost:%i/http://notexist.example.com/%s' % (
67 PORT, DEBNAME)).read()
68 # make sure the data is equal
69 assert data == '*contents*'
70
71
72-def test_download_one_epoch_deb(tmpdir):
73+def test_download_one_versionepoch_deb(tmpdir):
74 """
75- Test downloading a deb with an epoch from the local cache.
76+ Test downloading a deb with a version epoch from the local cache.
77 """
78 # cachedir is the directory to serve debs out of
79 cachedir = path.join(str(tmpdir), 'debs')
80@@ -89,8 +89,8 @@
81 touch(path.join(cachedir, DEBEPOCHNAME), '*contents*')
82
83 with azc_server(str(tmpdir), cachedir, PORT,
84- {('apt-cache', 'test'): 'http://example.com'}) as server:
85- data = urlopen('http://localhost:%i/http://example.com/%s' % (
86+ {('apt-cache', 'test'): 'http://notexist.example.com'}) as server:
87+ data = urlopen('http://localhost:%i/http://notexist.example.com/%s' % (
88 PORT, DEBEPOCHNAME)).read()
89 # make sure the data is equal
90 assert data == '*contents*'
91@@ -118,15 +118,17 @@
92 with azc_server(one, cacheone, PORT, one_config):
93 with azc_server(two, cachetwo, PORT+1, two_config):
94 time.sleep(3.0) # wait for one to discover two
95- data = urlopen('http://localhost:%i/http://example.com/%s' % (
96- PORT, DEBNAME)).read()
97+ data = urlopen(
98+ 'http://localhost:%i/http://notexist.example.com/%s' % (
99+ PORT, DEBNAME)).read()
100 # make sure the data is equal
101 assert data == '*contents*'
102
103
104-def test_download_epoch_local_server(tmpdir):
105+def test_download_versionepoch_local_server(tmpdir):
106 """
107- Test fetching a file with an epoch from an AZC instance on the local network.
108+ Test fetching a file with an epoch from an AZC instance on the local
109+ network.
110 """
111 # cachedir is the directory to serve debs out of
112 one = path.join(str(tmpdir), 'one')
113@@ -146,8 +148,9 @@
114 with azc_server(one, cacheone, PORT, one_config):
115 with azc_server(two, cachetwo, PORT+1, two_config):
116 time.sleep(3.0) # wait for one to discover two
117- data = urlopen('http://localhost:%i/http://example.com/%s' % (
118- PORT, DEBNAME)).read()
119+ data = urlopen(
120+ 'http://localhost:%i/http://notexist.example.com/%s' % (
121+ PORT, DEBNAME)).read()
122 # make sure the data is equal
123 assert data == '*contents*'
124

Subscribers

People subscribed via source and target branches