Code review comment for lp:~wallyworld/launchpad/delete-bugtask-ui-878909

Revision history for this message
Ian Booth (wallyworld) wrote :

I figured out how to avoid using TestBrowser. One key step was to shove
the default bugtask into LaunchBag. Then the view for each table row had
to be constructed and rendered separately. Obvious!

>
> The TestBrowser is an indirect means to test rendering. The view does that.
> you can render any view (that had the principal argument passed) by calling
> it; view(). Launchpad views add striping rules so __call__ calls render().
> You can render a view's templates using view() or view.render(). It is much
> faster than TestBrowser.

<new stuff>
             login_person(bugtask.owner)
             getUtility(ILaunchBag).add(bug.default_bugtask)
             view = create_initialized_view(
                 bug, name='+bugtasks-and-nominations-table',
                 principal=bugtask.owner)
             # We render the bug task table rows - there are 2 bug tasks.
             subviews = view.getBugTaskAndNominationViews()
             self.assertEqual(2, len(subviews))
             default_bugtask_contents = subviews[0]()
             bugtask_contents = subviews[1]()
</new stuff>
             # bugtask can be deleted because the user owns it.
             delete_icon = find_tag_by_id(
                 bugtask_contents, 'bugtask-delete-task%d' % bugtask.id)
             delete_url = canonical_url(
                 bugtask, rootsite='bugs', view_name='+delete')
             self.assertEqual(delete_url, delete_icon['href'])
             # default_bugtask cannot be deleted.
             delete_icon = find_tag_by_id(
                 default_bugtask_contents,
                 'bugtask-delete-task%d' % bug.default_bugtask.id)
             self.assertIsNone(delete_icon)

« Back to merge proposal