Ejemplo n.º 1
0
 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))
Ejemplo n.º 2
0
 def getFeatureFlag(self, flag_name, active_scopes=()):
     scopes = list(default_scopes)
     for scope_name in active_scopes:
         if scope_name.startswith('user:'******'user:'):])
             if person is not None:
                 scopes.append(TeamScope(lambda: person))
         else:
             scopes.append(FixedScope(scope_name))
     flag_name = unicode(flag_name)
     controller = FeatureController(
         MultiScopeHandler(scopes).lookup, StormFeatureRuleSource())
     return controller.getFlag(flag_name)
Ejemplo n.º 3
0
 def test_MultiScopeHandler_lookup_finds_matching_scope(self):
     scope_name = self.factory.getUniqueString()
     handler = MultiScopeHandler([FakeScope(scope_name)])
     self.assertTrue(handler.lookup("fake:" + scope_name))
Ejemplo n.º 4
0
 def test_MultiScopeHandler_lookup_ignores_inapplicable_scope(self):
     scope_name = self.factory.getUniqueString()
     handler = MultiScopeHandler([FakeScope(scope_name)])
     self.assertFalse(handler.lookup("fake:other"))
Ejemplo n.º 5
0
 def test_MultiScopeHandler_lookup_ignores_unmatched_scope(self):
     scope_name = self.factory.getUniqueString()
     fake_scope = FakeScope(scope_name)
     handler = MultiScopeHandler([fake_scope])
     self.assertFalse(handler.lookup("other:other"))
Ejemplo n.º 6
0
 def test_MultiScopeHandler_lookup_finds_matching_scope(self):
     scope_name = self.factory.getUniqueString()
     handler = MultiScopeHandler([FakeScope(scope_name)])
     self.assertTrue(handler.lookup("fake:" + scope_name))
Ejemplo n.º 7
0
 def test_MultiScopeHandler_lookup_ignores_inapplicable_scope(self):
     scope_name = self.factory.getUniqueString()
     handler = MultiScopeHandler([FakeScope(scope_name)])
     self.assertFalse(handler.lookup("fake:other"))
Ejemplo n.º 8
0
 def test_MultiScopeHandler_lookup_ignores_unmatched_scope(self):
     scope_name = self.factory.getUniqueString()
     fake_scope = FakeScope(scope_name)
     handler = MultiScopeHandler([fake_scope])
     self.assertFalse(handler.lookup("other:other"))