Merge lp:~jml/libdep-service/what-devportal-binary into lp:libdep-service

Proposed by Jonathan Lange
Status: Merged
Approved by: James Westby
Approved revision: 84
Merged at revision: 83
Proposed branch: lp:~jml/libdep-service/what-devportal-binary
Merge into: lp:libdep-service
Diff against target: 406 lines (+5/-334)
3 files modified
djlibdep/testing.py (+1/-6)
djlibdep/tests/test_configuration.py (+2/-2)
djlibdep/tests/test_database.py (+2/-326)
To merge this branch: bzr merge lp:~jml/libdep-service/what-devportal-binary
Reviewer Review Type Date Requested Status
Canonical Consumer Applications Hackers Pending
Review via email: mp+134323@code.launchpad.net

Commit message

Fix tests that incorrectly targeted pkgme-devportal rather than libdep-service

Description of the change

If I type something useful here, the internet will probably break again.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'djlibdep/testing.py'
2--- djlibdep/testing.py 2012-11-12 17:35:55 +0000
3+++ djlibdep/testing.py 2012-11-14 16:20:31 +0000
4@@ -139,11 +139,6 @@
5 self.addCleanup(self.db.close)
6
7
8-def ConfigFileFixture(location):
9- """Use a different configuration file."""
10- return EnvironmentVariableFixture(CONF_FILE_ENV_VAR, location)
11-
12-
13 class ConfigSettings(Fixture):
14 """Use a configuration file with different settings."""
15
16@@ -166,7 +161,7 @@
17 tempdir = self.useFixture(TempDir())
18 config_file_path = os.path.join(tempdir.path, 'test.cfg')
19 write_config_file(config_file_path, self._settings)
20- self.useFixture(ConfigFileFixture(config_file_path))
21+ self.useFixture(EnvironmentVariableFixture(CONF_FILE_ENV_VAR, config_file_path))
22
23
24 def make_config_section(key, values):
25
26=== modified file 'djlibdep/tests/test_configuration.py'
27--- djlibdep/tests/test_configuration.py 2012-11-12 17:50:43 +0000
28+++ djlibdep/tests/test_configuration.py 2012-11-14 16:20:31 +0000
29@@ -9,13 +9,13 @@
30 )
31 from testtools import TestCase
32
33-from devportalbinary.configuration import (
34+from ..configuration import (
35 _DEFAULT_CONF_FILE,
36 CONF_FILE_ENV_VAR,
37 get_config_file_path,
38 load_configuration,
39 )
40-from devportalbinary.testing import make_config_section
41+from ..testing import make_config_section
42
43
44 class TestConfigFileLocation(TestCase):
45
46=== modified file 'djlibdep/tests/test_database.py'
47--- djlibdep/tests/test_database.py 2012-11-12 17:50:43 +0000
48+++ djlibdep/tests/test_database.py 2012-11-14 16:20:31 +0000
49@@ -1,4 +1,3 @@
50-from collections import namedtuple
51 import os
52
53 from fixtures import TempDir
54@@ -10,40 +9,16 @@
55 Equals,
56 Matcher,
57 )
58-from treeshape import (
59- CONTENT,
60- FileTree,
61-)
62
63-from devportalbinary.database import (
64- AptFilePackageDatabase,
65- deb_file_url_for_publication,
66- dict_add,
67- find_file_under_dir,
68- get_dependency_database,
69- get_file_contents,
70- get_package_info_from_publication,
71- is_library_package,
72- LibdepServiceClient,
73- libdep_mapping_from_symbols,
74+from ..database import (
75 load_configuration,
76- NoSharedObject,
77- possible_sonames_for_shared_object,
78 PackageDatabase,
79- publishings_to_package_info,
80- shared_object_info_to_soname,
81- shared_objects_from_shlibs,
82- TooManySharedObjects,
83 )
84-from devportalbinary.testing import (
85- ConfigFileFixture,
86+from ..testing import (
87 ConfigSettings,
88 postgres_db_resource,
89 )
90
91-from djlibdep.test_double import LibdepServiceDouble
92-from libdep_service_client.client import Client
93-
94
95 class ResultsIn(Matcher):
96
97@@ -161,24 +136,6 @@
98 self.assertRaises(
99 ValueError, PackageDatabase.get_db_info_from_config, options)
100
101- def test_default_create_no_config(self):
102- nonexistent = self.getUniqueString()
103- self.useFixture(ConfigFileFixture(nonexistent))
104- self.assertIsInstance(
105- get_dependency_database(), AptFilePackageDatabase)
106-
107- def test_default_create_empty_config(self):
108- self.useFixture(ConfigSettings())
109- self.assertIsInstance(
110- get_dependency_database(), AptFilePackageDatabase)
111-
112- def test_remote_service(self):
113- base_url = 'http://example.com/libdep-service/'
114- self.use_database_config(db_type='libdep-service', base_url=base_url)
115- db = get_dependency_database()
116- self.assertIsInstance(db, LibdepServiceClient)
117- self.assertEqual(base_url, db._client.base_url)
118-
119 def test_get_db_info_from_config_postgres(self):
120 expected_username = self.getUniqueString()
121 expected_password = self.getUniqueString()
122@@ -200,284 +157,3 @@
123 self.assertEqual(expected_host, uri.host)
124 self.assertEqual(expected_password, uri.password)
125 self.assertEqual(expected_username, uri.username)
126-
127-
128-class FakeBPPH(object):
129-
130- def __init__(self):
131- self.archive = namedtuple(
132- 'Archive', 'web_link')('http://lp.net/archive')
133- self.distro_arch_series = namedtuple(
134- 'DistroArchSeries', 'architecture_tag')('i386')
135- self.binary_package_name = 'foo'
136- self.binary_package_version = '1'
137- self.architecture_specific = True
138-
139-
140-class TestDebFileUrlForPublication(TestCase):
141-
142- def test_get_url(self):
143- bpph = FakeBPPH()
144- expected_url = '%s/+files/%s_%s_%s.deb' % (
145- bpph.archive.web_link,
146- bpph.binary_package_name,
147- bpph.binary_package_version,
148- bpph.distro_arch_series.architecture_tag,
149- )
150- self.assertEqual(expected_url, deb_file_url_for_publication(bpph))
151-
152- def test_get_url_with_epoch(self):
153- # epochs are stripped from the version number
154- bpph = FakeBPPH()
155- bpph.binary_package_version = '1:1'
156- expected_url = '%s/+files/%s_%s_%s.deb' % (
157- bpph.archive.web_link,
158- bpph.binary_package_name,
159- '1',
160- bpph.distro_arch_series.architecture_tag,
161- )
162- self.assertEqual(expected_url, deb_file_url_for_publication(bpph))
163-
164- def test_get_url_for_arch_indep(self):
165- # epochs are stripped from the version number
166- bpph = FakeBPPH()
167- bpph.architecture_specific = False
168- expected_url = '%s/+files/%s_%s_all.deb' % (
169- bpph.archive.web_link,
170- bpph.binary_package_name,
171- '1',
172- )
173- self.assertEqual(expected_url, deb_file_url_for_publication(bpph))
174-
175-
176-class TestShlibs(TestCase):
177-
178- def test_empty(self):
179- self.assertEqual({}, shared_objects_from_shlibs(""))
180-
181- def test_comments(self):
182- self.assertEqual({}, shared_objects_from_shlibs("# aaaaa\n"))
183-
184- def test_blank_line(self):
185- self.assertEqual({}, shared_objects_from_shlibs("\n"))
186-
187- def test_whitespace_line(self):
188- self.assertEqual({}, shared_objects_from_shlibs(" \n"))
189-
190- def test_udeb_skipped(self):
191- self.assertEqual(
192- {}, shared_objects_from_shlibs("udeb: libfoo 1 libfoo\n"))
193-
194- def test_simple_soname(self):
195- self.assertEqual(
196- {('libfoo', '1'): 'libfoo'},
197- shared_objects_from_shlibs("libfoo 1 libfoo\n"))
198-
199- def test_other_type_of_soname(self):
200- self.assertEqual(
201- {('libfoo', '4.8'): 'libfoo'},
202- shared_objects_from_shlibs("libfoo 4.8 libfoo\n"))
203-
204-
205-class TestPossibleSonamesForSharedObject(TestCase):
206-
207- def test_no_dot(self):
208- self.assertEqual(
209- set(['libfoo.so.1', 'libfoo-1.so']),
210- possible_sonames_for_shared_object('libfoo', '1'))
211-
212- def test_dot(self):
213- self.assertEqual(
214- set(['libfoo-1.0.so']),
215- possible_sonames_for_shared_object('libfoo', '1.0'))
216-
217-
218-class TestFindFileUnderDir(TestCase):
219-
220- def test_file_missing(self):
221- tree = {}
222- path = self.useFixture(FileTree(tree)).path
223- self.assertEqual(None, find_file_under_dir('nothere', path))
224-
225- def test_file_in_basedir(self):
226- filename = 'here'
227- tree = {filename: {}}
228- built_tree = self.useFixture(FileTree(tree))
229- self.assertEqual(
230- built_tree.join(filename),
231- find_file_under_dir(filename, built_tree.path))
232-
233- def test_file_in_subdir(self):
234- filename = 'here'
235- relpath = 'there/' + filename
236- tree = {relpath: {}}
237- built_tree = self.useFixture(FileTree(tree))
238- self.assertEqual(
239- built_tree.join(relpath),
240- find_file_under_dir(filename, built_tree.path))
241-
242- def test_handles_multiple_matches(self):
243- filename = 'here'
244- relpath = 'there/' + filename
245- tree = {filename: {}, relpath: {}}
246- built_tree = self.useFixture(FileTree(tree))
247- self.assertEqual(
248- built_tree.join(filename),
249- find_file_under_dir(filename, built_tree.path))
250-
251-
252-class TestSharedObjectInfoToSoname(TestCase):
253-
254- def test_no_files(self):
255- tree = {}
256- path = self.useFixture(FileTree(tree)).path
257- self.assertRaises(
258- NoSharedObject,
259- shared_object_info_to_soname, 'libfoo', '1', path)
260-
261- def test_too_many_files(self):
262- libname = 'libfoo'
263- version = '1'
264- possible_sonames = possible_sonames_for_shared_object(libname, version)
265- tree = dict((name, {}) for name in possible_sonames)
266- path = self.useFixture(FileTree(tree)).path
267- self.assertRaises(
268- TooManySharedObjects,
269- shared_object_info_to_soname, libname, version, path)
270-
271- def test_file_found(self):
272- libname = 'libfoo'
273- version = '1'
274- expected_soname = '{0}.so.{1}'.format(libname, version)
275- tree = {expected_soname: {}}
276- path = self.useFixture(FileTree(tree)).path
277- self.assertEqual(
278- expected_soname,
279- shared_object_info_to_soname(libname, version, path))
280-
281-
282-class TestDictAdd(TestCase):
283-
284- def test_no_dicts(self):
285- self.assertEqual({}, dict_add())
286-
287- def test_one_dict(self):
288- self.assertEqual(dict(a=1), dict_add(dict(a=1)))
289-
290- def test_two_dicts(self):
291- self.assertEqual(dict(a=1, b=2), dict_add(dict(a=1), dict(b=2)))
292-
293- def test_precedence(self):
294- self.assertEqual(dict(a=2), dict_add(dict(a=1), dict(a=2)))
295-
296-
297-class TestIsLibraryPackage(TestCase):
298-
299- def test_lib_filename(self):
300- self.assertEqual(
301- True, is_library_package('http://launchpad.net/libfoo.deb'))
302-
303- def test_whitelisted(self):
304- self.assertEqual(
305- True, is_library_package('http://launchpad.net/zlib1g.deb'))
306-
307- def test_other(self):
308- self.assertEqual(
309- False, is_library_package('http://launchpad.net/bzr.deb'))
310-
311-
312-class TestGetPackageInfoFromPublication(TestCase):
313-
314- def test_returns_url_and_arch(self):
315- bpph = FakeBPPH()
316- self.assertEqual(
317- (deb_file_url_for_publication(bpph),
318- bpph.distro_arch_series.architecture_tag),
319- get_package_info_from_publication(bpph))
320-
321-
322-class TestPublishingsToPackageInfo(TestCase):
323-
324- def test_integration(self):
325- # This function is split out as it is the testable part of
326- # fetch symbols files. This tests that the functions glue
327- # together
328- publishings = [FakeBPPH(), FakeBPPH()]
329- expected_bpph = publishings[1]
330- expected_bpph.binary_package_name = 'libfoo'
331- expected_info = (
332- deb_file_url_for_publication(expected_bpph),
333- expected_bpph.distro_arch_series.architecture_tag)
334- self.assertEqual(
335- [expected_info], publishings_to_package_info(publishings))
336-
337-
338-class TestGetFileContents(TestCase):
339-
340- def test_exists(self):
341- expected_content = 'boring content\n'
342- filename = 'foo.txt'
343- tree = {filename: {CONTENT: expected_content}}
344- path = self.useFixture(FileTree(tree)).join(filename)
345- self.assertEqual(expected_content, get_file_contents(path))
346-
347- def test_not_exists(self):
348- tree = {}
349- path = self.useFixture(FileTree(tree)).join('nothere')
350- self.assertEqual(None, get_file_contents(path))
351-
352- def test_directory(self):
353- tree = {}
354- path = self.useFixture(FileTree(tree)).path
355- self.assertRaises(IOError, get_file_contents, path)
356-
357-
358-class TestLibdepMappingFromSymbols(TestCase):
359-
360- def test_empty(self):
361- self.assertEqual({}, libdep_mapping_from_symbols(''))
362-
363- def test_blank_line_ignored(self):
364- self.assertEqual({}, libdep_mapping_from_symbols('\n'))
365-
366- def test_alternate_template_ignored(self):
367- self.assertEqual({}, libdep_mapping_from_symbols('| foo\n'))
368-
369- def test_meta_information_ignored(self):
370- self.assertEqual({}, libdep_mapping_from_symbols('* foo\n'))
371-
372- def test_symbols_ignored(self):
373- self.assertEqual({}, libdep_mapping_from_symbols(' foo\n'))
374-
375- def test_comments_ignored(self):
376- self.assertEqual({}, libdep_mapping_from_symbols('# foo\n'))
377-
378- def test_include_ignored(self):
379- self.assertEqual(
380- {}, libdep_mapping_from_symbols('(arch=!armel)#include foo\n'))
381-
382- def test_includes_mapping(self):
383- self.assertEqual(
384- {'libfoo.so.1': 'libfoo'},
385- libdep_mapping_from_symbols('libfoo.so.1 libfoo #MINVER#\n'))
386-
387-
388-class TestLibdepServiceClient(TestCase):
389-
390- TEST_DATA = [('libfoo', {'i386': {'libfoo': 'libfoo-bin'}})]
391-
392- def test_wraps_libdep_service(self):
393- double = self.useFixture(LibdepServiceDouble(self.TEST_DATA))
394- client = Client(double.base_url)
395- wrapper = LibdepServiceClient(client)
396- self.assertEqual(
397- {'libfoo': set(['libfoo-bin'])},
398- wrapper.get_multiple_dependencies(['libfoo'], 'i386'))
399- self.assertEqual(
400- {}, wrapper.get_multiple_dependencies(['libbar'], 'i386'))
401-
402- def test_has_close_method(self):
403- client = Client('http://localhost/')
404- wrapper = LibdepServiceClient(client)
405- # Check that there is no exception
406- wrapper.close()

Subscribers

People subscribed via source and target branches