def test_active_related_features__enabled_feature(self): # If a view has a non-empty sequence of related feature flags and if # only a non-default scope is defined and active, the property # active_related_features contains this feature flag. self.useFixture(FeatureFixture( {}, ( { u'flag': u'test_feature', u'scope': u'pageid:foo', u'priority': 0, u'value': u'on', }, ), override_scope_lookup=lambda scope_name: True)) request = LaunchpadTestRequest() view = LaunchpadView(object(), request) view.related_features = ['test_feature'] self.assertEqual({ 'test_feature': { 'is_beta': True, 'title': 'title', 'url': 'http://wiki.lp.dev/LEP/sample', 'value': 'on'} }, view.related_feature_info)
def test_related_feature_info__enabled_feature_with_default_same_value( self): # If a view # * has a non-empty sequence of related feature flags, # * the default scope and a non-default scope are defined # and have the same values, # then is_beta is false. # Unless related_features forces it to always be beta, and the # flag is set. self.useFixture( FeatureFixture({}, self.makeFeatureFlagDictionaries(u'on', u'on'), override_scope_lookup=lambda scope_name: True)) request = LaunchpadTestRequest() view = LaunchpadView(object(), request) view.related_features = {'test_feature': False} self.assertEqual( { 'test_feature': { 'is_beta': False, 'title': 'title', 'url': 'http://wiki.lp.dev/LEP/sample', 'value': 'on', } }, view.related_feature_info) view.related_features['test_feature'] = True self.assertEqual( { 'test_feature': { 'is_beta': True, 'title': 'title', 'url': 'http://wiki.lp.dev/LEP/sample', 'value': 'on', } }, view.related_feature_info) self.useFixture( FeatureFixture({}, self.makeFeatureFlagDictionaries(u'on', u''), override_scope_lookup=lambda scope_name: True)) self.assertEqual( { 'test_feature': { 'is_beta': False, 'title': 'title', 'url': 'http://wiki.lp.dev/LEP/sample', 'value': '', } }, view.related_feature_info)
def test_related_feature_info__with_related_feature_nothing_enabled(self): # If a view has a non-empty sequence of related feature flags but if # no matching feature rules are defined, is_beta is False. request = LaunchpadTestRequest() view = LaunchpadView(object(), request) view.related_features = ['test_feature'] self.assertEqual({ 'test_feature': { 'is_beta': False, 'title': 'title', 'url': 'http://wiki.lp.dev/LEP/sample', 'value': None, } }, view.related_feature_info)
def test_related_feature_info__enabled_feature_with_default_same_value( self): # If a view # * has a non-empty sequence of related feature flags, # * the default scope and a non-default scope are defined # and have the same values, # then is_beta is false. self.useFixture(FeatureFixture( {}, self.makeFeatureFlagDictionaries(u'on', u'on'), override_scope_lookup=lambda scope_name: True)) request = LaunchpadTestRequest() view = LaunchpadView(object(), request) view.related_features = ['test_feature'] self.assertEqual({'test_feature': { 'is_beta': False, 'title': 'title', 'url': 'http://wiki.lp.dev/LEP/sample', 'value': 'on', }}, view.related_feature_info)
def test_related_features__enabled_feature_with_default(self): # If a view # * has a non-empty sequence of related feature flags, # * the default scope and a non-default scope are defined # but have different values, # then the property related_feature_info contains this feature flag. self.useFixture(FeatureFixture( {}, self.makeFeatureFlagDictionaries(u'', u'on'), override_scope_lookup=lambda scope_name: True)) request = LaunchpadTestRequest() view = LaunchpadView(object(), request) view.related_features = ['test_feature'] self.assertEqual({ 'test_feature': { 'is_beta': True, 'title': 'title', 'url': 'http://wiki.lp.dev/LEP/sample', 'value': 'on', }}, view.related_feature_info)
def test_related_feature_info__default_scope_only(self): # If a view has a non-empty sequence of related feature flags but if # only a default scope is defined, it is not considered beta. self.useFixture( FeatureFixture({}, ({ u'flag': u'test_feature', u'scope': u'default', u'priority': 0, u'value': u'on', }, ))) request = LaunchpadTestRequest() view = LaunchpadView(object(), request) view.related_features = {'test_feature': False} self.assertEqual( { 'test_feature': { 'is_beta': False, 'title': 'title', 'url': 'http://wiki.lp.dev/LEP/sample', 'value': 'on', } }, view.related_feature_info)
def test_related_feature_info__default_scope_only(self): # If a view has a non-empty sequence of related feature flags but if # only a default scope is defined, it is not considered beta. self.useFixture(FeatureFixture( {}, ( { u'flag': u'test_feature', u'scope': u'default', u'priority': 0, u'value': u'on', }, ))) request = LaunchpadTestRequest() view = LaunchpadView(object(), request) view.related_features = ['test_feature'] self.assertEqual({'test_feature': { 'is_beta': False, 'title': 'title', 'url': 'http://wiki.lp.dev/LEP/sample', 'value': 'on', }}, view.related_feature_info)