def test_xmlrpc_interface_set(self): sp = xmlrpclib.ServerProxy( config.launchpad.feature_flags_endpoint, transport=XMLRPCTestTransport(), allow_none=True) flag_name = u'flag' with feature_flags(): set_feature_flag(flag_name, u'1') self.assertEqual(u'1', sp.getFeatureFlag(flag_name))
def test_getFeatureFlag_considers_supplied_scope(self): flag_name = u'flag' scope_name = u'scope' with feature_flags(): set_feature_flag(flag_name, u'value', scope_name) self.assertEqual( u'value', self.endpoint.getFeatureFlag(flag_name, [scope_name]))
def test_xmlrpc_interface_set(self): sp = xmlrpclib.ServerProxy(config.launchpad.feature_flags_endpoint, transport=XMLRPCTestTransport(), allow_none=True) flag_name = u'flag' with feature_flags(): set_feature_flag(flag_name, u'1') self.assertEqual(u'1', sp.getFeatureFlag(flag_name))
def test_getFeatureFlag_turns_user_into_team_scope(self): flag_name = u'flag' person = self.factory.makePerson() team = self.factory.makeTeam(members=[person]) with feature_flags(): set_feature_flag(flag_name, u'value', u'team:' + team.name) self.assertEqual( u'value', self.endpoint.getFeatureFlag( flag_name, ['user:' + person.name]))
def test_getFeatureFlag_turns_user_into_team_scope(self): flag_name = u'flag' person = self.factory.makePerson() team = self.factory.makeTeam(members=[person]) with feature_flags(): set_feature_flag(flag_name, u'value', u'team:' + team.name) self.assertEqual( u'value', self.endpoint.getFeatureFlag(flag_name, ['user:' + person.name]))
def test_getFeatureFlag_ignores_relevant_feature_controller(self): # getFeatureFlag should only consider the scopes it is asked to # consider, not any that happen to be active due to the XML-RPC # request itself. flag_name = u'flag' scope_name = u'scope' self.installFeatureController( FeatureController( MultiScopeHandler( [DefaultScope(), FixedScope(scope_name)]).lookup, StormFeatureRuleSource())) set_feature_flag(flag_name, u'1', scope_name) self.assertEqual(None, self.endpoint.getFeatureFlag(flag_name))
def test_getFeatureFlag_ignores_relevant_feature_controller(self): # getFeatureFlag should only consider the scopes it is asked to # consider, not any that happen to be active due to the XML-RPC # request itself. flag_name = u'flag' scope_name = u'scope' self.installFeatureController( FeatureController( MultiScopeHandler([DefaultScope(), FixedScope(scope_name)]).lookup, StormFeatureRuleSource())) set_feature_flag(flag_name, u'1', scope_name) self.assertEqual(None, self.endpoint.getFeatureFlag(flag_name))
def test_getFeatureFlag_returns_true_for_set_flag(self): flag_name = u'flag' with feature_flags(): set_feature_flag(flag_name, u'1') self.assertEqual(u'1', self.endpoint.getFeatureFlag(flag_name))
def test_flags_unset_outside_feature_flags_context(self): """get fails when used outside the feature_flags context.""" with feature_flags(): set_feature_flag(u'name', u'value') self.assertIs(None, getFeatureFlag('name'))
def test_flags_set_within_feature_flags_context(self): """In the feature_flags context, set/get works.""" self.useContext(feature_flags()) set_feature_flag(u'name', u'value') self.assertEqual('value', getFeatureFlag('name'))