예제 #1
0
    def test_getAllRulesAsText(self):
        source = StormFeatureRuleSource()
        source.setAllRules(test_rules_list)
        self.assertEquals(
            """\
%s\tbeta_user\t100\t%s
ui.icing\tnormal_user\t500\t5.0
ui.icing\tbeta_user\t300\t4.0
ui.icing\tdefault\t100\t3.0
""" % (notification_name, notification_value), source.getAllRulesAsText())
예제 #2
0
    def test_getAllRulesAsText(self):
        source = StormFeatureRuleSource()
        source.setAllRules(test_rules_list)
        self.assertEquals(
            """\
%s\tbeta_user\t100\t%s
ui.icing\tnormal_user\t500\t5.0
ui.icing\tbeta_user\t300\t4.0
ui.icing\tdefault\t100\t3.0
"""
            % (notification_name, notification_value),
            source.getAllRulesAsText(),
        )
예제 #3
0
    def test_setAllRulesFromText(self):
        # We will overwrite existing data.
        source = StormFeatureRuleSource()
        source.setAllRules(test_rules_list)
        source.setAllRulesFromText(
            """

flag1   beta_user   200   alpha
flag1   default     100   gamma with spaces
flag2   default     0\ton
"""
        )
        self.assertEquals(
            {
                "flag1": [("beta_user", 200, "alpha"), ("default", 100, "gamma with spaces")],
                "flag2": [("default", 0, "on")],
            },
            source.getAllRulesAsDict(),
        )
예제 #4
0
    def setUp(self):
        """Set the feature flags that this fixture is responsible for."""
        super(FeatureFixture, self).setUp()

        rule_source = StormFeatureRuleSource()
        self.addCleanup(
            rule_source.setAllRules, rule_source.getAllRulesAsTuples())
        rule_source.setAllRules(self.makeNewRules())

        original_controller = get_relevant_feature_controller()

        def scope_lookup(scope_name):
            request = get_current_browser_request()
            return ScopesFromRequest(request).lookup(scope_name)

        if self.override_scope_lookup:
            scope_lookup = self.override_scope_lookup
        install_feature_controller(
            FeatureController(scope_lookup, rule_source))
        self.addCleanup(install_feature_controller, original_controller)
예제 #5
0
    def setUp(self):
        """Set the feature flags that this fixture is responsible for."""
        super(FeatureFixture, self).setUp()

        rule_source = StormFeatureRuleSource()
        self.addCleanup(rule_source.setAllRules,
                        rule_source.getAllRulesAsTuples())
        rule_source.setAllRules(self.makeNewRules())

        original_controller = get_relevant_feature_controller()

        def scope_lookup(scope_name):
            request = get_current_browser_request()
            return ScopesFromRequest(request).lookup(scope_name)

        if self.override_scope_lookup:
            scope_lookup = self.override_scope_lookup
        install_feature_controller(FeatureController(scope_lookup,
                                                     rule_source))
        self.addCleanup(install_feature_controller, original_controller)
예제 #6
0
    def test_setAllRulesFromText(self):
        # We will overwrite existing data.
        source = StormFeatureRuleSource()
        source.setAllRules(test_rules_list)
        source.setAllRulesFromText("""

flag1   beta_user   200   alpha
flag1   default     100   gamma with spaces
flag2   default     0\ton
""")
        self.assertEquals(
            {
                'flag1': [
                    ('beta_user', 200, 'alpha'),
                    ('default', 100, 'gamma with spaces'),
                ],
                'flag2': [
                    ('default', 0, 'on'),
                ],
            }, source.getAllRulesAsDict())
예제 #7
0
 def test_getAllRulesAsTuples(self):
     source = StormFeatureRuleSource()
     source.setAllRules(test_rules_list)
     self.assertEquals(test_rules_list, list(source.getAllRulesAsTuples()))
예제 #8
0
 def test_getAllRulesAsTuples(self):
     source = StormFeatureRuleSource()
     source.setAllRules(test_rules_list)
     self.assertEquals(test_rules_list, list(source.getAllRulesAsTuples()))