Merge lp:~rvb/launchpad/dds-missing-base-version-747202 into lp:launchpad

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 12780
Proposed branch: lp:~rvb/launchpad/dds-missing-base-version-747202
Merge into: lp:launchpad
Diff against target: 226 lines (+103/-11)
4 files modified
lib/lp/registry/browser/distroseriesdifference.py (+1/-0)
lib/lp/registry/browser/tests/test_distroseriesdifference_views.py (+89/-7)
lib/lp/registry/templates/distroseriesdifference-listing-extra.pt (+7/-3)
lib/lp/testing/factory.py (+6/-1)
To merge this branch: bzr merge lp:~rvb/launchpad/dds-missing-base-version-747202
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email: mp+56311@code.launchpad.net

Commit message

[r=jcsackett][bug=747202] Fix the UI on the localpackagediffs page when dsd's base_version is None.

Description of the change

This branch fixes the UI on the localpackagediffs page when dsd's base_version is None. It displays 'unknown' instead of an empty line for "Last common version:" and prevents the package diff slot to be displayed.

== Tests ==
./bin/test -cvv test_distroseriesdifference_views test_package_diff_no_base_version

== QA ==
- Fire up a local instance.
- Turn on the feature flag :
    'soyuz.derived-series-ui.enabled default 1 on'
- Update the dsd:
    update distroseriesdifference set base_version = NULL ;
- Access the page
    https://launchpad.dev/deribuntu/deriwarty/+localpackagediffs
- Open up the first row.
- Make sure:
    - "Last common version:" is Unknown.
    - the package diff request link is not there.

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

As discussed in IRC, I think this needs to be investigated, as I'm not sure the boolean logic ever evaulates to True

=== modified file 'lib/lp/registry/templates/distroseriesdifference-listing-extra.pt'
--- lib/lp/registry/templates/distroseriesdifference-listing-extra.pt 2011-03-31 20:40:32 +0000
+++ lib/lp/registry/templates/distroseriesdifference-listing-extra.pt 2011-04-05 10:03:19 +0000
@@ -48,10 +48,13 @@
         </span>
     </dt>
     <dt
- tal:condition="not: view/show_package_diffs_request_link">
+ tal:condition="python: not(view.show_package_diffs_request_link) and context.base_version">
       Differences from last common version:
     </dt>
- <dd>
+ <dd class="greyed-out" tal:condition="not: context/base_version">
+ Unknown
+ </dd>
+ <dd tal:condition="context/base_version">
       <ul class="package-diff-status">
         <tal:source-diff-option condition="view/display_child_diff">
           <li tal:condition="context/package_diff">

As you said, it could probably use a test to make sure things *are* displayed under the right conditions and not just *not* displayed as appropriate.

review: Needs Information
Revision history for this message
j.c.sackett (jcsackett) wrote :

This looks good to land. Thanks for adding the test.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/distroseriesdifference.py'
2--- lib/lp/registry/browser/distroseriesdifference.py 2011-04-06 07:34:18 +0000
3+++ lib/lp/registry/browser/distroseriesdifference.py 2011-04-08 06:51:07 +0000
4@@ -178,6 +178,7 @@
5 request link.
6 """
7 return (check_permission('launchpad.Edit', self.context) and
8+ self.context.base_version and
9 (not self.context.package_diff or
10 not self.context.parent_package_diff))
11
12
13=== modified file 'lib/lp/registry/browser/tests/test_distroseriesdifference_views.py'
14--- lib/lp/registry/browser/tests/test_distroseriesdifference_views.py 2011-04-05 13:18:48 +0000
15+++ lib/lp/registry/browser/tests/test_distroseriesdifference_views.py 2011-04-08 06:51:07 +0000
16@@ -9,7 +9,10 @@
17
18 from BeautifulSoup import BeautifulSoup
19 import soupmatchers
20-from testtools.matchers import Not
21+from testtools.matchers import (
22+ MatchesAny,
23+ Not,
24+ )
25 import transaction
26 from zope.component import getUtility
27
28@@ -39,6 +42,7 @@
29 person_logged_in,
30 TestCaseWithFactory,
31 )
32+from zope.security.proxy import removeSecurityProxy
33 from lp.testing.views import create_initialized_view
34
35
36@@ -261,7 +265,8 @@
37 def test_both_request_diff_texts_rendered(self):
38 # An unlinked description of a potential diff is displayed when
39 # no diff is present.
40- ds_diff = self.factory.makeDistroSeriesDifference()
41+ ds_diff = self.factory.makeDistroSeriesDifference(
42+ set_base_version=True)
43
44 view = create_initialized_view(ds_diff, '+listing-distroseries-extra')
45 # Both diffs present simple text repr. of proposed diff.
46@@ -270,7 +275,8 @@
47 def test_source_diff_rendering_diff(self):
48 # A linked description of the diff is displayed when
49 # it is present.
50- ds_diff = self.factory.makeDistroSeriesDifference()
51+ ds_diff = self.factory.makeDistroSeriesDifference(
52+ set_base_version=True)
53
54 with person_logged_in(ds_diff.derived_series.owner):
55 ds_diff.package_diff = self.factory.makePackageDiff()
56@@ -286,7 +292,8 @@
57 def test_source_diff_rendering_diff_no_link(self):
58 # The status of the package is shown if the package diff is in a
59 # PENDING or FAILED state.
60- ds_diff = self.factory.makeDistroSeriesDifference()
61+ ds_diff = self.factory.makeDistroSeriesDifference(
62+ set_base_version=True)
63
64 statuses_and_classes = [
65 (PackageDiffStatus.PENDING, 'PENDING'),
66@@ -309,7 +316,8 @@
67 def test_parent_source_diff_rendering_diff_no_link(self):
68 # The status of the package is shown if the parent package diff is
69 # in a PENDING or FAILED state.
70- ds_diff = self.factory.makeDistroSeriesDifference()
71+ ds_diff = self.factory.makeDistroSeriesDifference(
72+ set_base_version=True)
73
74 statuses_and_classes = [
75 (PackageDiffStatus.PENDING, 'PENDING'),
76@@ -342,7 +350,8 @@
77 def test_parent_source_diff_rendering_diff(self):
78 # A linked description of the diff is displayed when
79 # it is present.
80- ds_diff = self.factory.makeDistroSeriesDifference()
81+ ds_diff = self.factory.makeDistroSeriesDifference(
82+ set_base_version=True)
83
84 with person_logged_in(ds_diff.derived_series.owner):
85 ds_diff.parent_package_diff = self.factory.makePackageDiff()
86@@ -425,7 +434,8 @@
87 def test_package_diff_request_link(self):
88 # The link to compute package diffs is only shown to
89 # a user with lp.Edit persmission.
90- ds_diff = self.factory.makeDistroSeriesDifference()
91+ ds_diff = self.factory.makeDistroSeriesDifference(
92+ set_base_version=True)
93 package_diff_request_matcher = soupmatchers.HTMLContains(
94 soupmatchers.Tag(
95 'Request link', 'a',
96@@ -443,3 +453,75 @@
97 ds_diff, '+listing-distroseries-extra')
98 self.assertThat(view(), package_diff_request_matcher)
99 self.assertTrue(view.show_package_diffs_request_link)
100+
101+ def test_package_diff_label(self):
102+ # If base_version is not None the label for the section is
103+ # there.
104+ changelog_lfa = self.factory.makeChangelog('foo', ['0.30-1'])
105+ parent_changelog_lfa = self.factory.makeChangelog(
106+ 'foo', ['0.32-1', '0.30-1'])
107+ transaction.commit() # Yay, librarian.
108+ ds_diff = self.factory.makeDistroSeriesDifference(versions={
109+ 'derived': '0.30-1',
110+ 'parent': '0.32-1',
111+ }, changelogs={
112+ 'derived': changelog_lfa,
113+ 'parent': parent_changelog_lfa})
114+ package_diff_header_matcher = soupmatchers.HTMLContains(
115+ soupmatchers.Tag(
116+ 'Package diffs header', 'dt',
117+ text=re.compile(
118+ '\s*Differences from last common version:')))
119+
120+ with celebrity_logged_in('admin'):
121+ ds_diff.parent_package_diff = self.factory.makePackageDiff()
122+ ds_diff.package_diff = self.factory.makePackageDiff()
123+ view = create_initialized_view(
124+ ds_diff, '+listing-distroseries-extra')
125+ html = view()
126+ self.assertThat(html, package_diff_header_matcher)
127+
128+ def test_package_diff_no_base_version(self):
129+ # If diff's base_version is None packages diffs are not displayed
130+ # and neither is the link to compute them.
131+ versions={
132+ 'base': None, # No base version.
133+ 'derived': '0.1-1derived1',
134+ 'parent': '0.1-2'}
135+ ds_diff = self.factory.makeDistroSeriesDifference(versions=versions)
136+ package_diff_request_matcher = soupmatchers.HTMLContains(
137+ soupmatchers.Tag(
138+ 'Request link', 'a',
139+ text=re.compile(
140+ '\s*Compute differences from last common version\s*')))
141+
142+ pending_package_diff_matcher = soupmatchers.HTMLContains(
143+ soupmatchers.Tag(
144+ 'Pending package diff', 'span',
145+ attrs={'class': 'PENDING'}))
146+
147+ package_diff_header_matcher = soupmatchers.HTMLContains(
148+ soupmatchers.Tag(
149+ 'Package diffs header', 'dt',
150+ text=re.compile(
151+ '\s*Differences from last common version:')))
152+
153+ unknown_base_version = soupmatchers.HTMLContains(
154+ soupmatchers.Tag(
155+ 'Unknown base version', 'dd',
156+ text=re.compile(
157+ '\s*Unknown')))
158+
159+ with celebrity_logged_in('admin'):
160+ view = create_initialized_view(
161+ ds_diff, '+listing-distroseries-extra')
162+ html = view()
163+ self.assertFalse(view.show_package_diffs_request_link)
164+ self.assertThat(html, unknown_base_version)
165+ self.assertThat(
166+ html,
167+ Not(
168+ MatchesAny(
169+ package_diff_request_matcher,
170+ pending_package_diff_matcher,
171+ package_diff_header_matcher)))
172
173=== modified file 'lib/lp/registry/templates/distroseriesdifference-listing-extra.pt'
174--- lib/lp/registry/templates/distroseriesdifference-listing-extra.pt 2011-04-01 15:18:38 +0000
175+++ lib/lp/registry/templates/distroseriesdifference-listing-extra.pt 2011-04-08 06:51:07 +0000
176@@ -39,7 +39,11 @@
177 </ul></dd>
178 <tal:package-diffs tal:condition="view/can_have_packages_diffs">
179 <dt>Last common version:</dt>
180- <dd tal:content="context/base_version">1.2.1</dd>
181+ <dd tal:condition="context/base_version"
182+ tal:content="context/base_version">1.2.1</dd>
183+ <dd tal:condition="not: context/base_version">
184+ Unknown
185+ </dd>
186 <dt
187 tal:condition="view/show_package_diffs_request_link"
188 class="package-diff-placeholder">
189@@ -49,10 +53,10 @@
190 </span>
191 </dt>
192 <dt
193- tal:condition="not: view/show_package_diffs_request_link">
194+ tal:condition="python: not(view.show_package_diffs_request_link) and context.base_version">
195 Differences from last common version:
196 </dt>
197- <dd>
198+ <dd tal:condition="context/base_version">
199 <ul class="package-diff-status">
200 <tal:source-diff-option condition="view/display_child_diff">
201 <li tal:condition="context/package_diff">
202
203=== modified file 'lib/lp/testing/factory.py'
204--- lib/lp/testing/factory.py 2011-04-04 07:21:23 +0000
205+++ lib/lp/testing/factory.py 2011-04-08 06:51:07 +0000
206@@ -2304,7 +2304,8 @@
207 versions=None,
208 difference_type=DistroSeriesDifferenceType.DIFFERENT_VERSIONS,
209 status=DistroSeriesDifferenceStatus.NEEDS_ATTENTION,
210- changelogs=None):
211+ changelogs=None,
212+ set_base_version=False):
213 """Create a new distro series source package difference."""
214 if derived_series is None:
215 parent_series = self.makeDistroSeries()
216@@ -2358,6 +2359,10 @@
217
218 removeSecurityProxy(diff).status = status
219
220+ if set_base_version:
221+ version = versions.get('base', "%s.0" % self.getUniqueInteger())
222+ removeSecurityProxy(diff).base_version = version
223+
224 # We clear the cache on the diff, returning the object as if it
225 # was just loaded from the store.
226 clear_property_cache(diff)