LaunchpadTestRequest should not always set features to NullFeatureController

Bug #758649 reported by Gavin Panella
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Brad Crittenden

Bug Description

In a test, the following code did not work:

    def test_a_view(self):
        set_derived_series_ui_feature_flag(self)
        with person_logged_in(self.simple_user):
            view = create_initialized_view(...)
            html = view()
        self.assertThat(...)

Because LaunchpadTestRequest overrides self.features to
NullFeatureController, effectively ignoring any flags that have been
set up in the test, and preventing more flags from being configured.

In this instance the code worked when modified:

    from lp.services.features import get_relevant_feature_controller

    def test_a_view(self):
        set_derived_series_ui_feature_flag(self)
        with person_logged_in(self.simple_user):
            view = create_initialized_view(...)
            view.request.features = get_relevant_feature_controller()
            html = view()
        self.assertThat(...)

In this instance it was the template that queried request.features, so
it was possible to poke a sensible feature controller into place
before it was needed. However, this would not have worked if the view
initialization code had looked at request.features.

I'm not aware of the rationale behind clobbering LTR.features in this
way, especially with a not very useful feature controller. We *need*
to be able to write tests for code that is activated by feature flags.

This might be a duplicate of bug 631884 depending on your point of
view.

I am marking this as High importance because trying to diagnose this
problem consumed well over 2h of developer time.

Related branches

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 758649] [NEW] LaunchpadTestRequest should not always set features to NullFeatureController

I think NullFeatureController was quite possibly a mistake on my part
(specifically leftover tdd scaffolding), and if someone tackles this
please think about killing it entirely.

Martin

Brad Crittenden (bac)
Changed in launchpad:
status: Triaged → In Progress
assignee: nobody → Brad Crittenden (bac)
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
Changed in launchpad:
milestone: none → 11.05
tags: added: qa-needstesting
Changed in launchpad:
status: In Progress → Fix Committed
tags: added: qa-untestable
removed: qa-needstesting
Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.