Hello Bac,
thanks for making Launchpad a bit more user-friendly! ;-) I still need to send
you on another round-trip, though. Please find my comments below.
Henning
Am 04.10.2010 15:44, schrieb Brad Crittenden:
> === modified file 'lib/lp/bugs/browser/bugtask.py'
> --- lib/lp/bugs/browser/bugtask.py 2010-09-28 14:50:19 +0000
> +++ lib/lp/bugs/browser/bugtask.py 2010-10-04 12:55:59 +0000
> @@ -168,6 +168,7 @@
> ObjectImageDisplayAPI,
> PersonFormatterAPI,
> )
> +
> from canonical.lazr.interfaces import IObjectPrivacy
> from canonical.lazr.utils import smartquote
> from canonical.widgets.bug import BugTagsWidget
> @@ -2987,8 +2988,17 @@
> return False
>
> @property
> + def should_show_bug_information(self):
> + """Return False if a project group that does not use Launchpad."""
> + if not self._projectContext():
> + return True
> + involvement = getMultiAdapter((self.context, self.request),
> + name="+get-involved")
> + return involvement.official_malone
This seems odd, to create a view just to get a property that is really a
property of the context. The "official_malone" property should be defined in
ProjectGroup and could be implemented like this: ;-)
@cachedproperty
def offcial_malone(self):
return any([product.offcial_malone for product in self.products])
Unless I misunderstood something, I see this misuse of a view as a real
blocker for landing this. This earned you the "need-fixing" ;-)
> +
> + @property
> def form_has_errors(self):
> - """Return True of the form has errors, otherwise False."""
> + """Return True if the form has errors, otherwise False."""
This looks like a forgotten sanity check? If you wish to keep it in here you
should give it its own tests and mention in the comment their sanity nature.
> +
> + def test_empty_project_group(self):
This one and the next three tests belong in the model tests for
ProjectGroup.official_malone.
> + # An empty project group does not use Launchpad for bugs.
> + view = create_initialized_view(
> + self.projectgroup, name=u'+bugs', rootsite='bugs')
> + self.assertFalse(self.projectgroup.hasProducts())
> + self.assertFalse(view.should_show_bug_information)
> +
> + def test_project_group_with_subordinate_not_using_launchpad(self):
> + # A project group with all subordinates not using Launchpad
> + # will itself be marked as not using Launchpad for bugs.
> + self.makeSubordinateProduct(False)
> + self.assertTrue(self.projectgroup.hasProducts())
> + view = create_initialized_view(
> + self.projectgroup, name=u'+bugs', rootsite='bugs')
> + self.assertFalse(view.should_show_bug_information)
> +
> + def test_project_group_with_subordinate_using_launchpad(self):
> + # A project group with one subordinate using Launchpad
> + # will itself be marked as using Launchpad for bugs.
> + self.makeSubordinateProduct(True)
> + self.assertTrue(self.projectgroup.hasProducts())
> + view = create_initialized_view(
> + self.projectgroup, name=u'+bugs', rootsite='bugs')
> + self.assertTrue(view.should_show_bug_information)
> +
> + def test_project_group_with_mixed_subordinates(self):
You could keep this one in here to show that view.should_show_bug_information
really reflects ProjectGroup.official_malone
> + # A project group with one or more subordinates using Launchpad
> + # will itself be marked as using Launchpad for bugs.
> + self.makeSubordinateProduct(False)
> + self.makeSubordinateProduct(True)
> + self.assertTrue(self.projectgroup.hasProducts())
> + view = create_initialized_view(
> + self.projectgroup, name=u'+bugs', rootsite='bugs')
> + self.assertTrue(view.should_show_bug_information)
> +
> + def test_project_group_has_no_portlets_if_not_using_LP(self):
> + # A project group that has no projects using Launchpad will not have a
> + # 'Report a bug' link.
> + self.makeSubordinateProduct(False)
> + view = create_initialized_view(
> + self.projectgroup, name=u'+bugs', rootsite='bugs',
> + current_request=True)
> + self.assertFalse(view.should_show_bug_information)
> + contents = view.render()
> + report_a_bug = find_tag_by_id(contents, 'bug-portlets')
> + self.assertIs(None, report_a_bug)
> +
> + def test_project_group_has_portlets_link_if_using_LP(self):
> + # A project group that has no projects using Launchpad will not have a
> + # 'Report a bug' link.
Copy & paste error ;-) The comment needs negation ...
Hello Bac,
thanks for making Launchpad a bit more user-friendly! ;-) I still need to send
you on another round-trip, though. Please find my comments below.
Henning
Am 04.10.2010 15:44, schrieb Brad Crittenden: bugs/browser/ bugtask. py' bugs/browser/ bugtask. py 2010-09-28 14:50:19 +0000 bugs/browser/ bugtask. py 2010-10-04 12:55:59 +0000 layAPI, lazr.interfaces import IObjectPrivacy lazr.utils import smartquote widgets. bug import BugTagsWidget show_bug_ information( self): ntext() : ((self. context, self.request), get-involved" ) official_ malone
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -168,6 +168,7 @@
> ObjectImageDisp
> PersonFormatterAPI,
> )
> +
> from canonical.
> from canonical.
> from canonical.
> @@ -2987,8 +2988,17 @@
> return False
>
> @property
> + def should_
> + """Return False if a project group that does not use Launchpad."""
> + if not self._projectCo
> + return True
> + involvement = getMultiAdapter
> + name="+
> + return involvement.
This seems odd, to create a view just to get a property that is really a
property of the context. The "official_malone" property should be defined in
ProjectGroup and could be implemented like this: ;-)
@cachedproperty malone( self): offcial_ malone for product in self.products])
def offcial_
return any([product.
Unless I misunderstood something, I see this misuse of a view as a real
blocker for landing this. This earned you the "need-fixing" ;-)
> + errors( self):
> + @property
> def form_has_
> - """Return True of the form has errors, otherwise False."""
> + """Return True if the form has errors, otherwise False."""
Good catch! ;)
> return len(self.errors) > 0 ariesAdvancedFo rm(self) : bugs/browser/ tests/test_ bugtask. py' bugs/browser/ tests/test_ bugtask. py 2010-09-23 14:51:48 +0000 bugs/browser/ tests/test_ bugtask. py 2010-10-04 12:55:59 +0000
>
> def validateVocabul
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
[...]
> @@ -418,6 +424,88 @@ fields[ 'assignee' ].field. vocabularyName) pBugs(TestCaseW ithFactory) : onalLayer ctGroupBugs, self).setUp() makePerson( name='bob' ) makeProject( name='container ', Product( self, tracks_bugs_in_lp): makeProduct( official_ malone= tracks_ bugs_in_ lp) logged_ in(product. owner): tracks_ bugs_in_ lp], product. bug_tracking_ usage.name)
> view.form_
>
>
> +class TestProjectGrou
> + """Test the bugs overview page for Project Groups."""
> +
> + layer = LaunchpadFuncti
> +
> + def setUp(self):
> + super(TestProje
> + self.owner = self.factory.
> + self.projectgroup = self.factory.
> + owner=self.owner)
> +
> + def makeSubordinate
> + """Create a new product and add it to the project group."""
> + product = self.factory.
> + with person_
> + product.project = self.projectgroup
> + expected = {True: 'LAUNCHPAD',
> + False: 'UNKNOWN',
> + }
> + self.assertEqual(
> + expected[
This looks like a forgotten sanity check? If you wish to keep it in here you
should give it its own tests and mention in the comment their sanity nature.
> + project_ group(self) :
> + def test_empty_
This one and the next three tests belong in the model tests for official_ malone.
ProjectGroup.
> + # An empty project group does not use Launchpad for bugs. initialized_ view( e(self. projectgroup. hasProducts( )) e(view. should_ show_bug_ information) group_with_ subordinate_ not_using_ launchpad( self): inateProduct( False) (self.projectgr oup.hasProducts ()) initialized_ view( e(view. should_ show_bug_ information) group_with_ subordinate_ using_launchpad (self): inateProduct( True) (self.projectgr oup.hasProducts ()) initialized_ view( (view.should_ show_bug_ information) group_with_ mixed_subordina tes(self) :
> + view = create_
> + self.projectgroup, name=u'+bugs', rootsite='bugs')
> + self.assertFals
> + self.assertFals
> +
> + def test_project_
> + # A project group with all subordinates not using Launchpad
> + # will itself be marked as not using Launchpad for bugs.
> + self.makeSubord
> + self.assertTrue
> + view = create_
> + self.projectgroup, name=u'+bugs', rootsite='bugs')
> + self.assertFals
> +
> + def test_project_
> + # A project group with one subordinate using Launchpad
> + # will itself be marked as using Launchpad for bugs.
> + self.makeSubord
> + self.assertTrue
> + view = create_
> + self.projectgroup, name=u'+bugs', rootsite='bugs')
> + self.assertTrue
> +
> + def test_project_
You could keep this one in here to show that view.should_ show_bug_ information official_ malone
really reflects ProjectGroup.
> + # A project group with one or more subordinates using Launchpad inateProduct( False) inateProduct( True) (self.projectgr oup.hasProducts ()) initialized_ view( (view.should_ show_bug_ information) group_has_ no_portlets_ if_not_ using_LP( self): inateProduct( False) initialized_ view( request= True) e(view. should_ show_bug_ information) by_id(contents, 'bug-portlets') group_has_ portlets_ link_if_ using_LP( self):
> + # will itself be marked as using Launchpad for bugs.
> + self.makeSubord
> + self.makeSubord
> + self.assertTrue
> + view = create_
> + self.projectgroup, name=u'+bugs', rootsite='bugs')
> + self.assertTrue
> +
> + def test_project_
> + # A project group that has no projects using Launchpad will not have a
> + # 'Report a bug' link.
> + self.makeSubord
> + view = create_
> + self.projectgroup, name=u'+bugs', rootsite='bugs',
> + current_
> + self.assertFals
> + contents = view.render()
> + report_a_bug = find_tag_
> + self.assertIs(None, report_a_bug)
> +
> + def test_project_
> + # A project group that has no projects using Launchpad will not have a
> + # 'Report a bug' link.
Copy & paste error ;-) The comment needs negation ...
> + self.makeSubord inateProduct( True) initialized_ view( request= True) (view.should_ show_bug_ information) by_id(contents, 'bug-portlets') t(None, report_a_bug) TestLoader( ).loadTestsFrom Name(__ name__) DocTestSuite( bugtask) ) bugs/templates/ buglisting- default. pt'
> + view = create_
> + self.projectgroup, name=u'+bugs', rootsite='bugs',
> + current_
> + self.assertTrue
> + contents = view.render()
> + report_a_bug = find_tag_
> + self.assertIsNo
> +
> +
> def test_suite():
> suite = unittest.
> suite.addTest(
>
> === modified file 'lib/lp/
This looks OK.
[...] testing/ views.py' testing/ views.py 2010-09-19 03:09:49 +0000 testing/ views.py 2010-10-04 12:55:59 +0000 initialized_ view(context, name, form=None, layer=None, request= False):
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -85,7 +85,8 @@
> def create_
> server_url=None, method=None, principal=None,
> query_string=None, cookie=None, request=None,
> - path_info='/', rootsite=None):
> + path_info='/', rootsite=None,
> + current_
Thanks for improving our testing helpers. ;-)
> """Return a view that has already been initialized.""" request= current_ request)
> if method is None:
> if form is None:
> @@ -94,7 +95,8 @@
> method = 'POST'
> view = create_view(
> context, name, form, layer, server_url, method, principal,
> - query_string, cookie, request, path_info, rootsite=rootsite)
> + query_string, cookie, request, path_info, rootsite=rootsite,
> + current_
> view.initialize()
> return view
>
>