Merge lp:~mabac/svammel/specify-single-component into lp:svammel

Proposed by Mattias Backman
Status: Merged
Approved by: James Westby
Approved revision: 106
Merged at revision: 106
Proposed branch: lp:~mabac/svammel/specify-single-component
Merge into: lp:svammel
Diff against target: 145 lines (+55/-5)
4 files modified
config.py (+4/-0)
data_parsing.py (+9/-3)
file-failures.py (+1/-1)
tests/test_fail_filer.py (+41/-1)
To merge this branch: bzr merge lp:~mabac/svammel/specify-single-component
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Matthias Klose Pending
Review via email: mp+73764@code.launchpad.net

Description of the change

Hi,

This branch adds support for specifying --component from a list of 'main', 'restricted', 'universe', 'multiverse' to have svammel only work on build records from that repository component.

Thanks,

Mattias

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

Looks great.

Thanks,

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.py'
2--- config.py 2011-04-17 21:39:22 +0000
3+++ config.py 2011-09-02 09:46:40 +0000
4@@ -174,5 +174,9 @@
5 parser.add_argument(
6 '--target-series', dest='targetseries',
7 help='If specified, will be nominated for all created bugs.')
8+ parser.add_argument(
9+ '--component',
10+ choices=['main', 'restricted', 'universe', 'multiverse'],
11+ help='If specified, only look for build in this repository component.')
12
13 return parser
14
15=== modified file 'data_parsing.py'
16--- data_parsing.py 2011-06-07 09:16:17 +0000
17+++ data_parsing.py 2011-09-02 09:46:40 +0000
18@@ -163,7 +163,7 @@
19 return candidate_spph
20
21
22-def fetch_pkg_list(archives, build_state):
23+def fetch_pkg_list(archives, build_state, component):
24 all_spph = dict()
25 for archive, archive_name in archives:
26 logger.info("Packages with state '%s' in '%s'."
27@@ -176,6 +176,12 @@
28 # Build record for an older version
29 continue
30
31+ if component is not None and csp.component_name != component:
32+ logger.debug("Only interested in repository '%s' but build " \
33+ "'%s' is in '%s'" % (component, build.title,
34+ csp.component_name))
35+ continue
36+
37 logger.info("Found build '%s'" % build.title)
38
39 stored_spph = all_spph.get(csp.source_package_name)
40@@ -324,7 +330,7 @@
41
42
43 def get_build_status(archive_names, series_name, fail_platform, ok_platforms,
44- build_state):
45+ build_state, component):
46 """Download live data from lp.
47
48 Parameters:
49@@ -342,5 +348,5 @@
50
51 logger.info("Will be getting builds from archives " + ", ".join(
52 name for (archive, name) in archives))
53- spph_list = fetch_pkg_list(archives, build_state)
54+ spph_list = fetch_pkg_list(archives, build_state, component)
55 return filter_spph(spph_list, fail_platform, ok_platforms, archives)
56
57=== modified file 'file-failures.py'
58--- file-failures.py 2011-06-07 09:05:34 +0000
59+++ file-failures.py 2011-09-02 09:46:40 +0000
60@@ -90,7 +90,7 @@
61 try:
62 interesting_spph = get_build_status(args.archive, args.series,
63 fail_platform, ok_platforms,
64- FAILED_BUILD_STATE)
65+ FAILED_BUILD_STATE, args.component)
66 except:
67 logger.critical('Could not get build status.')
68 raise
69
70=== modified file 'tests/test_fail_filer.py'
71--- tests/test_fail_filer.py 2011-09-01 13:51:10 +0000
72+++ tests/test_fail_filer.py 2011-09-02 09:46:40 +0000
73@@ -36,7 +36,9 @@
74 get_highest_version,
75 filter_spph,
76 get_build_list,
77+ fetch_pkg_list,
78 )
79+import data_parsing
80 import bug_reporting
81 from bug_reporting import (
82 bug_already_filed_by_url,
83@@ -84,9 +86,10 @@
84
85 class MockRecord(object):
86 class CSP:
87- def __init__(self, name, version):
88+ def __init__(self, name, version, component_name='main'):
89 self.source_package_name = name
90 self.source_package_version = version
91+ self.component_name = component_name
92
93 def __init__(self, arch, datecreated, state=FAILED_BUILD_STATE,
94 name='packagename', version='1', archive=None):
95@@ -112,6 +115,12 @@
96 self.has_been_called = True
97 return self.records_to_return
98
99+ class MockBuild(object):
100+ def __init__(self, csp, title):
101+ self.current_source_publication = csp
102+ self.title = title
103+ self.arch_tag = 'armel'
104+
105 def setUp(self):
106 super(TestFilter, self).setUp()
107
108@@ -123,6 +132,37 @@
109 Launchpad, 'login_with', classmethod(mock_func)))
110 init('staging', 'dummyapp', 'dummycache')
111
112+ def test_fetch_wanted_component(self):
113+ self.init_dummy_config()
114+ pkgname = 'testname'
115+ wanted_component = 'main'
116+ failrecord = self.MockRecord(TEST_FAIL_ARCH, datetime.now(),
117+ FAILED_BUILD_STATE)
118+ def mock_func(archive, build_state):
119+ return [self.MockBuild(self.MockRecord.CSP(
120+ pkgname, '1.0', wanted_component), 'title')]
121+
122+ self.useFixture(MockSomethingFixture(
123+ data_parsing, 'get_build_list', mock_func))
124+ pkgs = fetch_pkg_list([('archive','archive')], 'build_state',
125+ wanted_component)
126+ self.assertEquals(pkgname, pkgs[pkgname].package_name)
127+
128+ def test_fetch_not_wanted_component(self):
129+ self.init_dummy_config()
130+ pkgname = 'testname'
131+ wanted_component = 'main'
132+ failrecord = self.MockRecord(TEST_FAIL_ARCH, datetime.now(),
133+ FAILED_BUILD_STATE)
134+ def mock_func(archive, build_state):
135+ return [self.MockBuild(self.MockRecord.CSP(
136+ pkgname, '1.0', 'universe'), 'title')]
137+
138+ self.useFixture(MockSomethingFixture(
139+ data_parsing, 'get_build_list', mock_func))
140+ pkgs = fetch_pkg_list([('archive','archive')], 'build_state', wanted_component)
141+ self.assertEquals(pkgs, {})
142+
143 def test_filter_only_checks_other_archives(self):
144 self.init_dummy_config()
145 archive_with_failure = self.MockArchive('failarchive')

Subscribers

People subscribed via source and target branches